File: assembly.md

package info (click to toggle)
riscemu 2.2.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,036 kB
  • sloc: python: 5,669; asm: 780; sh: 28; makefile: 26
file content (37 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Assembly

Assembly tokenization should be working completely. It knows what instructions the CPU implementation supports and parses based on them.


## Instruction sets:
* RV32I
    * Loads/Stores: `lb, lh, lw, lbu, lhu, sw, sh, sb` (supported arg format is either `rd, imm(reg)` or `rd, reg, imm`)
    * Branch statements: `beq, bne, blt, bge, bltu, bgeu`
    * Jumps `j, jal, jalr, ret`
    * Basic arithmetic: `add, addi, sub, lui, auipc`
    * Shifts: `sll, slli, srl, srli, sra, srai`
    * Syscall/Debugging:`scall, ecall, sbreak, ebreak` (both `s` and `e` version are the same instruction)
    * Compares: `slt, sltu, slti, sltiu`
    * Logical: `and, or, xor, andi, ori, xori`
    * Not implemented: `fence, fence.i, rdcycle, rdcycleh, rdtime, rdtimeh, rdinstret, rdinstreth`
* RV32M
    * Multiplication: `mul, mulh`, not implemented yet are `mulhsu, mulhu`
    * Division: `div, divu, rem, remu`



## Pseudo-ops
The following pseudo-ops are implemented as of yet:
* `.space <len>` reverse <len> 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
* `.align <bytes>` currently a nop as cpu does not care about alignment as of now

## 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)