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

26/32-bit neutral build... isn't (RISC OS) #5

Open
dpt opened this issue Feb 24, 2021 · 4 comments
Open

26/32-bit neutral build... isn't (RISC OS) #5

dpt opened this issue Feb 24, 2021 · 4 comments

Comments

@dpt
Copy link
Owner

dpt commented Feb 24, 2021

I saw a GtEscape build crashing on ArcEm, Arculator and ArchiEmu but only when configured for ARM2, not ARM250. In fact it locked the virtual machines solid. After some digging I found that the OSLib that I link against isn't 26/32-bit neutral. The 32-bit version uses MRS instructions and they somehow work on emulated ARM250's, but not on emulated ARM2's.

@dpt dpt added the bug label Feb 24, 2021
@dpt dpt self-assigned this Feb 24, 2021
@dpt
Copy link
Owner Author

dpt commented Feb 24, 2021

So OSLib uses the sequence RSB R0,PC,PC:MRS R0,CPSR which is intended to be 26/32-bit neutral, but happens to fail on ARM2 only. It uses that sequence to return CPU flags from os_read_mode_variable(). RSB R0,PC,PC isolates the flag bits on 26-bit ARM. MRS R0,CPSR fetches the flags register on 32-bit ARM. On ARM2 the MRS is UNDEFINED and will fault, but on ARM250/ARM3 it's a NOP.

So since it's a NOP and I don't care about the value returned, the build wobbles on unaware on ARM250+.

A hacky solution would be to physically NOP out that MRS.

@dpt
Copy link
Owner Author

dpt commented Feb 24, 2021

However, note that I didn't see the Undefined instruction error box. It just locked the machine up solid.

@dpt
Copy link
Owner Author

dpt commented Feb 26, 2021

Stopgap: amended !Help in 217aa37 to document that an ARM250 is required.

@dpt dpt added this to TODO in The Great Escape Feb 26, 2021
@dpt dpt removed their assignment Feb 26, 2021
@dpt
Copy link
Owner Author

dpt commented Mar 1, 2021

The likely fix is to use _swi() and dodge OSLib's problematic os_read_mode_variable() veneer. However, we then discover that TimerMod also uses MRS so it can't be ARM2 compatible, despite my fixes... I must have tested it on ArcEm's default configuration which seems to be an ARM2aS, not an ARM2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant