Hi,
I try to run the following code with a Cortex-A8 processor:
asmfunc1: CMP r1, #0 ; Compare r1 to zero.
BCS $1 ; If carry is set, branch to $1;
ADDS r0, r0, #1 ; else increment to r0
MOVCS pc, lr ; and return.
$1: LDR r2, [r5], #4 ; Load indirect of r5 into r2
; with write back.
.newblock ; Undefine $1 so it can be used
; again.
ADDS r1, r1, r2 ; Add r2 to r1.
BPL $1 ; If the negative bit isn't set,
; branch to $1;
MVNS r1, r1 ; else negate r1.
$1: MOV pc, lr ; Return.
At the first lable $1, r5 content is zero. When CPU runs from $1, it does not go to line below the first $1. It goes to a line:
I don't know what does not set correctly causes this. Because I just find that software simulator behaves correctly, it suspects that in the board emulator, the asm function is in a privilege mode related status(?)
This small project is a bare metal type. In main() of the .c file, the asm function is called. I do not find ARM mode control settings in the ARM compiler. What else can change Arm mode in compilation?
Could you help me to understand the curious instruction jump?
Thanks,