Skip to content

Commit a7d4d1c

Browse files
Merge pull request #148 from chrisnc/thumb-svc-ldrb
Use ldrb instead of ldrh+bic for thumb-mode svc immediates
2 parents 510c872 + 9d81f6d commit a7d4d1c

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

aarch32-rt/src/arch_v4/svc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ core::arch::global_asm!(
2929
mrs r0, spsr // Load processor status that was banked on entry
3030
tst r0, {t_bit} // SVC occurred from Thumb state?
3131
beq 1f
32-
ldrh r0, [lr,#-2] // Yes: Load halfword and...
33-
bic r0, r0, #0xFF00 // ...r0 now contains SVC number
32+
ldrb r0, [lr,#-2] // Yes: Load 1-byte immediate
3433
b 2f
3534
1:
3635
ldr r0, [lr,#-4] // No: Load word and...
37-
bic r0, r0, #0xFF000000 // ...r0 now contains SVC number
36+
bic r0, r0, #0xFF000000 // ...extract 3-byte immediate
3837
2:
3938
mov r1, r12 // pass the stacked integer registers in r1
4039
bl _svc_handler

aarch32-rt/src/arch_v7/svc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ core::arch::global_asm!(
2626
r#"
2727
mrs r0, spsr // Load processor status that was banked on entry
2828
tst r0, {t_bit} // SVC occurred from Thumb state?
29-
ldrhne r0, [lr,#-2] // Yes: Load halfword and...
30-
bicne r0, r0, #0xFF00 // ...extract comment field
29+
ldrbne r0, [lr,#-2] // Yes: Load 1-byte immediate
3130
ldreq r0, [lr,#-4] // No: Load word and...
32-
biceq r0, r0, #0xFF000000 // ...extract comment field
31+
biceq r0, r0, #0xFF000000 // ...extract 3-byte immediate
3332
mov r1, r12 // pass the stacked integer registers in r1
3433
bl _svc_handler
3534
mov lr, r0 // move r0 out of the way - restore_fpu_context will trash it

0 commit comments

Comments
 (0)