In: Computer Science
Represent following LEGv8 assembly instruction into machine code
(use hexa decimal format).
STUR X1, [X1, #8]
Solution :
LEGv8 assembly instruction STUR X1,[X1,#8] have following format,
| 
 Opcode  | 
 address  | 
 Op2  | 
 Rn  | 
 Rt  | 
| 
 11 bits  | 
 9 bits  | 
 2 bits  | 
 5 bits  | 
 5 bits  | 
Where, Opcode = Operation Code, Address = constant offset from content of base register, Op2 = any other operand, Rn = Base register, Rt = Destination or source register
So for translation we need to write instruction in above format using equivalent binary form and then covert into hexadecimal format, Opcode for STUR is 1984
| 
 Opcode(11 bits)  | 
 Address(9 bits)  | 
 Op2(2 bits)  | 
 Rn(5 bits)  | 
 Rt(5 bits)  | 
| 
 1984  | 
 8  | 
 0  | 
 1  | 
 1  | 
| 
 Equivalent binary form of each field in required bits  | 
||||
| 
 11111000000  | 
 000001000  | 
 00  | 
 00001  | 
 0001  | 
Now we are going to make group of 4 bits from above resulted binary string, 1111 1000 0000 0000 1000 0000 0010 0001two = F800802116 Therefore instruction STUR X1,[X1,#8] is converted to (F8008021)16 machine code.