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
Aligns the next data address to a 2^n-byte boundary: .align 0 is byte alignment, .align 1 is 2 bytes, .align 2 is 4 bytes, and .align 3 is 8 bytes. Here the operand is the exponent; .balign takes the byte count directly.
.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
Declares an external data symbol and its size in bytes, so the assembler can reserve its address for references to that symbol.
.globl
Marks the listed symbol as global so it can be used as an external name, such as a program entry point: .globl main.
.global
Alias for .globl: marks a symbol as global, for example .global main.
.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
Switches to the named section, such as .text, .data, .rodata, or .bss. In this simulator, .rodata and .bss share the data segment with .data; use .text for instructions.
.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