merged assembly and cpu docs

float_support
Anton Lydike 4 years ago
parent a7cedc1cd2
commit e42ec6a331

@ -22,7 +22,7 @@ Program exited with code 0
``` ```
See the docs on [asembly](docs/assembly.md) and [the cpu](docs/CPU.md) for more detail on how to write assembly code for this emulator. See the docs on [asembly](docs/assembly.md) for more detail on how to write assembly code for this emulator.
See the [list of implemented syscalls](docs/syscalls.md) for more details on how to syscall. See the [list of implemented syscalls](docs/syscalls.md) for more details on how to syscall.
Currently, symbols (such as `main:`) are looked-up at runtime. This allows for better debugging, I believe. Currently, symbols (such as `main:`) are looked-up at runtime. This allows for better debugging, I believe.

@ -1,13 +0,0 @@
# The CPU
The CPU emulates some RISC-V instructions:
* all loads/stores: `lb, lh, lw, lbu, lhu, sw, sh, sb`
* supported arg format is either `rd, imm(reg)` or `reg, reg, imm`
* all branch statements: `beq, bne, blt, bge, bltu, bgeu`
* all jumps `j, jal, jalr, ret`
* basic arithmetic: `add, addi, sub` (not `lui, auipc`)
* shifts: `sll, slli, srl, srli, sra, srai`
* `scall, ecall, sbreak, ebreak` (both `s` and `e` version are the same instrcution)
* compares (non immediate): `slt, sltu`, not `slti, sltiu`
* logiacl (non immediate): `and, or, xor` not (`andi, ori, xori`)

@ -1,23 +1,40 @@
# Assembly # Assembly
Assembly tokenization should be workiung completely. It knows what instructions the CPU implementation supports and parses based on them. 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)` or `rd, reg, imm`
* all branch statements: `beq, bne, blt, bge, bltu, bgeu`
* all jumps `j, jal, jalr, ret`
* basic arithmetic: `add, addi, sub` (not `lui, auipc`)
* shifts: `sll, slli, srl, srli, sra, srai`
* `scall, ecall, sbreak, ebreak` (both `s` and `e` version are the same instruction)
* compares (non immediate): `slt, sltu` (not `slti, sltiu`)
* logical (non immediate): `and, or, xor` (not `andi, ori, xori`)
All unimplemented instructions can be added quite easily
## Pseudo-ops ## Pseudo-ops
The following pseudo-ops are implemented as of yet: The following pseudo-ops are implemented as of yet:
* `.space <len>` reverse <len> bytes of zero * `.space <len>` reverse <len> bytes of zero
* `.ascii 'text'` put text into memory * `.ascii 'text'` put text into memory
* `.asciiz 'text'` put text into memory (null terminated) * `.asciiz 'text'` put text into memory (null terminated)
* `.sextion .<name>` same as `.<name>` see sections: * `.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: ## Sections:
Currently only these three sections are supported: Currently only these three sections are supported:
* `data` read-write data (non-executable) * `data` read-write data (non-executable)
* `rodata` read-only data (non-executable) * `rodata` read-only data (non-executable)
* `.text` executable data (read-only) * `text` executable data (read-only)
## Allocating stack ## Allocating stack
another pseudo-op is recognized: `.stack <len>`. This marks the executable as requesting at least `<len>` bytes of stack. another pseudo-op is recognized: `.stack <len>`. This marks the executable as requesting at least `<len>` bytes of stack.
If the loader repsects this wish, the sp is initialized pointing to the end of the stack. If the loader respects this wish, the sp is initialized pointing to the end of the stack.

@ -1,10 +0,0 @@
# The stack
The stack is a continuous region of memory, located somewhere. The stack grows "downwards", meaning new values are pushed like this:
```asm
add sp, sp, -4
sw a0, sp, 0
```
Loading…
Cancel
Save