LDR 的两种用法
1)LDR pc, =MyHandleIRQ 表示将MyHandleIRQ符号放入pc寄存器中
2)LDR PC,MyHandleIRQ 表示将读取存储器中MyHandleIRQ符号所表示的地址中的值,及需要多读一次存储器。
在代码中:
start:
ldr pc,=MyHandleReset @jump to HandleReset
ldr pc,=MyHandleUndef @jump to HandleUndef
ldr pc,=MyHandleSWI @jump to HandleSWI
ldr pc,=MyHandleIabort @jump to HandleIabort
ldr pc,=MyHandleDabort @jump to HandleDabort
nop
ldr pc,=MyHandleIRQ @jump to HandleIRQ <=之前出错的一行
ldr pc,=MyHandleFIQ @jump to HandleFIQ
@MyHandleIRQ: .word OS_CPU_IRQ_ISR
MyHandleIRQ:
sub lr, lr, #4 @ to calculate the return address
stmdb sp!, {r0-r12,lr}
ldr lr, =int_return @ restore the return address
ldr pc, =int_handle @ call for the interrupt handler
在“之前出错的一行”处,如果改成“ldr pc,MyHandleIRQ”当中断来临时,无法进行中断处理。
另一种情况是正确的,注意体会:
start:
ldr pc,=MyHandleReset @jump to HandleReset
ldr pc,=MyHandleUndef @jump to HandleUndef
ldr pc,=MyHandleSWI @jump to HandleSWI
ldr pc,=MyHandleIabort @jump to HandleIabort
ldr pc,=MyHandleDabort @jump to HandleDabort
nop
ldr pc,MyHandleIRQ @jump to HandleIRQ <=之前出错的一行
ldr pc,=MyHandleFIQ @jump to HandleFIQ
MyHandleIRQ: .word OS_CPU_IRQ_ISR
@MyHandleIRQ:
@ sub lr, lr, #4 @ to calculate the return address
@ stmdb sp!, {r0-r12,lr}
@ ldr lr, =int_return @ restore the return address
@ ldr pc, =int_handle @ call for the interrupt handler
因为当中断来临时,还需要去MyHandleIRQ处把OS_CPU_IRQ_ISR取出,即多取一次存储器。
阅读(3601) | 评论(0) | 转发(0) |