Question

In: Computer Science

1.The machine code of LEGv8 instruction SUB X15,X16,X17 in hexadecimal is? 2.The LEGv8 assembly instruction assembled...

1.The machine code of LEGv8 instruction SUB X15,X16,X17 in hexadecimal is?

2.The LEGv8 assembly instruction assembled into the hexadecimal machine code D1001695 is?

3.What does the LEGv8 instruction below do?

LSL X12,X12,#8

Solutions

Expert Solution

1.

Above instruction is equivalent to :

X15 <- X16 - X17

SUB is a R-type instruction, with the following fields :

  • First 11 bits = Opcode = 1100 1011 000
  • Next 5 bits = Second source register = X17 = 1 0001
  • Next 6 bits = Shift amount = 0 = 0000 00
  • Next 5 bits = First source register = X16 = 10 000
  • Next 5 bits = Destination Register = X15 = 0 1111

Writing all bits together, we get

= 1100 1011 000 1 0001 0000 00 10 000 0 1111

= 1100 1011 0001 0001 0000 0010 0000 1111

= 0xCB11020F

2.

Expanding the intruction 0xD1001695, we get

1101 0001 0000 0000 0001 0110 1001 0101

Here, the first 10 bits are

1101 0001 00

which is 10-bit opcode for SUBI, which is an I-type instruction.

Thus, the next fields are :

  • Next 12 bits = Immediate operand = 00 0000 0001 01 = 5
  • Next 5 bits = Source Register = 10 100 = X20
  • Next 5 bits = Destination Register = 1 0101 = X21

Thus, the operation is

X21 <- X20 - 5

and the assembly instruction is

SUBI X21, X20, #5

3.

LSL stands for Logical Shift Left, where the vacated (lowermost) bits are filled with 0s.

Thus,

LSL X12,X12,#8

=> X12 <- X12 << 8

where,

  • X12 is the register that is shifted left 8 times, filling the lowermost vacated 8 positions with 0s.
  • X12 is also the destination register, and thus the final result gets stored in X12 itself.

Related Solutions

Represent following LEGv8 machine code into assembly instruction. 0x784302CD
Represent following LEGv8 machine code into assembly instruction. 0x784302CD
Translate these two LEGv8 assembly instructions to 32-bit binary machine code. Give your answer in hexadecimal....
Translate these two LEGv8 assembly instructions to 32-bit binary machine code. Give your answer in hexadecimal. CBZ X19, exit ADD X10, X19, X20 exit:
Represent following LEGv8 assembly instruction into machine code (use hexa decimal format). STUR X1, [X1, #8]
Represent following LEGv8 assembly instruction into machine code (use hexa decimal format). STUR X1, [X1, #8]
True and False 1. The instruction register stores machine code for the instruction being executed. 2....
True and False 1. The instruction register stores machine code for the instruction being executed. 2. Before a digital computer may execute an instruction, the instruction code must be fetched from memory. 3. A pointer is a binary code for data in the arithmetic logic unit. 4. Von Neumann computer architecture stores data and instruction codes in the same memory. 5. Complex instruction set computers have instructions with greater speed than those in reduced instruction set computers.
Suppose the address of the first instruction is 5F370654 in hexadecimal in the following code. Show...
Suppose the address of the first instruction is 5F370654 in hexadecimal in the following code. Show in decimal the immediate value (i.e. offset) in the beq and bne instruction, and in hexadecimal (of 7 digits) the psedudo address in the j instruction. Separate the numbers by comma. label1: beq $t1, $t2, label3 (17 instructions here) label2: bne $t3, $t4, label1 (46 instructions here) label3: j label2
The following 32-bit binary word written in hexadecimal format represents a single RISC-V assembly instruction. What...
The following 32-bit binary word written in hexadecimal format represents a single RISC-V assembly instruction. What is the RISC-V instruction format and specific assembly language instruction? 0xfe810113
2. Given the Instruction sets for Machine-1, Machine-2 and Machine-3, write programs to calculate: P= ((B×C)...
2. Given the Instruction sets for Machine-1, Machine-2 and Machine-3, write programs to calculate: P= ((B×C) + (A +D)) / (E - C × D) and comment on relative efficiency. Machine-1: One address instructions Machine-2: Two address instructions Machine-3: Three address instructions STORE X ; X<― [AC] LOAD X ; AC<― [X] MPY X ; AC<― [AC x X] DIV X ; AC<― [AC / X] ADD X ; AC<― [AC + X] SUB X ; AC<― [AC -X] X...
Write assembly code for the following machine code. Assume that the segment is placed starting at...
Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels. 0010 1010 0000 1000 0000 0000 0000 1010 0001 0001 0000 0000 0000 0000 0000 0010 0000 0010 0001 0001 1000 0000 0010 0000 0000 1000 0000 0000 0100 1110 0010 0101 0000 0010 0001 0010 1000 0000 0010 0000
a. Write machine code for the following assembly code. Assume that the segment is placed starting...
a. Write machine code for the following assembly code. Assume that the segment is placed starting at location 80000. Use decimal numbers to represent each instruction. loop:         beq $s3, $s1, endwhile                  add $t0, $s3, $s4                  lw $t1, 0($t0)                  add $s0, $s0, $t1                  addi $s3, $s3, 4                  j loop endwhile: b. Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual...
Question: In the following MIPS assembly code, translate all the instructions to their corresponding machine code...
Question: In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x2fff0004. Loop: lw $t0, 4($s0)             addi $t1, $t1, -15             sll $t1, $t1, 2             beq $t1, $s1, Exit             addi $s0, $s0, 4             j Loop Exit: …
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT