I am new to assembly and I am trying out simple code here,why is my prompt showing 3 times ? What do I need to do so it can only show me prompt once ?? I am missing a return somewhere ? I've tried ret for DisplayS and DisplayN and DisplayName but it still shows me twice...
INCLUDE Irvine32.inc
.data
;--------- Enter Data Here
vS BYTE "************", 0
vA BYTE "************", 0
vName BYTE "*************", 0
vHexPrompt BYTE "Please Enter the Value:" ,0
.code
main PROC
;--------- Enter Code Below Here
call Clrscr
call DisplayS
call DisplayA
call DisplayName
call DisplayPrompt
call DisplayString
call EndProgram
call Clrscr
;------------------------------------------------------------------
DisplayS:
mov dh, 4
mov dl, 33
call Gotoxy
mov edx, OFFSET vS
call WriteString
ret
;------------------------------------------------------------------
DisplayA:
mov dh, 5
mov dl, 33
call Gotoxy
mov edx, OFFSET vA
call WriteString
ret
;------------------------------------------------------------------
DisplayName:
mov dh, 6
mov dl, 33
call Gotoxy
mov edx, OFFSET vName
call WriteString
ret
;------------------------------------------------------------------
DisplayPrompt:
mov dh, 8
mov dl, 33
call Gotoxy
mov edx, OFFSET vHexPrompt
call WriteString
ret
;------------------------------------------------------
DisplayString:
call WriteString
ret
;----------------------------------------------------------
EndProgram:
xor ecx, ecx
call ReadChar
exit
main ENDP
END main
Your using WriteString
to display a string. WriteString
uses edx
to hold the address of the string to print.
You call DisplayPrompt
and move the address of vHexPrompt
into edx
, then you call DisplayString
and in that function, you call WriteString
. edx
still contains the address of vHexPrompt
which is why you are getting a double prompt.
Until you write more code to utilize DisplayString
, either comment out the call to writestring in that function, or just add xor edx, edx
right before your call to WriteString
in DisplayString