Search code examples
assemblyarmarm7

If interrupted between instructions a, b do some stuff


I am trying to write assembly to detect if the present interrupt happened between two particular instructions.

I think I have it, but it's not easy for me to test, so if someone could verify I would very much appreciate it.

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

Does that look right?

My concern is that I should be using LS instead of LO?


Solution

  • LR_IRQ is always address+4 of the instruction that was interrupted.

    ie:

     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
    

    I hope you can figure out what's wrong with your code now :)