Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ladystarbreeze opened this issue Apr 15, 2021 · 1 comment
Closed

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

ladystarbreeze opened this issue Apr 15, 2021 · 1 comment

Comments

@ladystarbreeze
Copy link

@ladystarbreeze ladystarbreeze commented Apr 15, 2021

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

@endrift
Copy link
Member

@endrift endrift commented Apr 16, 2021

Talk about an edge case of an edge case. Doesn't look hard to fix though.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants