Skip to content

Instantly share code, notes, and snippets.

@21isgonnabeagoodyear
Last active August 29, 2015 14:01
Show Gist options
  • Save 21isgonnabeagoodyear/33db10fce7b886320997 to your computer and use it in GitHub Desktop.
Save 21isgonnabeagoodyear/33db10fce7b886320997 to your computer and use it in GitHub Desktop.
build c code for msp430 using msp430-elf-gcc and naken430asm
#!/bin/sh
#compile it
msp430-elf-gcc -S $1 -o build.s
#remove all the crap gcc throws in, and initialize the stack (0x27f) & org (0xf800)
cat build.s | sed "s/\.text/\.org 0xf800/g" | sed "s/\.file/;\.file/g" | sed "s/\.balign/;\.balign/g" | sed "s/\.global/;\.global/g" | sed "s/\.size/;\.size/g" | sed "s/\.ident/;\.ident/g" |sed "s/\.L/L/g" |sed "s/main:/main:mov.w #0x27f, sp\n mov.w #0x5a80, &0x120;disable wdt/g" |sed "s/{/\n/g" >build2.s
#run main on reset
echo ".org 0xfffe" >> build2.s
echo " dw main" >> build2.s
#assemble it to out.hex
naken430asm build2.s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment