Created
January 21, 2012 22:58
-
-
Save singpolyma/1654392 to your computer and use it in GitHub Desktop.
GCC ARM problem example
This file contains 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
.global activate | |
activate: | |
b test |
This file contains 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
.global _start | |
_start: | |
ldr sp, =0x07FFFFFF | |
bl main |
This file contains 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
void activate(void); | |
void test(void) { | |
char *s = "Yay!\n"; | |
while(*s) { | |
*(volatile char*)0x101f1000 = *s; | |
s++; | |
} | |
} | |
int main(void) { | |
char *string = "Hello, World!\n"; | |
char *string2 = "Done!\n"; | |
while(*string) { | |
*(volatile char*)0x101f1000 = *string; | |
string++; | |
} | |
activate(); | |
while(*string2) { | |
*(volatile char*)0x101f1000 = *string2; | |
string2++; | |
} | |
while(1); /* We can't exit, there's nowhere to go */ | |
return 0; | |
} |
This file contains 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
CC=arm-linux-gnueabi-gcc | |
LD=arm-linux-gnueabi-ld | |
CFLAGS=-ansi -pedantic -Wall -Wextra -march=armv6 -msoft-float -fPIC -mapcs-frame | |
LDFLAGS=-N -Ttext=0x10000 | |
kernel.elf: bootstrap.o kernel.o activate.o | |
.PHONY: clean | |
clean: | |
$(RM) *.elf *.o | |
.SUFFIXES: .s .o .elf | |
.s.o: | |
$(CC) $(CFLAGS) -o $@ -c $^ | |
.o.elf: | |
$(LD) $(LDFLAGS) -o $@ $^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment