Numerical value in decimal of the 32-bit word stored at address 1000H

assembly

I'm a little confused how to tackle these three questions.

Assuming two's complement arithmetic and operand alignment, give the numerical value in decimal of the 32-bit word stored at address 1000H and of each 16-bit half-word stored at addresses 1000H and 1002H under (1) Little Endian and (2) Big Endia storing conventions.

1000H:  23H
1001H:  F7H
1002H:  32H
1003H:  AB

Questions:

  1. For the first question, we have 23H at 1000H. Is this a hex word? What is the H for? 23 would be 35 in decimal

  2. But two's complement would assume binary? 35 in binary would be 11011101. I also understand big vs little endian, but I'm missing something here.

Best Answer

I'm going on the assumption that the "H" at the end of each number indicates hexadecimal representation. I'm going to use subscripts like \$23_{16}\$, \$35_{10}\$, and \$00100011_{2}\$ to represent hexadecimal, decimal, and binary, respectively.

In computer memory, data is addressed on byte (8-bit) boundaries. When a data type larger than 8-bits is stored in memory, it will span across as many 8-bit memory locations as necessary to accommodate its size.

The first part of the question asks what the decimal equivalent of the 32-bit integer that is stored at address \$1000_{16}\$. You can translate that to "What is the decimal equivalent of the 32-bit integer that begins at address \$1000_{16}\$?" Since it's 32-bit, you know it will span over the memory space of four bytes. Therefore, the contiguous memory representation of the 32-bit integer is \$23F732AB_{16}\$.

In Big Endian, we don't have to change the order of the bytes to represent the actual value. But since the numbers are stored as signed integers (two's complement), we do need to check the first bit to see if the number is negative. The MSB is \$23_{16}\$, which in binary is \${\color{red}0}0100011_{2}\$. The sign bit is low, so the value is positive and no two's complement conversion is necessary:
$$23F732AB_{16} = 603402923_{10}$$

The Little Endian representation of the integer is \$AB32F723_{16}\$. In this case, the MSB is \$AB_{16}\$, which is \${\color{red}1}0101011_{2}\$. The sign bit is set, so this is a negative number. To represent it in decimal, we must first "un-two's complement" it by subtracting one and flipping all of the bits. This results in a hexadecimal representation of \$54CD08DD_{16}\$. Translating to decimal and adding the negative sign gives you:
$$AB32F723_{16}=-1422723293_{10}$$

Remember that numerical values can be freely represented in whatever base you want. You can take the two's complement of a hexadecimal number just as you can a binary number. The reason you are probably a little confused about that is you were taught a method to perform a two's complement using only binary numbers. But that was just for convenience. It is simply easiest to perform a two's compliment operation on the binary representation of a number.

The 16-bit integers will work out in a similar way as the 32-bit. Each one will span two 8-bit memory locations, so you will have \$23F7_{16}\$ and \$32AB_{16}\$ as two separate 16-bit values. I will leave the rest of the work for you to work out on your own.