如果在指令之间中断,则b做一些事情

时间:2013-12-24 01:50:00

标签: assembly arm arm7

我正在尝试编写程序集来检测当前中断是否发生在两个特定指令之间。

我想我已经拥有它,但我测试并不容易,所以如果有人能够证实我会非常感激。

LDR R0, =INSTR_A ;address of first instruction
CMP LR, R0       ;are we ahead of the first?
BLO NOPE
LDR R0, =INSTR_B ;yes, address of second instr
CMP LR, R0       ;are we ahead of second?
{YEP}LO          ;no, so we're between, do {stuff}LO
{MORE STUFF}LO

看起来不错吗?

我担心的是我应该使用LS代替LO

2 个答案:

答案 0 :(得分:1)

LR_IRQ始终是被中断的指令的地址+4。

即:

 0x00 mov r0, #0  <-- First instruction
 0x04 mov r1, #1
 0x08 mov r2, #2  <-- Interrupt occurs here, Address will be 0x0c in LR_irq not 0x08
 0x0c mov r3, #4  <-- Second instruction

我希望你现在可以弄清楚你的代码有什么问题:)

答案 1 :(得分:-1)

LDR R0, =INSTR_A ;address of first instruction
CMP LR, R0       ;If LR < R0 (or LR - R0 underflows), set carry
BLO NOPE         ; Branch if carry set (LO = CC)
LDR R0, =INSTR_B ;yes, address of second instr
CMP LR, R0       ;are we ahead of second?
BLO YEP          ;This is what you meant?