0

I'm just starting to learn assembly language, and we are working with hex addresses. Below is a question of ours. I'm not sure how it adds up though. I know the answer is 0x202C, but how did we get there? Can you help explain the processes step by step, in the most basic way possible to help me understand? Thank you!!


The following data segment starts at memory address 0x2000 (hexadecimal)

.data
printString BYTE "Assembly is fun",0
moreBytes BYTE 24 DUP(0)
dateIssued DWORD ?
dueDate DWORD ?

What is the hexadecimal address of dueDate?

  • Take a look at Anne-s answer at https://stackoverflow.com/questions/11277652/what-is-the-meaning-of-align-an-the-start-of-a-section It is VERY complete – donPablo Apr 08 '20 at 19:16

1 Answers1

0

You have three data definitions to add together:

printString is an ASCII text followed by a zero byte. The string part is 15 bytes long, and with the terminal zero byte that makes 16. So the offset of the next data item is 0x2010 (16 decimal is 0x10 hex). printString starts at 0x2000, and the next one starts after the last byte of printString, so you have to add its length to its offset to get to the next offset.

moreBytes is 24 bytes long, because that's how DUP works. BYTE x DUP (y) means "X bytes of value Y". So the offset of the next data item is 0x2028, as 24 decimal is 0x18 hex.

dateIssued is 4 bytes long, because that's the definition of a DWORD. So the next one is at 0x0x2C, since 8+4=12, and that's 0xC in hex notation.

Alternatively, you could add the three lenghts together, getting 44. 44 in hex would be 0x2C.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281