I have some code started but I am having problems saving the users string input into a variable.
Using ReadString I can get prompt the user to input a string, but after saving the users input into a variable named AskName1, and then displaying the information saved in AskName1, I have found that it save the number of characters that the user input and not the actual string. So what I need to figure out is how to save the string that the user input into a variable instead of the number of characters the user input.
INCLUDE Irvine32.inc
.data
AskName BYTE "Please enter your name " ,0dh,0ah,0
Birth BYTE "Please enter your birth year",0dh,0ah,0
Job BYTE "Pleas enter the location at which you work",0dh,0ah,0
AskName1 DWORD ?
Birth1 DWORD ?
Job1 DWORD ?
.code
main PROC
call Clrscr
mov edx, OFFSET Birth
call writestring
call ReadInt
mov Birth1, eax
mov edx, OFFSET Birth1
call writeint
call crlf
mov edx, OFFSET AskName
call WriteString
call ReadString
; AT THIS POINT I WANT TO TAKE USER STRING INPUT AND SAVE THE STRING INTO THE VARIABLE "ASKNAME1"
main ENDP
END main
Irvine's
ReadString
needs two arguments inEDX
andECX
. It fills the memory pointed byEDX
and returns in the size of the input. Since the string in[EDX]
will be zero-terminated, you have to reserve space for the string and the terminating null. WithAskName1 DWORD ?
you reserved only 4 bytes - that's surely not enough.As I saw debugging, ECX should be the size of the string with null (not as mentioned: "max number of non-null chars" = size-1).
Do it so: