In: Computer Science
Represent following LEGv8 machine code into assembly
instruction.
0x784302CD
We are given the LEGv8 machine code in hexadecimal notation
which is:- 0x784302CD.
We will now convert the above hexadecimal code to binary to check
whether what is the opcode and what are the register numbers and
offset.
Binary Representation:- 0111 1000 0100 0011 0000 0010 1100 1101, so we have out 32 bits instruction.
I have povided the chart for convenience.
So, from the above chart is we keep on matching whether which operation code is matching our machine code, we will find that LDURH instruction has the 11 bits identical to the first 11 bits of our machine code. So now we have the instruction in our hand which is LDURH, which means load half word unscaled.
Instruction format - LDURH Rt , [
Rn, offset ] , where Rt is the destination or
load register number, and Rn is the base register, and
offset will be added to the Rn to load the contents from
the resultant address.
LDURH - Load (Unscaled) Halfword: loads a halfword from memory
addressed by Rn+
offest.
Now, our task is only to find the register numbers and the offset number. For that we will refer the below format to find the decimal value corresponding to Rn and Rt and also offset.
On comparing our machine code with the above format, we get,
Rn = 10110 = 22
Rt = 01101 = 13
Offset/address = 000110000 = 48
Now, we have everything to write the instruction corresponding to machine code:-
Assembly Instruction = LDURH R13, [ R22, #48 ]
where R13 is a temporary register and R22 is a saved register according to LEGv8 register specifications.