Page 1 of 1

devkitARM release 52-2 thumb code generation problem

Posted: Sun Jun 09, 2019 9:44 pm
by gomwing
devkitARM release 52-2 thumb code generation problem

I am hobbiest programmer. and recently i reinstalled devkitARM with NDS, GBA development tools

working with old source code

I compiled old source code with original option

ARCH := -mthumb -mthumb-interwork

but

generated code has undefined instructions.

Emulation unpaused
ARM9: Undefined instruction: 0x33017813 PC=0x020019D8

this codes are
.text:020019D4 ; =============== S U B R O U T I N E =======================================
.text:020019D4
.text:020019D4
.text:020019D4 EXPORT scalingSet
.text:020019D4 scalingSet
.text:020019D4 10 B5 PUSH {R4,LR}
.text:020019D6 07 4A LDR R2, =g_scaling_set
.text:020019D8 13 78 LDRB R3, [R2] <- here ---------------------------------------------
.text:020019DA 01 33 ADDS R3, #1
.text:020019DC 1B 06 LSLS R3, R3, #0x18
.text:020019DE 1B 0E LSRS R3, R3, #0x18
.text:020019E0 02 2B CMP R3, #2
.text:020019E2 05 D8 BHI loc_20019F0
.text:020019E4
.text:020019E4 loc_20019E4 ; CODE XREF: scalingSet+1Ej
.text:020019E4 13 70 STRB R3, [R2]
.text:020019E6 02 F0 DF FF BL SetupScaling
.text:020019EA 04 F0 47 F8 BL SetVDPMode
.text:020019EE 10 BD POP {R4,PC}

==============================================================================================

i think byte code 13 78 is not valid thumb code..


,

but with this option . it works well

ARCH := -marm -mthumb-interwork


is this compiler problem? or Am i lost some newer options ?

Re: devkitARM release 52-2 thumb code generation problem

Posted: Mon Jun 10, 2019 10:48 pm
by WinterMute
gomwing wrote: Sun Jun 09, 2019 9:44 pm
generated code has undefined instructions.

Emulation unpaused
ARM9: Undefined instruction: 0x33017813 PC=0x020019D8
The generated code is fine. If you look closely the reported undefined instruction has a 32bit encoding (0x33017813) which indicates that the emulator core is trying to run in arm mode rather than thumb. It's hard to offer any advice without seeing code but my best guess would be that there's an arm assembly function somewhere that is somehow not interworking safe.