mov edx,offset Prompt1
call WriteString
mov ecx,32
mov edx,offset String1
call ReadString
Now, how do I go about accessing String1? How do I move it into a register so I can do shifting operations on it?
For example,
mov eax, edx
shr eax, 1
The problem that I'm having is that I can't figure out how to access String1. It doesn't seem to be going into the eax register, but if I call WriteString it will appear, so I believe it is in EDX.
The data is read into memory starting at the address of
String1. There is a null byte (0) after the last input character.So if after your
call ReadString, you writemov edx,offset String1, then EDX is pointing to the first character of the string.You can then process the string. For example, to add 1 to each character:
So if the input was "0123abc", that would change the string to "1234bdc".
(for the nitpickers: Yes, I know this could be optimized. In particular the
cmp al,0. But it's better for beginners to think of comparing ... we can work on optimizations after they have a firm grasp of working at the processor level.)