Die wichtigsten ARMv4 Assembler-Befehle

Grundsätzliches

Condition Flags

Die Flags sind in den oberen 4 Bit des CPSR Registers.

https://developer.arm.com/documentation/ddi0210/c/Programmer-s-Model/The-program-status-registers?lang=en

https://developer.arm.com/documentation/ddi0406/c/Application-Level-Architecture/Instruction-Details/Conditional-execution?lang=en

5f4786a179ff4c392c0ff7f5

Use MRS in combination with MSR as part of a read-modify-write sequence for updating a PSR, for example to change processor mode, or to clear the Q flag.

Conditional execution

Basierend auf den Condition-Flags können Befehle entsprechend ausgeführt oder übersprungen werden:

https://developer.arm.com/documentation/ddi0406/c/Application-Level-Architecture/Instruction-Details/Conditional-execution?lang=en

Control bits

Shift

Assembler Commands

ADDS

B...

VS Overflow Unordered V == 1 VC No overflow Not unordered V == 0 HI Unsigned higher Greater than, or unordered C == 1 and Z == 0 LS Unsigned lower or same Less than or equal C == 0 or Z == 1 GE Signed greater than or equal Greater than or equal N == V LT Signed less than Less than, or unordered N != V GT Signed greater than Greater than Z == 0 and N == V LE Signed less than or equal Less than, equal, or unordered Z == 1 or N != V

CMP

„Compare“, vergleich die angegebenen Werte auf Übereinstimmung und setzt in diesem Fall das „Z“-Flag (Zero). Technisch entspricht es einer Subtraktion, die wenn beide Werte gleich sind, bei Gleichheit einfach „0“ ergibt.

LDR

„Load Register“ lädt das angegebene Register mit einem Wert. Dieser kann direkt oder von einer Speicherstelle geladen werden.

LDR R1, =<byte_ADDR>
Das = zeigt an das der Wert aus der angegebenen Speicherstelle ins Register geladen wird.

LDRB R0, [R4, #1]
Lädt ein Byte von Adresse in R4 mit Offset #1 in das Zielregister R0.

LSL, LSLS

LSL = Logical Shift Left

If „S“ is specified, the LSL instruction updates the N and Z flags according to the result. The C flag is unaffected if the shift value is 0. Otherwise, the C flag is updated to the last bit shifted out.

LSLS R0, R0, #2 ⇒ Thumb-Operator um den Inhalt von R0 um die angegebene Anzahl Bits nach links zu schieben.

LSRS

MOV / MOVS

MOV TARGET, SOURCE

MOV R2, #0x80 lädt den direkt (angezeigt durch #) angegebenen Wert 0x80 in das Register R2

MOVS aktualisiert nach der Ausführung die Statusflags.