Use this information and the code at the right to answer
questions #20 - 21.
Given the following declarations for an IA-32 processor:
MAXSIZE = 10
.data
string BYTE MAXSIZE DUP (?)
val DWORD ?
The ReadString procedure accepts the address of the
memory destination in edx, and the maximum number of
characters to read in ecx. ReadString stores the user's input
characters in the memory destination, and the actual number
of characters in eax. The ASCII code for character '0' is 48.
Suppose that the user enters the string "5738" (without the
quotes) when the ReadString procedure is called.
20. (3 pts) What is displayed?
21. What is stored in memory at val?
A. 0x5 0x7 0x3 0x8
B. 0x8 0x3 0x7 0x5
C. 0x6A 0x16 0x0 0x0
D. 0x0 0x0 0x16 0x6A
E. none of the above
; code fragment V
mov edx, OFFSET string
mov ecx, MAXSIZE
dec ecx
call ReadString
mov ecx, eax ;number of
; digits entered
mov val,0 ;initialize val
mov esi, OFFSET string
cld
top:
mov eax,0
lodsb
sub eax, 48
mov ebx, eax
mov eax, val
mov edx, 10
mul edx
add eax, ebx
mov val, eax
loop top
done:
mov eax, val
call WriteDec