Skip to content

LDMS with empty rlist does not reload CPSR when it should #2127

@ladystarbreeze

Description

@ladystarbreeze

In mGBA 0.9.0, the LDM rbase, {}^ instruction does not reload CPSR. Hardware interprets an empty rlist as "transfer r15" (which is correctly implemented in mGBA); however, this also applies to LDMS, so hardware ends up reloading CPSR.

; switch to Abort mode, set up SPSR
mov     r0, 0x17
msr     cpsr_csxf, r0
orr     r0, 0xF0000000
msr     spsr, r0

adr     r1, .Pool_Main
dw      0xE8D10000 ; ldmia r1, {}^

.Main_PrintResult:
    ; save new CPSR value, switch back to System mode
    mrs     r0, cpsr ; F0000017h on hardware, 00000017h in mGBA
    msr     cpsr_csxf, 0x1F
    mov     r1, 8
    bl      .PrintHex

.Loop_Endless:
    b       .Loop_Endless
    
.Pool_Main:
    dw      MEM_ROM0 + .Main_PrintResult

ldmia_empty_cpsr

ldmia_empty_cpsr_mGBA

ldmia_empty_cpsr.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions