gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > ARM instructions using inline assembly

#177107 - blessingta@hotmail.co.uk - Sun Dec 11, 2011 9:56 pm

hi

How do I activate arm instruction using in-line assembly ? So I'm getting this error:

Code:
instruction not supported in Thumb16 mode -- `subs r2,#1'

#177108 - Dwedit - Sun Dec 11, 2011 11:48 pm

Don't use inline asm unless you really need it to be in-line, use separate source files instead, saves a lot of grief.

That said, make a separate file, declare your code as ARM, and code away.

If you really need inline ARM assembly in what would otherwise be a thumb source file, you need to change the mode the assembler emits, and also change the mode the processor is executing, then change the modes back afterwards.

.thumb
adr r0,someLabel
bx r0
.arm
someLabel:

... code here

adr r0,someLabel2
bx r0
.thumb
someLabel2:
nop
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#177111 - Miked0801 - Mon Dec 12, 2011 7:23 pm

.code16 or .thumb for Thumb
.code32 or .arm for ARM