Skip to content

Commit fd9d34a

Browse files
committed
Clean up assembly code a little
Add some extra comments, and replace an ldmia with a pop.
1 parent 4962f3f commit fd9d34a

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

aarch32-rt/src/arch_v4/abort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ core::arch::global_asm!(
3434
pop {{ r0-r4, r12 }} // restore preserved registers, dummy value, and alignment amount
3535
add sp, r12 // restore SP alignment using R12
3636
pop {{ r12 }} // restore SPSR using R12
37-
msr spsr_cxsf, r12 //
37+
msr spsr, r12 //
3838
pop {{ r12 }} // restore R12
3939
movs pc, lr // return from exception
4040
.size _asm_default_data_abort_handler, . - _asm_default_data_abort_handler
@@ -75,7 +75,7 @@ core::arch::global_asm!(
7575
pop {{ r0-r4, r12 }} // restore preserved registers, dummy value, and alignment amount
7676
add sp, r12 // restore SP alignment using R12
7777
pop {{ r12 }} // restore SPSR using R12
78-
msr spsr_cxsf, r12 //
78+
msr spsr, r12 //
7979
pop {{ r12 }} // restore R12
8080
movs pc, lr // return from exception
8181
.size _asm_default_prefetch_abort_handler, . - _asm_default_prefetch_abort_handler

aarch32-rt/src/arch_v4/interrupt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ core::arch::global_asm!(
3535
pop {{ r0-r3, r12, lr }} // restore alignment amount (in LR) and preserved registers
3636
add sp, lr // restore SP alignment using LR
3737
msr cpsr_c, {irq_mode} // switch back to IRQ mode (with IRQ masked)
38-
ldmia sp!, {{ lr }} // load and restore SPSR using LR
38+
pop {{ lr }} // load and restore SPSR using LR
3939
msr spsr, lr //
40-
ldmfd sp!, {{ pc }}^ // return from exception
40+
ldmfd sp!, {{ pc }}^ // return from exception (^ => restore SPSR to CPSR)
4141
.size _asm_default_irq_handler, . - _asm_default_irq_handler
4242
"#,
4343
// sys mode with IRQ masked

aarch32-rt/src/arch_v4/svc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ core::arch::global_asm!(
4646
mov r0, lr // replace R0 with return value from _svc_handler
4747
add sp, r12 // restore SP alignment using R12
4848
pop {{ lr }} // restore SPSR using LR
49-
msr spsr_cxsf, lr //
50-
ldmfd sp!, {{ r12, pc }}^ // restore R12 and return from exception
49+
msr spsr, lr //
50+
ldmfd sp!, {{ r12, pc }}^ // restore R12 and return from exception (^ => restore SPSR to CPSR)
5151
.size _asm_default_svc_handler, . - _asm_default_svc_handler
5252
"#,
5353
t_bit = const { crate::Cpsr::new_with_raw_value(0).with_t(true).raw_value() },

aarch32-rt/src/arch_v4/undefined.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ core::arch::global_asm!(
3939
pop {{ r0-r4, r12 }} // restore preserved registers, dummy value, and alignment amount
4040
add sp, r12 // restore SP alignment using R12
4141
pop {{ r12 }} // restore SPSR using R12
42-
msr spsr_cxsf, r12 //
42+
msr spsr, r12 //
4343
pop {{ r12 }} // restore R12
44-
movs pc, lr // return from exception
44+
movs pc, lr // return from exception (movs => restore SPSR to CPSR)
4545
.size _asm_default_undefined_handler, . - _asm_default_undefined_handler
4646
"#,
4747
t_bit = const { crate::Cpsr::new_with_raw_value(0).with_t(true).raw_value() },

0 commit comments

Comments
 (0)