** 1. ReadString Implement your own version of the ReadString procedure, using s
ID: 3693172 • Letter: #
Question
** 1. ReadString
Implement your own version of the ReadString procedure, using stack parameters. Pass it a pointer to a string and an integer, indicating the maximum number of characters to be entered. Return a count (in EAX) of the number of characters actually entered. The procedure must input a string from the console and insert a null byte at the end of the string (in the position occupied by 0Dh). See Section 11.1.4 for details on the Win32 ReadConsole function. Write a short program that tests your procedure.
Question from Assembly Language for x86 Processors (7th ed.) pg. 509
Explanation / Answer
The ReadString procedure reads a string from the keyboard, stopping whenever the user presses
the enter key. Pass the offset of a buffer in EDX and set ECX to the max number of
characters tthat he user can enter, plus 1 (to save space for the terminating the null bytes). The
procedure returns the count of the number of characters typed by the user,stored in EAX.
The sample program has been mentioned below:-
.data
buffer BYTE 21 DUP(0) ; input buffer
byteCount DWORD ? ; this holds the counter value
.code
mov edx,OFFSET buffer ; this point to the buffer
mov ecx,SIZEOF buffer ; this specifies maximum characters
call ReadString ; input the string from keyboard
mov byteCount,eax ; return the number of characters
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.