How to decode machine instructions for assembly in LEGv8?

It’s hard for me to understand how the instruction of a LEGv8 machine is decoded. Suppose the following binary code:

1000 1011 0000 1111 0000 0000 0001 0011

I have the following diagram that should help me decode:

LEGv8 Encoding / Decoding Graphics

The first 11 bits of 10001011000 correspond to decimal 1112 , and according to the diagram, this is an ADD command . Therefore, I know how to define this part of the instruction (if there is no better approach, perhaps this will not work for operation codes that are not 11 bits?). At this point, I am confused about how to proceed.

I know that ADD has the format of the R-format command , so the bit is laid out as follows:

: 11
Rm: 5
shamt: 6
Rn: 5
Rd: 5

, ...

opcode = 1000 1011 000 0 1111 0000 0000 0001 0011 = 10001011000
11 .

Rm = 1000 1011 000 0 1111 0000 0000 0001 0011 = 01111
5 11 .

shamt = 1000 1011 0000 1111 0000 00 00 0001 0011 = 000000
6 5 Rm.

Rn = 1000 1011 0000 1111 0000 00 00 000 1 0011 = 00000
5 6 shamt.

Rd = 1000 1011 0000 1111 0000 0000 000 1 0011= 10011
5 (5 5 Rn).

Rm, Rn Rd :

Rm = 15 = X15
Rn = 0 = X0
Rd = 19 = X19

ADD X19, X0, X15

, , ADD X16, X15, X5. ?

+4
1

, gnu binutils:

$ echo .int 0b10001011000011110000000000010011 > test.s
$ as test.s && objdump -d a.out

a.out:     file format elf64-littleaarch64
Disassembly of section .text:

0000000000000000 <.text>:
   0:   8b0f0013    add x19, x0, x15

, ;)

+3

Source: https://habr.com/ru/post/1657639/


All Articles