Given the following definitions: .DATA wval LABEL WORD barray BYTE 10h, 20h, 30h
ID: 1716189 • Letter: G
Question
Given the following definitions:
.DATA
wval LABEL WORD
barray BYTE 10h, 20h, 30h, 6 DUP (0Ah)
ALIGN 4
warray WORD 5 DUP (1000h)
pressKey EQU <"Press any key to continue ...", 0>
darray DWORD 5 DUP (56789ABh), 7 DUP (12345678h)
dval LABEL DWORD
prompt BYTE pressKey
What will be the value of EAX, AX, and AL after executing each of the following instructions? Assume that the address of barray is 404000h.
a. mov eax, TYPE warray
b. mov eax, LENGTHOF barray
c. mov eax, SIZEOF darray
d. mov eax, OFFSET warray
e. mov eax, OFFSET darray
f. mov eax, OFFSET prompt
g. mov eax, DWORD PTR barray
h. mov al, BYTE PTR darray
i. mov ax, wval
j. mov eax, dval
Explanation / Answer
a) The TYPE operator returns the size, in bytes, of a single element of a data declaration.
DATA: warray WORD 5 DUP (1000h)
WORD SWORD; 16-bit unsigned & signed integer=2Byte
a. mov eax, TYPE warray; eax=2
b) The LENGTHOF operator counts the number of elements in a single data declaration.
DATA: barray BYTE 10h, 20h, 30h, 6 DUP (0Ah)
b. mov eax, LENGTHOF barray; eax=9
c) The SIZEOF operator returns a value that is equivalent to multiplying LENGTHOF by TYPE.
DATA: darray DWORD 5 DUP (56789ABh), 7 DUP (12345678h)-> length of 12
DWORD SDWORD 32-bit unsigned & signed integer->type of 4 bytes
c. mov eax, SIZEOF darray; eax=48
d, e, f) OFFSET returns the distance in bytes, of a label from the beginning of its enclosing segment
ALIGN bound aligns a variable on a byte, word, doubleword or paragraph boundary for doubleword,
or paragraph boundary for efficiency. (bound can be 1, 2, 4, or 16.)
DATA:
wval LABEL WORD
barray BYTE 10h, 20h, 30h, 6 DUP (0Ah) ; 404000h.
ALIGN 4
warray WORD 5 DUP (1000h) ; 404004h.
pressKey EQU <"Press any key to continue ...", 0> ; 404008h.
darray DWORD 5 DUP (56789ABh), 7 DUP (12345678h) ; 40400Ch.
dval LABEL DWORD ; LABEL does not allocate any storage of its own; it is just an alias
prompt BYTE pressKey ; 40400Fh.
d. mov eax, OFFSET warray; 404004h.
e. mov eax, OFFSET darray ; 40400Ch.
f. mov eax, OFFSET prompt; 40400Fh.
g,h) PTR Overrides the default type of a label (variable). Provides the flexibility to access part of a variable. or used to combine elements of smaller data type
g. mov eax, DWORD PTR barray; eax =0A0A0A0Ah
h. mov al, BYTE PTR darray; al=78h
i,j)
i. mov ax, wval; ax=0A0Ah
j. mov eax, dval; eax=" ..."
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.