0

I'm working on an assignment that's asking me to convert some lines of machine code to assembly. Here's an example

0x0000000080001294 : EB01001F

According to some people online, this translates to CMP X0, X1 in assembly.

From what I understand, you're supposed to take the "EB01001F", convert it to binary, and use an opcode table to figure out the rest. When putting it into binary, here's what I get:

11101011000000010000000000011111

The problem is the opcode table in the textbook I have has nothing that matches up with any of this so I'm lost, can someone help me out?

3
  • 3
    Which CPU is this for? Those numbers mean different things on different hardware. Commented Feb 23, 2021 at 0:32
  • Could be an endianness problem. Try 1F0001EB instead. I assume this is aarch64. Commented Feb 23, 2021 at 0:40
  • looks to be aarch64 and it is right if you assemble that cmp x0,x1 you get 0xEB01001F. use the arm documentation not a text book it walks you through all the bits in the instruction and/or you can go to the answer and see the bits match Commented Feb 23, 2021 at 2:11

1 Answer 1

2

We don't know what table your textbook has. Maybe it has the endianness reversed. Official arm documentation however uses your bit order. You can find the CMP (shifted register) instruction which looks like:

1110 1011 ss0m mmmm iiii iinn nnn1 1111 (structure from manual)
1110 1011 0000 0001 0000 0000 0001 1111 (your bits)

In particular you can see i=0 (the shift amount), m=1 (second operand) and n=0 (first operand) hence it is really CMP X0, X1 as expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.