2025-02-09 01:09:13 +00:00
|
|
|
Calculator
|
|
|
|
==========
|
|
|
|
|
|
|
|
Aims to be a calculator implemented in 32-bit RISC-V assembly, initially targeting the
|
|
|
|
inexpensive [CH32V003 RV32EC microcontroller][CH32V003]: 48Mhz 2KB SRAM, 16KB Flash.
|
|
|
|
|
|
|
|
Notes
|
|
|
|
-----
|
|
|
|
|
|
|
|
### Disassemble
|
|
|
|
|
|
|
|
riscv64-unknown-elf-objdump -D main.o
|
|
|
|
|
2025-02-09 05:09:53 +00:00
|
|
|
### List Symbols
|
|
|
|
|
|
|
|
riscv64-unknown-elf-nm calc.o
|
|
|
|
|
|
|
|
### List segment info
|
|
|
|
|
|
|
|
readelf -l calc.elf
|
|
|
|
|
2025-02-13 10:32:18 +00:00
|
|
|
### Build with LLVM
|
|
|
|
|
|
|
|
make AS=clang ASFLAGS="-g -mabi=ilp32e --target=riscv32-unknown-elf -nostdlib -c"
|
|
|
|
|
2025-02-09 01:09:13 +00:00
|
|
|
Resources
|
|
|
|
---------
|
|
|
|
|
|
|
|
* https://riscv-programming.org/book/riscv-book.html
|
|
|
|
* [CH32V003 Datasheet](https://www.wch-ic.com/downloads/CH32V003RM_PDF.html)
|
|
|
|
* [QingKeV2 Processor Manual](https://www.wch-ic.com/downloads/QingKeV2_Processor_Manual_PDF.html) — core used in the CH32V003
|
|
|
|
|
2025-02-09 01:21:38 +00:00
|
|
|
### Syscalls on RV32E
|
|
|
|
|
2025-02-09 01:32:46 +00:00
|
|
|
[Syscalls supported by rv32emu](https://github.com/sysprog21/rv32emu/blob/master/docs/syscall.md).
|
|
|
|
|
2025-02-09 01:21:38 +00:00
|
|
|
Consensus seems to be pass the syscall number in `t0`:
|
|
|
|
|
|
|
|
* https://github.com/riscvarchive/riscv-qemu/pull/61
|
|
|
|
* https://github.com/sysprog21/rv32emu/blob/1286b3c41eec541b68f3d25462722ba848bf4e51/src/syscall.c#L484
|
2025-02-09 01:09:13 +00:00
|
|
|
|
|
|
|
[CH32V003]: https://www.wch-ic.com/products/CH32V003.html
|