Post date: Dec 09, 2017 2:41:37 AM
Surf here:
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
On Windows, click the first download link for this file (link is current as of 9 dec 2017):
File: gcc-arm-none-eabi-6-2017-q2-update-win32.exe (82.56 MB)
Once downloaded, double-click the installer.
The tools will be installed here. You may want to update you enviroment variables...
C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q2-update\bin\
To test it, make a short C program.
int main()
{
int a = 0x55;
int b;
b = a ^ 0xff00;
return 0;
}
Compile it (my code is at ~\cortex directory):
C:\Users\Mun3im\cortex>arm-none-eabi-gcc --specs=nosys.specs -mcpu=cortex-m0 -S test.c
The assembler output is test.s. The assembly code corresponding the C code in is in light green. The rest of the code are just scaffolding.
C:\Users\Mun3im\cortex>more test.s
.cpu cortex-m0
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 1
.eabi_attribute 30, 6
.eabi_attribute 34, 0
.eabi_attribute 18, 4
.file "test.c"
.text
.align 1
.global main
.syntax unified
.code 16
.thumb_func
.fpu softvfp
.type main, %function
main:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
push {r7, lr}
sub sp, sp, #8
add r7, sp, #0
movs r3, #85
str r3, [r7, #4]
ldr r3, [r7, #4]
movs r2, #255
lsls r2, r2, #8
eors r3, r2
str r3, [r7]
movs r3, #0
movs r0, r3
mov sp, r7
add sp, sp, #8
@ sp needed
pop {r7, pc}
.size main, .-main
.ident "GCC: (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]"
How to decipher the code
movs r3, #85 @ a = 0x55;
str r3, [r7, #4] // a = [r7 + 4]
ldr r3, [r7, #4]
movs r2, #255 // r2 = 0xff
lsls r2, r2, #8 // r2 = 0xff00
eors r3, r2 // r3 = a ^ 0xff00; 'b' is r3
str r3, [r7] @ b = a ^ 0xff00, stored in [r7]
movs r3, #0
movs r0, r3 @ r0 <- 0 to prepare for return 0 C statement