I am curious - What is the difference between .equ
and .word
directives in ARM assembly, when defining constants?
* EQU - The equate directive is used to substitute values for symbols or labels. The format is 'label: EQU value', so whenever the assembler encounters 'label', it replaces this with 'value'.
The EQU directive gives a symbolic name to a numeric constant, a register-relative value or a PC-relative value.
db: compile time. the value stored in db is stored in the binary output by the assembler at a specific offset. equ allows you define constants that normally would need to be either hardcoded, or require a mov operation to get. db allows you to have data available in memory before the program even starts.
Assembler directives supply data to the program and control the assembly process. Assembler directives enable you to do the following: Assemble code and data into specified sections. Reserve space in memory for uninitialized variables. Control the appearance of listings.
.equ
is like #define
in C:
#define bob 10
.equ bob, 10
.word
is like unsigned int
in C:
unsigned int ted;
ted:
.word 0
Or initialized with a value:
unsigned int alice = 42;
alice:
.word 42
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With