0

How do I convert this example of psuedo code to Arm 7??

if R8 == 1, Go to "method 1"
else, Go to "method 2"

Also in "method 1" R8 is changed to two (R8=2), so the next time around I want it to access "method 2". So I wanted the loop to alternate between method 1 and 2

Ano
  • 1
  • 2
  • 1
    You must show some effort than asking questions without giving a shot yourself. Are you also sure you want this for Arm 7? If this is for newer generations you want ARMv7. Arm 7 is a really old core. – auselen Oct 24 '14 at 06:23
  • possible duplicate of [Branching to different subroutines in ARM assembly?](http://stackoverflow.com/questions/26110034/branching-to-different-subroutines-in-arm-assembly) – artless noise Oct 24 '14 at 15:10

1 Answers1

1
cmp r8, #1
bleq method1
cmp r8, #1 //method1 may alter CPSR
blne method2

see http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/CIHIDDID.html

Jacen
  • 346
  • 2
  • 12
  • I would investigate `adrCC rX,methodYY` and a final `bl rx` to avoid the re-compare. I think the table method in the other question/answer is just as good, even for two values and will work if the method1 trashes `r8` (assembler may not follow the APCS). – artless noise Oct 24 '14 at 15:17
  • How would i form a branch if the value R8 is odd? – Ano Oct 24 '14 at 19:38
  • Indeed, with more methods, I would put them in an array, and compute an offset to call the right one, but here, I only have two choices, and ldr may cost much time. @TaylorAustin, look in the [ARM documentation](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/CIHIDDID.html) you've got an instruction for bitwise tests. – Jacen Oct 26 '14 at 11:14