Reputation: 109
I'm learning assembly language and I'm trying to understand how to convert between assembly-language to machine-language. I'm trying to read up sources and such, even asking my professors, but none has been helpful.This is the following code that I'm working on:
MOV R10, #63488
LSL R9, R6, #7
STR R4, [R11, R8]
ASR R6, R7, R3
I found an ARM to HEX converter website and this is the conversion:
3EABA0E3
8693A0E1
08408BE7
5763A0E1
Can someone help explain to me how this works? Thank you so much!
Upvotes: 2
Views: 6884
Reputation: 71506
Colin's answer is basically THE answer, just adding some more info. The tool you need is called an assembler, not an arm to hex converter. You can then use a disassembler to see it, for example with your program using gnu tools:
arm-none-eabi-as so.s -o so.o
arm-none-eabi-objdump -D so.o
produces
00000000 <.text>:
0: e3a0ab3e mov r10, #63488 ; 0xf800
4: e1a09386 lsl r9, r6, #7
8: e78b4008 str r4, [r11, r8]
c: e1a06357 asr r6, r7, r3
And how the processor interprets the machine code is well documented in the ARM ARM, probably start with the ARMv5 one, which the older less complicated one. ARMv6, ARMv7 have a lot more operating system and protection features, mostly the same instruction set, although more thumb instructions, then ARMv8 is a hybrid with aarch32 the older ARMv4 to ARMv7 instruction set then a completely new aarch64 instruction set in the same core. So google arm architectural reference manual, some folks have illegally left them laying around or go to infocenter.arm.com to get the real ones.
Upvotes: 3
Reputation: 3524
What you need is the ARM ARM (architecture reference manual) which is available freely from Arm's website, though you may need to register. It contains the encoding for all available instructions.
Upvotes: 4