190k views
5 votes
Given the following declarations, assume that the memory address of balance is 44h. What is the hexadecimal address of the last element of history?

HISTLIMIT = 100

.data
balance DWORD 0
account WORD ?
history WORD HISTLIMIT DUP(?)
isValid BYTE 0

User Nardo
by
7.9k points

2 Answers

2 votes

Final answer:

To find the hexadecimal address of the last element of history, calculate the offset based on the size of the array and add it to the starting address of balance.

Step-by-step explanation:

The memory address of balance is given as 44h. The size of each element in history is 2 bytes since it is declared as a WORD. To find the address of the last element of history, we need to calculate the offset based on the size of the array and add it to the starting address.

The size of history can be calculated as HISTLIMIT * 2 since each element is 2 bytes. The offset of the last element is (HISTLIMIT - 1) * 2. Adding this offset to the starting address of balance (44h) gives us the hexadecimal address of the last element of history.

Address of last element = 44h + (HISTLIMIT - 1) * 2

User Javing
by
8.8k points
3 votes

Based on the above, the hexadecimal address of the last element of history is 0110h

To know the hexadecimal address of the last element of the "history" array, we need to consider the size of each element in the array.

Since the "history" array is declared as WORD (which represents a 2-byte value), we can calculate the size of the array and then add it to the address of the first element to find the address of the last element.

Given that the array size is HISTLIMIT (100) and each element is a WORD (2 bytes), the total size of the array in bytes is:

Array size=HISTLIMIT×size of each element

Array size =100×2=200 bytes

User Rengasamy
by
8.1k points