masm - Assembly Language: Two-prompt user input (mix char and int) -


i new assembly programming , need understanding , fixing code have been struggling with: want provide user input:

prompt 1: enter destination read value prompt 2: enter destination read value display distance , destination.

i using vs2012 irvine32 libraries on x64 hardware. compiling x32.

the problem code compiles , builds. output not proper. first prompt displayed no input. second prompt "distance" displayed entry allowed. if change first prompt have "readint" instead of "readstring", prompts in both, "invalid integer" error. why this? how fix , display input values.

my code

include irvine32.inc  ;*************************************************************************       .data     querydest   byte   "destination", 0     querydist   byte   "distance", 0      destination       dword   ?     distance       dword   ?  .code  main proc         call clrscr          mov edx, offset querydest         call writestring         call readstring         mov destination, eax          call crlf         mov edx, offset querydist         call writestring         call readint         mov distance, eax          call crlf         call waitmsg        ;causes wait key pressed         exit main endp end main 

current output

destination

distance50

press key continue...

untested because vs 2012 refuses work (working on it). main problem destination must string, not number :

include irvine32.inc  ;*************************************************************************       .data     querydest   byte   "destination=", 0     querydist   byte   "distance=", 0      destination byte   "                     " ; length 21.     distance    dword   ?  .code  main proc         call clrscr  ;read destination.             mov edx, offset querydest         call writestring             ;display message.          mov edx, offset destination  ;store string here (zero terminated).         mov ecx, 20                  ;max chars read.         call readstring              ;stores string edx points.          call crlf  ;read distance.         mov edx, offset querydist         call writestring             ;display message.         call readint         mov distance, eax   ;display destination , distance.         call crlf         call crlf         mov edx, offset destination   ;edx points string display.         call writestring              ;display destination.         call crlf         mov eax, distance             ;number display.         call writeint                 ;display distance.          call crlf         call waitmsg        ;causes wait key pressed         exit main endp end main 

bibliography


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -