Last active
December 28, 2015 14:49
-
-
Save makestuff/7517475 to your computer and use it in GitHub Desktop.
Generating ARMv2 code with a gcc cross-compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat regs.c | |
| typedef unsigned int uint32; | |
| #define BLTCON1 *((volatile uint32 *)0xFFFFFF00) | |
| #define BLTCON2 *((volatile uint32 *)0xFFFFFF04) | |
| #define BLTCON3 *((volatile uint32 *)0xFFFFFF08) | |
| void foo(uint32 x, uint32 y, uint32 z) { | |
| BLTCON1 = x; | |
| BLTCON2 = y; | |
| BLTCON3 = z; | |
| } | |
| $ armeb-unknown-eabi-gcc -march=armv2 -O2 -S -Wall -Wextra -Wundef -Wconversion -pedantic-errors -std=c99 regs.c | |
| regs.c:1: warning: target CPU does not support interworking | |
| $ cat regs.s | |
| .arch armv2 | |
| .fpu softvfp | |
| .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, 2 | |
| .eabi_attribute 18, 4 | |
| .file "regs.c" | |
| .text | |
| .align 2 | |
| .global foo | |
| .type foo, %function | |
| foo: | |
| @ args = 0, pretend = 0, frame = 0 | |
| @ frame_needed = 0, uses_anonymous_args = 0 | |
| @ link register save eliminated. | |
| mvn r3, #0 | |
| str r0, [r3, #-255] | |
| str r1, [r3, #-251] | |
| str r2, [r3, #-247] | |
| mov pc, lr | |
| .size foo, .-foo | |
| .ident "GCC: (crosstool-NG 1.19.0) 4.3.2" | |
| $ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.19.0.tar.bz2 | |
| bunzip2 -c crosstool-ng-1.19.0.tar.bz2 | tar xf - | |
| cd crosstool-ng-1.19.0 | |
| ./configure --enable-local | |
| make | |
| ./ct-ng armeb-unknown-eabi | |
| ./ct-ng build | |
| export PATH=${PATH}:${HOME}/x-tools/armeb-unknown-eabi/bin | |
| armeb-unknown-eabi-gcc -march=armv2 ... |
ghost
commented
Nov 17, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment