The MARS Data-Segment Window
You need to be able to find words in this window
Here's a picture of a data-segment window showing values in decimal:
- The window displays a table with 9 columns
- The first row consists of column headers (ignore the word "Value"; pay attention to the number in parentheses)
- The leftmost column (headed "Address") consists of row headers,
which give the address of the first data column in that row
- The actual data are displayed in the body of the table, i.e. everything else (yellow background)
- Each cell holds 1 word i.e. 4 bytes, and every word address is a multiple of 4
- That is why the number in parentheses at the top increases by 4 each time you move one cell to the right
- You can figure the address of any cell in the body of the table by adding the numbers
in its row header and its column header
- So the green background is at address 0x10010048, and the pink background is at 0x10010054
Here's a window showing values in hexadecimal:
- The word value at location 0x10010048 is 0x1234568A
- The word value at location 0x10010054 is 0x1234568D
You need to be able to find bytes in this window
- To find a byte, you have to know which word to look in
- The word's address will be the largest multiple of 4 that is not
larger than the byte's address; i.e. round the byte's address down to a multiple of 4
- Byte 0x10010056 is therefore in word 0x10010054
- Once you've found the right word, you need to decide which of the word's 4 bytes is the correct one
- Here's the word divided into its bytes; each byte is 2 hexadecimal digits
- Since this is a little-endian machine, the bytes are numbered from right to left
- Above each byte (white background) is the byte's offset in its word
- To get a byte's address, you add its offset to the address of its word
- 0x10010056 = 0x10010054 + 2, so our byte's offset is 2
- So byte 0x10010056 has a value of 0x34