You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.6 KiB
1.6 KiB
Assembly
Assembly tokenization should be working completely. It knows what instructions the CPU implementation supports and parses based on them.
Instructions
- all loads/stores:
lb, lh, lw, lbu, lhu, sw, sh, sb
- supported arg format is either
rd, imm(reg)
orrd, reg, imm
- supported arg format is either
- all branch statements:
beq, bne, blt, bge, bltu, bgeu
- all jumps
j, jal, jalr, ret
- basic arithmetic:
add, addi, sub
(notlui, auipc
) - shifts:
sll, slli, srl, srli, sra, srai
scall, ecall, sbreak, ebreak
(boths
ande
version are the same instruction)- compares (non immediate):
slt, sltu
(notslti, sltiu
) - logical (non immediate):
and, or, xor
(notandi, ori, xori
)
All unimplemented instructions can be added quite easily
Pseudo-ops
The following pseudo-ops are implemented as of yet:
.space <len>
reverse bytes of zero.ascii 'text'
put text into memory.asciiz 'text'
put text into memory (null terminated).section .<name>
same as.<name>
, see sections.set <name>, <value>
to create a const symbol with a given value.global <name>
mark symbol<name>
as a global symbol. It is available from all loaded programs
Sections:
Currently only these three sections are supported:
data
read-write data (non-executable)rodata
read-only data (non-executable)text
executable data (read-only)
Allocating stack
another pseudo-op is recognized: .stack <len>
. This marks the executable as requesting at least <len>
bytes of stack.
If the loader respects this wish, the sp is initialized pointing to the end of the stack.