HiSt
2009-05-16 02:47:38 UTC
Hello!
Somewhere in the specifications of ARM CPUs
it states that CMP is like a SUB instruction
without register overwrite...
mov r0,0
mov r1,1
cmp r0,r1
As "cmp r0,r1" is equivalent to
"sub r0,r0,r1" (without writing r0)
and equivalent to "r0-r1"
then the Carry flag (C) should be set in this example,
but IT IS NOT, at least for the CMP instruction.
This means that the CS (Carry Set) and CC (Carry Clear)
condition codes must be interpreted inverted:
CC == "r0 unsigned lower than r1", (normally r0 > r1)
CS == "r0 unsigned higher or same than r1", (normally r0 <= r1)
This leads to weird condition codes for
comparing and branching, for people that
have been programming i86 and 68000.
Is this a specification fault of ARM?
Greetings!
H.Samso (thebitsclub.tripod.com)
Somewhere in the specifications of ARM CPUs
it states that CMP is like a SUB instruction
without register overwrite...
mov r0,0
mov r1,1
cmp r0,r1
As "cmp r0,r1" is equivalent to
"sub r0,r0,r1" (without writing r0)
and equivalent to "r0-r1"
then the Carry flag (C) should be set in this example,
but IT IS NOT, at least for the CMP instruction.
This means that the CS (Carry Set) and CC (Carry Clear)
condition codes must be interpreted inverted:
CC == "r0 unsigned lower than r1", (normally r0 > r1)
CS == "r0 unsigned higher or same than r1", (normally r0 <= r1)
This leads to weird condition codes for
comparing and branching, for people that
have been programming i86 and 68000.
Is this a specification fault of ARM?
Greetings!
H.Samso (thebitsclub.tripod.com)