Hi,

I'm having problems with my code.
What I"m trying to do is print out a message to the screen asking for input and then take the input from the user.

The problem I'm having is the menu appears AFTER the user types in a string.
For instance, when I run this program I get the following output:
---------------------------------------------------------------
2
ENTER THE BASE OF THE NUMBER TO BE ENTERED OR 'Q' TO QUIT> ENTER A NUMBER>
--------------------------------------------------------------------------
where 2 is the number I typed in

The following is the code I have:

[GLOBAL mystart] ; export the start address
extern _printf
;----------------------------------------------------------------------------
[SECTION .text]
;----------------------------------------------------------------------------
; code belongs in this section starting here
mystart:
push dword promptBaseInput ; push the input-base prompt location.
call _printf ; call the printf function.
pop eax ; pop the value back.

call GETBASE

push dword promptNumberInput ; push the input-base prompt location.
call _printf ; call the printf function.
pop eax ; pop the value back.

endProg:
ret
GETBASE:
mov byte [baseStore], 98 ; baseStore can hold 98 characters
mov byte [baseStore+1], 0 ; reuse 0 characters from last input
mov ah, 0ah ; select buffered input function
mov edx, baseStore ; put baseStore address in EDX
int 0f1h ; call OS interrupt 0F1H
mov ah, 02h ; select write character function
mov dl, 10 ; output a newline
int 0f1h

ret ; return

;----------------------------------------------------------------------------
[SECTION .data]
;----------------------------------------------------------------------------
; all initialized data variables and constant definitions go here

promptBaseInput db "ENTER THE BASE OF THE NUMBER TO BE ENTERED OR 'Q' TO QUIT> ", 0
promptNumberInput db "ENTER A NUMBER> ", 0
promptBaseOutput db "ENTER THE BASE OF THE OUTPUT VALUE> ", 0
;----------------------------------------------------------------------------
[SECTION .bss]
;----------------------------------------------------------------------------
; all uninitialized data elements go here
baseStore resb 100 ; variable to store base of input
numberInput resb 100 ; variable to store number
;-----------------------

Thanks.

It's lot easier to follow your code if you wrap your code with

tags. Just to know for the future

It's lot easier to follow your code if you wrap your code with tags. Just to know for the future

Thanks. I'll wrap my code next time.


---------------------------------------------------------------------------

I figured what I was doing wrong. The problem turned out to be the gcc compiler I was using --> solved the problem after updating the version....... :eek: :cry:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.