I have seen the following directives but I don't know exactly the usage:
.space
.byte
.word
.asciiz
.ascii
.align
I have seen the following directives but I don't know exactly the usage:
.space
.byte
.word
.asciiz
.ascii
.align
.space
reserves n bytes of memory, without aligning. e.g. arr: .space 100
.byte
store the n values in successive bytes of memory. e.g. num: .byte 0x01, 0x03
.word
store n 32-bit words contiguously in aligned memory. e.g. val: .word 10, -14, 30
.asciiz
stores string in memory with a null terminator. e.g. str: .asciiz "Hello, world"
.ascii
with a .byte 0
after it..ascii
stores string in memory without a null terminator. e.g. str: .ascii "Hello, world"
.align
aligns the next data on a 2^n
byte boundary. e.g. .align 2
aligns the next value on a word boundary. On the other hand if n is 0 then alignment is turned off until next data segment.For a detailed information see this assembly reference.
For more details about .align
, see
.align
in classic MIPS assemblers (like MARS) works differently from modern GAS and clang: in classic MIPS assemblers, it can put padding before an earlier label, instead of expanding to padding wherever you put it. (.word
and .half
also align an earlier label, unlike .space
)