artikel:arm:arm_v4_asm

Die wichtigsten ARMv4 Assembler-Befehle

  • Alles ARM-Register sind 32-Bit Register.
  • Zuerst steht immer das Ziel, dann die Quelle

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

  • N ⇒ Negative, or less than
    • Wird gesetzt wenn Bit 31 eines Registers 1 ist
  • Z ⇒ Zero
    • Wird beim CMP gesetzt wenn beide Operanden übereinstimmen
  • C ⇒ Carry or borrow or extend
  • V ⇒ Overflow

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.

  • MSR
  • MRS ⇒ Move to Register from Special Register \\moves the value from the selected special-purpose register into a general-purpose register.

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

  • I
  • F
  • T
  • M0..M4

Shift

  • LSL 8 = lower 24 bits remain
  • LSL 16 = lower 16 bits remain
  • LSL 24 = lower 8 bits remain
  • LSL 26 = lower 6 bits remain

ADDS

B...

  • BEQ ⇒ is equal (Z == 1)
  • BNE ⇒ not equal (Z == 0)
  • BCS ⇒ greater than, equal, or unordere (C == 1)
  • BCC ⇒ less than (C == 0)
  • BMI ⇒ negative less than (N == 1)
  • BPL ⇒ positive or zero Greater than, equal, or unordered (N == 0)
  • BX ⇒ ist ein unkonditioneller Sprungbefehl.

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.

  • artikel/arm/arm_v4_asm.txt
  • Zuletzt geändert: Tue. 14.03.2023 13:14
  • von go4it