RISC-V directives

What directives are

RISC-V directives are used to define the structure of the program. They are not instructions that are executed by the CPU, but rather instructions that are used by the assembler to define the structure of the program.

.data

Subsequent items stored in Data segment at next available address

.text

Subsequent items (instructions) stored in Text segment at next available address

.word

Store the listed value(s) as 32 bit words on word boundary

.dword

Store the listed value(s) as 64 bit double-word on word boundary

.ascii

Store the string in the Data segment but do not add null terminator

.asciz

Store the string in the Data segment and add null terminator

.string

Alias for .asciz

.byte

Store the listed value(s) as 8 bit bytes

.align

Align next data item on specified byte boundary (0=byte, 1=half, 2=word, 3=double)

.half

Store the listed value(s) as 16 bit halfwords on halfword boundary

.space

Reserve the next specified number of bytes in Data segment

.double

Store the listed value(s) as double precision floating point

.float

Store the listed value(s) as single precision floating point

.extern

Declare the listed label and byte length to be a global data field

.globl

Declare the listed label(s) as global to enable referencing from other files

.global

Declare the listed label(s) as global to enable referencing from other files

.eqv

Substitute second operand for first. First operand is symbol, second operand is expression (like #define)

.macro

Begin macro definition. See .end_macro

.end_macro

End macro definition. See .macro

.include

Insert the contents of the specified file. Put filename in quotes.

.section

Allows specifying sections without .text or .data directives. Included for gcc comparability

.bss

Subsequent items stored in the Data segment, which starts out zeroed

.sbss

Alias for .bss

.zero

Reserve the next specified number of bytes, which read as zero. Alias for .space

.comm

Reserve the given number of bytes for a global symbol, the way a C compiler declares an uninitialized global variable. Takes a symbol, a size in bytes and an optional alignment

.lcomm

Reserve the given number of bytes for a symbol local to this file, the way a C compiler declares an uninitialized static variable

.p2align

Align next data item on a 2^n byte boundary. Alias for .align

.balign

Align next data item on the given byte boundary, written directly rather than as a power of two

.2byte

Alias for .half

.4byte

Alias for .word

.8byte

Alias for .dword