Need Help with Computer architecture Assembly practice midte
Need Help with Computer architecture Assembly practice midtem
1. Given the following partial data segment, which starts at address 0x021A :
.data
list DWORD 1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683
x DWORD LENGTHOF list
y DWORD SIZEOF list
Show addresses in 4-digit hexadecimal, and contents in decimal.
a) x contains
b) y contains
c) The address of x is____________ (hex)
d) Given this code fragment:
mov esi, OFFSET list
mov eax, [esi+3*TYPE list]
eax contains :__________
e) Given this code fragment:
mov esi, OFFSET list
mov ebx, y
sub ebx, TYPE y
add esi, ebx [esi] contains :_____________
f) Given this code fragment:
mov esi, OFFSET list
mov ebx, y
sub ebx, TYPE y
add esi, ebx
mov al, BYTE PTR [esi+2]
The AL register contains : ___________________________
Solution
1)
 a) x contains 10 since total list elements are 10
 b) y contains 10 since size and length gives same result.
 c) The address of x is 0x031A (already given in question itself).
 ----------------------------------------------------------------------------------
  d)
 So esi is 0x031A
 list start address 0x021A
 TYPE list is integer, where 4 bytes.
 So 3*4 = 12 and 31+12 ==> 43
 eax has 0x0043A
 ----------------------------------------------------------------------------------
  e)
 offset of list -> esi -> 0x031A
 y contains 10
 Finally esi contains 0x031A[10] + 0x031A ==> 31+31 => 0x062A
 -----------------------------------------------------------------------------------------------------
  f)
 mov esi, OFFSET list ---> 0x031A
 mov ebx, y -----> 10
 sub ebx, TYPE y ---> 4 (int)
 add esi, ebx ----> 0x035A
 mov al, BYTE PTR [esi+2] ----> 0x037A
 The AL register contains : ----> 0x037A


