| 汇编伪指令 |
描述 |
举例 |
| .ascii “<string>” |
插入字符串到目标文件,但不以NULL结束 |
.ascii "JNZ" @插入字节0x4A 0x4E 0x5A |
| .asciz “<string>” |
与.ascii类似,但以NULL结束 |
.asciz "JNZ" @插入字节0x4A 0x4E 0x5A 0x00 |
.balign <power_of_2>
{,<fill_value>
{,<max_padding>} } |
使下面的位置<power_of_2>对齐 |
.byte 0x55 @插入字节: 0x55
.balign 4,0 @插入3个对齐字节:0x00 0x00 0x00
.word 0xAA55EE11 @插入字节:0x11 0xEE 0x55 0xAA (LSB order) |
| .byte <byte1> {,<byte2>} … |
插入字节到目标文件 |
.byte 64, 'A' @ inserts the bytes 0x40 0x41
.byte 0x42 @ inserts the byte 0x42
.byte 0b1000011, 0104 @ inserts the bytes 0x43 0x44 |
| .code <number_of_bits> |
设置指令位数,16位Thumb或32位ARM |
.code 16 @设置以下汇编为Thumb指令 |
| .else |
与 .if 和 .endif 配合使用 |
|
| .end |
标志汇编文件结束,汇编器不再读后面的内容 |
|
| .endif |
怀.if 配合使用 |
|
| .endm |
标志宏定义结束,与.macro配合使用 |
|
| .endr |
结束一个loop,与.rept 和 .irp 配合使用 |
|
| .equ <symbol name>, <value> |
设置一个符号的值 |
.equ adams, (5 * 8) + 2 @ set adams to 42
.set adams, 0x2A @ set adams to 42
adams = 0b00101010 @ set adams to 42 |
| .err |
汇编时如遇到.err,则停止编译 |
|
| .exitm |
中途退出宏定义 |
|
| .global <symbol> |
标识symbol被程序的其它模块(汇编或C)访问,
相当于Kernel中的EXPORT_SYMBOL |
.global _my_test_count @它可被其它模块R/W |
.hword <short1> {,<short2>}
… |
插入16位(半字)值到目标文件 |
.hword 0xAA55, 12345 @ 插入字节 0x55 0xAA 0x39 0x30
.2byte 0x55AA, -1 @插入字节 0xAA 0x55 0xFF 0xFF
@ Least Significant Byte (LSB) ordering assumed |
| .if <logical_expression> |
与 .endif 配合使用 |
|
| .ifdef <symbol> |
与 .endif 配合使用 |
|
| .ifndef <symbol> |
与 .endif 配合使用 |
|
| .include “<filename>” |
与C的#include类似 |
|
.irp <param> {,<val_1>}
{,<val_2>} … |
Repeats a block of code, once for each value
in the value list.Mark the end of the block
using a .endr directive. In therepeated code block,
use \<param> to substitute the associated
value in the value list. |
|
.macro <name> {<arg_1}
{,<arg_2>} … {,<arg_N>} |
定义一个名为name的汇编宏,它有N个参数,
且必须以.endm结束。 |
.macro SHIFTLEFT a, b
.if \b < 0
MOV \a, \a, ASR #-\b
.exitm
.endif
MOV \a, \a, LSL #\b
.endm |
.section <section_name>
{,”<flags>”} |
开始一个新的section, section_name可为:
.text: 代码段
.data: 已初始化的数据段
.bss: 未初始化的数据段
flags可为:
a allowable section
w writable section
x executable section |
.section .text, “x” |
.set <variable_name>,
<variable_value> |
设置变化的值,与.equ一样 |
.set adams, 0x2A @ set adams to 42 |
.space <number_of_bytes>
{,<fill_byte>} |
预留给定字节空间,并设置为0或fill_byte |
.space 0x400,0 |
| .word <word1> {,<word2>} … |
插入32位字列表到目标文件 |
head_ptr: .word 0 @ Head pointer to within buffer (initially zero)
tail_ptr: .word 0 @ Tail pointer to within buffer (initially zero)
.word 0xDEADBEEF @inserts the bytes 0xEF 0xBE 0xAD 0xDE
.4byte -42 @ inserts the bytes 0xD6 0xFF 0xFF 0xFF
@ Least Significant Byte (LSB) ordering assumed |
| .rept <number_of_times> |
重复执行代码块number_of_times次,与C中for
类似,以endr结束 |
|
<register_name> .req
<register_name> |
寄存器重新命名 |
acc .req r0 |