3. The first two bytes of a 2M 16 main memory have the following hex values:
Byte 0 is FE
Byte 1 is 01
If these bytes hold a 16-bit two’s complement integer, what is its actual decimal value if:
a) Memory is big endian?
b) Memory is little endian?
From the given information Byte 0=FE and Byte 1= 01, which holds two’s compliment value
a) when we represent the given information in big endian format :
Byte 0 |
Byte 1 |
01 |
FE |
When we convert (01 FE) into binary:(0000 0001 1111 1110)
To get the actual decimal value from the given two’s compliment binary value , we have to perform two’s compliment again for the binary value (since two’s compliment is a self compliment code).
Two’s compliment = one’s compliment +1
One’s compliment (0000 0001 1111 1110) = 1111 1110 0000 0001
two’s compliment = one’s compliment+1 = +1
= 1111 1110 0000 0010
The decimal equivalent (1111 1110 0000 0010)2 = (65026)10
b) when we represent the given information in Little endian format :
Byte 1 |
Byte 0 |
FE |
01 |
When we convert (FE 01) into binary:(1111 1110 0000 0001)
To get the actual decimal value from the given two’s compliment binary value , we have to perform two’s compliment again for the binary value (since two’s compliment is a self compliment code).
Two’s compliment = one’s compliment +1
One’s compliment (1111 1110 0000 0001) = 0000 0001 1111 1110
two’s compliment = one’s compliment+1 = +1
= 0000 0001 1111 1111
The decimal equivalent (0000 0001 1111 1111)2 = (511)10