Skip to content

Use ldrb instead of ldrh+bic for thumb-mode svc immediates#148

Merged
jonathanpallant merged 1 commit intorust-embedded:mainfrom
chrisnc:thumb-svc-ldrb
Mar 17, 2026
Merged

Use ldrb instead of ldrh+bic for thumb-mode svc immediates#148
jonathanpallant merged 1 commit intorust-embedded:mainfrom
chrisnc:thumb-svc-ldrb

Conversation

@chrisnc
Copy link
Contributor

@chrisnc chrisnc commented Mar 17, 2026

No description provided.

@chrisnc
Copy link
Contributor Author

chrisnc commented Mar 17, 2026

I noticed this while trying to get the armeb targets to work on this repo, which is indeed a can of worms... There are in effect five different flavors with different behavior:

  • little-endian (same in qemu and real hardware)
  • BE-8 hardware (e.g., bi-endian Armv7 cores with CPSR.E set)
  • BE-32 hardware (e.g., TI Hercules TMS570)
  • BE-8 qemu
  • BE-32 qemu

Between BE-8 and BE-32 on qemu, BE-8 is the closest to working. Once qemu is patched to interpret semihosting parameter blocks in the true endianness of the target, some of the tests in this repo start working, except for interrupts and svc-related tests. On BE-8, the svc immediate reading code is incorrect because instructions are still little-endian encoded, but ldr will load as big-endian, so you need a byte swap to get the correct value... For interrupts, I suspect that the VIC registers' endianness may be little-endian even when running qemu with cfgend=true.

@jonathanpallant
Copy link
Contributor

Times like these I am very grateful for the test suite we have. If CI passes, I'll merge it.

@jonathanpallant jonathanpallant added this pull request to the merge queue Mar 17, 2026
Merged via the queue into rust-embedded:main with commit a7d4d1c Mar 17, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants