Has anyone been successful in assembling, compiling and running thumb or thumb-2 on Rasparian. Here is an example of my assembly code:

.global main
.code 16
      MOV r3,#1
      bx lr

I have been attempting to use gas for assembly and gcc to compile:

as -o multiply.o multiply.s
gcc -mthumb -o multiply multiply.o

Both run without a complaint but when I attempt to run the code in GDB I get a SIGILL:

(gdb) b main
Breakpoint 1 at 0x8392
(gdb) run
Starting program: /home/pi/Dev/assembly_files/multiply 

Program received signal SIGILL, Illegal instruction.
0x00008390 in main ()

So, I'm uncertain if its something I am doing wrong or if I need to change my toolchain or other? I appreciate any advice. Also know that normal 32-bit ARM assembles, compiles and runs like a champ.

1 Answer 1


your program cannot just end, it's supposed to make a system call, that returns the control to the operating system. also, this is totally off topic here.

  • I'm uncertain how this is off-topic? I am using a raspberry-pi and I'm fairly certain writing code on it requires some specific libraries of code which other raspberry pi developers would be aware of. My code did have a mistake which I have resolved but the question still remains. Should I be capable of assembling thumb on raspberry pi using a linux based distro? Commented Jun 29, 2013 at 16:05
  • 2
    Why would it be offtopic? Commented Sep 3, 2013 at 0:23
  • @ThorbjørnRavnAndersen basic programming questions, like falling off the end of assembly program without calling the system about program exit, have nothing to do with Raspberry Pi, IMNSHO.
    – lenik
    Commented Sep 3, 2013 at 2:49
  • Raspberry Pi assembly programming? Well, as good a forum as any if it as a starter question and it can inspire others. Anyway, if you consider a question off-topic, flag it as so, so it can be migrated. Note that e.g. SO puts higher standards regarding question effort than might be possible for a hobbyist learning to program. Commented Sep 3, 2013 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.