In: Computer Science
If A is a 32-bit address, typically an instruction sequence such as: lui x19, A_upper addi x19, x19, A_lower can be used to load the word at A into a register (in this case x19).
a) How many bits of A are in A_upper?
b) If the MSB of A_upper is 1, what would be the value of the leftmost 32-bits of register x19. Provide your answer in decimal.
c) After the lui instruction, the rightmost 12-bits of x19 would be filled with all 1ās. True or False?
d) If the bit 11 (12th bit) of A is 1, how should A_upper be changed? Choose (X) one of the following (A_upper = A_upper + 1) / (A_upper = A_upper - 1) /(None)
e) What other instruction can be used instead of addi?
Greetings!!
Generally lui and addi instructions are used as a combination of instructions which can be used to load a 32 immediate value into a register and are used instead of the instruction li. For example, if register x19 needs to be filled with immediate value 0x81223344, the instruction li x19,0x81223344 is used. Otherwise lui and addi pair of instructions can be used as follows:
lui x19,0xFFF81223 #which will load the upper register with 0x81223000 and lower 12 bits with 000
8 | 1 | 2 | 2 | 3 | 0 | 0 | 0 |
addi x19,x19,344 #which appends the value 334 so that the register contains 0x81223344 at the end
8 | 1 | 2 | 2 | 3 | 3 | 4 | 4 |
a) A_upper is the Most significant 20 bits of A.
ie 0x81223344[Please note that each digit consists of 4 bit binary and hence 20 bits ie 81223 is 1000 0001 0010 0010 0011]
b) Here A is 0x81223344 and has a 1 at its MSB,the register will contain 0x81223000 after the instruction lui which represents 2166501376 in decimal
c) False. The rightmost 12 bits are filled with 0s after executing the lui instruction.
d) None
e) Instead of addi instruction ori instruction can be used.
Hope this helps