home | bit manipulation | data manipulation | addressing | loops | conditional execution/flags | about the author
useful documents | exercises | ARMulator | forum | links | c/c++ introduction | contact us | other websites by the author

Loops

An important feature of the ARM instruction set architecture is the presence of BRANCH instructions which, usefully can be configured to execute under certain conditions and enable the programmer to produce loops -like in high level languages such as C or Java. In order to branch the program counter (register R15) needs to be set to a new value, which will break the sequence of the program. The BRANCH instruction has the following format:
B{cc} < label >

An example of a simple loop follows:
      MOV R0, #5
loop
      SUB R0, R0, #1
      ;some useful code
      CMP R0, #0
      BNE loop

Here