Difference between .equ and .word in ARM Assembly?
.word is a directive that allocates a word-sized amount of storage space (memory) in that location. It can additionally have that location initialized with a given value.
.equ is more like a C preprocessor #define statement - it gets substituted in any subsequent code.
https://sourceware.org/binutils/docs-2.24/as/Equ.html#Equ
https://sourceware.org/binutils/docs-2.24/as/Word.html#Word
This is not actually ARM-specific, but applies to all gas targets.
.word 即是一个相当于内存中固定位置分配一个 word大小(4字节)的变量,它可以在初始化时就赋值一个给定的值。
.equ 更像是c语言中的 #define 语句,后面的任何位置的代码都可以用到它。
.equ USR_MODE, 0x10 /* normal user mode */
.equ FIQ_MODE, 0x11 /* fiq fast interrupts mode */
.equ IRQ_MODE, 0x12 /* irq standard interrupts mode */
.equ SVC_MODE, 0x13 /* supervisor interrupts mode */
.equ ABT_MODE, 0x17 /* abort processing memory faults mode */
.equ UDF_MODE, 0x1b /* undefined instructions mode */
.equ MODE_MASK, 0x1f /* system running in priviledged operating mode */
.equ NO_INT, 0xc0
.equ CPSR_IRQ_EN, 0x80
.equ CPSR_IRQ_MASK, 0x40 /* disable interrupt mode (irq) */
.equ CPSR_FIQ_MASK, 0x80 /* disable fast interrupt mode (fiq) */
.word 0x2000 /* 自拷贝文件大小 */
.word 0x0
.word 0x0
.word 0x0