ARM/THUMB instructions that change execution path?

Has anybody come across a list of ARM & THUMB instructions that cause deviation from the linear instruction stream?

I've been trying to figure out gdb-stub single stepping using software interrupts, and in single stepping you need to find

the next instruction(s) where the next breakpoint instruction needs to be set.

There are three cases:

1) current instruction doesn't change the execution path. Next instruction is the next word.

2) current instruction is a jump. The operand defines the next instruction address

3) current instruction is conditional branch. One possible next instruction is the next word, the other possible

instruction address is defined by the operand. (That includes conditional add with PC as the target, and the like).

To implement single stepping, I need to tell those cases apart and figure out how to find out the possible branching address.

I could go through manuals of numerous processors instruction by instruction and maybe I'd be done within the next couple of years,

or I could find a list of instructions to check, or a paper that explains how to "decode" the instructions in a useful way.

Also, there doesn't seem to be lots of sources of ARM gdb servers or stubs around that use software breakpoints.

Parents
  • I was doing nicely until I had to start decoding that huge set of instructions.

    Pretty laborous and slow.

    Like the media instructions: I found that unsigned and signed parallel addition and subtractions instructions can be

    handled similarly, like:

    A8.8.158cond 0 1 1 0 0 0 0 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmSADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.243cond 0 1 1 0 0 1 0 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmUADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.135cond 0 1 1 0 0 0 1 0       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmQADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.258cond 0 1 1 0 0 1 1 0       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmUQADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.169cond 0 1 1 0 0 0 1 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmSHADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.249cond 0 1 1 0 0 1 1 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmUHADD16<c> <Rd>, <Rn>, <Rm>A1

    All patterns are similar except bit 22=1: unsigned, bits 21,20: 00=undef, 01=basic, 10=Q and 11=H.

    That seems to be the same with all unsigned and signed parallel addition and subtractions instructions.

    It's easier to see the patterns when you can just search and copy the instructions to another file (like the above)

    and compare the bits of all the interesting instructions at once, and with patterns you can often unify the manipulation.

    It would be nice to get the tables into excel or ods for even more flexible manipulation (moving columns around and sorting lines by some columns). Maybe one day.

    [EDIT]

    The web page somehow makes the lines into a table and wraps some cells.

    It looks OK when writing/editing, but after posting it looks a bit weird.

    [/EDIT]

Reply
  • I was doing nicely until I had to start decoding that huge set of instructions.

    Pretty laborous and slow.

    Like the media instructions: I found that unsigned and signed parallel addition and subtractions instructions can be

    handled similarly, like:

    A8.8.158cond 0 1 1 0 0 0 0 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmSADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.243cond 0 1 1 0 0 1 0 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmUADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.135cond 0 1 1 0 0 0 1 0       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmQADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.258cond 0 1 1 0 0 1 1 0       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmUQADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.169cond 0 1 1 0 0 0 1 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmSHADD16<c> <Rd>, <Rn>, <Rm>A1
    A8.8.249cond 0 1 1 0 0 1 1 1       Rn     Rd (1) (1) (1) (1) 0 0 0 1 RmUHADD16<c> <Rd>, <Rn>, <Rm>A1

    All patterns are similar except bit 22=1: unsigned, bits 21,20: 00=undef, 01=basic, 10=Q and 11=H.

    That seems to be the same with all unsigned and signed parallel addition and subtractions instructions.

    It's easier to see the patterns when you can just search and copy the instructions to another file (like the above)

    and compare the bits of all the interesting instructions at once, and with patterns you can often unify the manipulation.

    It would be nice to get the tables into excel or ods for even more flexible manipulation (moving columns around and sorting lines by some columns). Maybe one day.

    [EDIT]

    The web page somehow makes the lines into a table and wraps some cells.

    It looks OK when writing/editing, but after posting it looks a bit weird.

    [/EDIT]

Children