5. When an 8-bit or 16-bit data is loaded from the data memory into a 32-bit reg
ID: 3738894 • Letter: 5
Question
5. When an 8-bit or 16-bit data is loaded from the data memory into a 32-bit register, LDRSB (load register with signed byte) LDRSH loads a signed byte and LDRB LDRSH (load register with signed halfword) and LDRH (load register with whether sign extension or zero extension is performed depends on the data's sign. (load register with byte) for an unsigned byte. halfword) read load a 16-bit signed and unsigned number from memory into a register, respectively. What is the value in register ri in the following instructions if re - ex20008000? Assume the system is little endian. (1) LDRSB r1, [re] (2) LDRSH r1, [re] (3) LDRB r1, [re] (4) LDRH r1, [re Memory address Data 0x20008002 0x20008001 0x20008000 0x20007FFF 0x20007FFE 0xA1 0xB2 0xC3 0xD4 0xE5Explanation / Answer
1. LDRSB R1,[R0]
R1= 0x-43
Explanation: LDRSB load a signed byte from the address field specified in the operand here the operand is [R0] which contains 0xC3, for a signed byte the MSB acts as sign bit if it is 1 then the number is negative, here the number is 1100 0011 which equals to -43 in hexa decimal format.
2. LDRSH R1,[R0]
R1 = 0x-42C3
Expalnation: LDRSH loads a signed halfword address field specified in the operand here the operand is [R0](LSB) which contains 0xC3,and [R0+1](MSB) contains B2 for a signed byte the MSB acts as sign bit if it is 1 then the number is negative, here the number is 1100 0010 1100 0011 which equals to -42C3 in hexa decimal format.
3. LDRB R1,[R0]
R1 = 0xC3
Explanation: LDRB loads a unsigned 8 bit value to the R1 from memory location specified in the R0. Here the R0 denoted the address location which has the value C3 in hexa decimal format.
4. LDRH R1,[R0]
R1 = 0xB2C3
Expalnation: LDRH loads a unsigned 16 bit value to R1. Since the system is little endian LSB is stored in the minimum address location, Therefore LSB = C3 and MSB is B2.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.