ARM Assembly

Local labels

Local labels are a subclass of label. A local label is a number in the range 0-99, optionally followed by a name. Unlike other labels, a local label can be defined many times and the same number can be used for more than one local label in an area.

Ref: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473c/Caccjfff.html

AArch64 identification registers

Ref: https://developer.arm.com/documentation/ddi0500/d/system-control/aarch64-register-summary/aarch64-identification-registers

Registers in AArch64 state

  • r0 - r31 是 32 個通用暫存器
  • 使用 x1 - x30 會拿到 64-bits ,使用 w0 - w30 會拿到 Lower 32-bits
  • x31 不直接存取
    • 使用 xzr/wzr 來存取即是 zero register
    • 使用 sp/wsp 來存取即是 stack pointer

Ref: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0801a/BABBGCAC.html

副檔名 .s 與 .S 差異

副檔名取 .s 可能會導致找不到 symbol

Ref1: https://stackoverflow.com/a/3076079

Ref2: https://stackoverflow.com/a/51110745

GNU Inline Assembly

asm volatile ("mrs %0, cntfrq_el0" : "=r"(f));

Ref: 關於GNU Inline Assembly

Instructions

eret

Exception Return.

https://developer.arm.com/docs/100076/0100/a32t32-instruction-set-reference/a32-and-t32-instructions/eret

svc

Supervisor calls are normally used to request privileged operations or access to system resources from an operating system.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0179b/ar01s02s07.html

brk

Breakpoint instruction. A BRK instruction generates a Breakpoint Instruction exception. The PE records the exception in ESR_ELx, using the EC value 0x3c, and captures the value of the immediate argument in ESR_ELx.ISS.

https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/brk-breakpoint-instruction

comments powered by Disqus