Expressed in hexadecimal, what are the values of the registers $1, $2, $3, and $4 after thefollowing lines of WRAMP assembly code have been executed?(2 marks)main:lw $1, val($0)lw $2, val($0)lw $3, val($0)lw $4, val($0)subui $1, $1, 1addi $2, $2, 1srli $3, $3, 1srai $4, $4, 1syscall.dataval:.word 0xFFFFFFFF$1 = ____0xFFFFFFFE________________$2 = ____0x00000000________________$3 = ____0x7FFFFFFF________________$4 = ____0xFFFFFFFF________________
Question
Expressed in hexadecimal, what are the values of the registers 2, 4 after thefollowing lines of WRAMP assembly code have been executed?(2 marks)main:lw 0)lw 0)lw 0)lw 0)subui 1, 1addi 2, 1srli 3, 1srai 4, 1syscall.dataval:.word 0xFFFFFFFF1 = ____0xFFFFFFFE________________2 = 0x00000000____________3 = ____0x7FFFFFFF________________4 = 0xFFFFFFFF____________
Solution
The WRAMP assembly code provided loads the value 0xFFFFFFFF into registers 2, 4. Then, it performs different operations on each register:
-
For register $1, it subtracts 1 from the value. In hexadecimal, 0xFFFFFFFF - 1 = 0xFFFFFFFE.
-
For register $2, it adds 1 to the value. However, since 0xFFFFFFFF is the maximum value for a 32-bit number, adding 1 will cause an overflow and the value will wrap around to 0.
-
For register $3, it performs a logical right shift by 1. This means that every bit in the number is shifted one place to the right, and the leftmost bit is filled with a 0. So, 0xFFFFFFFF >> 1 = 0x7FFFFFFF.
-
For register $4, it performs an arithmetic right shift by 1. This is similar to the logical right shift, but the leftmost bit is filled with the value of the original leftmost bit (to preserve the sign of the number). Since 0xFFFFFFFF is a negative number in two's complement representation, the leftmost bit is 1, so 0xFFFFFFFF >> 1 = 0xFFFFFFFF.
So, the final values of the registers are:
2 = 0x00000000 4 = 0xFFFFFFFF
Similar Questions
For the following excerpt of WRAMP assembly code, what are the final values stored in $2and $3?(2 marks)addi $2, $0, 0x42addi $3, $0, 0x42andi $2, $2, 0xF0andi $2, $2, 0xF0xori $3, $3, 0xF0xori $3, $3, 0xF0
Show the contents in hexadecimal of registers PC, AR, DR, IR, and SC of thebasic computer when an ISZ indirect instruction is fetched from memory andexecuted. The initial content of PC is 7FF. The content of memory at address7FF is EA9F. The content of memory at address A9F is 0C35. The content ofmemory at address C35 is FFFF. Give the answer in a table with five columns,one for each register and a row for each timing signal. Show the contents of theregisters after the positive transition of each clock pulse.170 CHAPTER FIVE Basic Computer Organization and Design
Assume the following shows the initial contents of the specified registers:REGISTER CONTENTSR1 0000 0000 0000 1001R2 0000 0000 0000 0101R3 0000 0000 0000 0010Also assume the following LC-3 machine instructions are loaded into memory at addresses shown:0x4000 1001 011 010 1 111110x4001 0001 011 011 1 000010x4002 0001 010 001 0 00 0110x4003 0000 001 001100000After the code above completes execution, what is the final value in each register below?(Enter your 16-bit answer in hex like the following example: 0x2A3F)A.) R1? B.) R2? C.) R3? D.) PC?
Given that general purpose register $1 has the value 10 in it, and $2 has the value 6, whichone of the following lines results in the value 26 being stored in $2?a. addi $1, $2, 10b. addi $1, $2, 0x10c. addi $2, $1, 10d. addi $2, $1, 0x10
The current contents of a general purpose register (X) are: X = 10111010 The currents of X represent an unsigned binary integer. Convert the value X into hexadecimal
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.