Skip to content

Instantly share code, notes, and snippets.

@singpolyma
Created January 21, 2012 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singpolyma/1654392 to your computer and use it in GitHub Desktop.
Save singpolyma/1654392 to your computer and use it in GitHub Desktop.
GCC ARM problem example
.global activate
activate:
b test
.global _start
_start:
ldr sp, =0x07FFFFFF
bl main
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;
}
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