mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Minimal assembly example
This commit is contained in:
parent
95333e06d8
commit
d8a2faf732
4 changed files with 39 additions and 0 deletions
|
|
@ -164,6 +164,7 @@ The uvm32 memory size is set at compile time with `-DUVM32_MEMORY_SIZE=X` (in by
|
||||||
* [host-parallel](host-parallel) parallel vm host running multiple vm instances concurrently, with baked in bytecode
|
* [host-parallel](host-parallel) parallel vm host running multiple vm instances concurrently, with baked in bytecode
|
||||||
* [host-arduino](host-arduino) vm host as Arduino sketch (tested on Arduino Uno ATmega328P, uses 9950 bytes of flash/1254 bytes RAM)
|
* [host-arduino](host-arduino) vm host as Arduino sketch (tested on Arduino Uno ATmega328P, uses 9950 bytes of flash/1254 bytes RAM)
|
||||||
* [apps/helloworld](apps/helloworld) C hello world program
|
* [apps/helloworld](apps/helloworld) C hello world program
|
||||||
|
* [apps/hello-asm](apps/hello-asm) Minimal hello world assembly
|
||||||
* [apps/fib](apps/fib) C fibonacci series program (iterative and recursive)
|
* [apps/fib](apps/fib) C fibonacci series program (iterative and recursive)
|
||||||
* [apps/sketch](apps/sketch) C Arduino/Wiring/Processing type program in `setup()` and `loop()` style
|
* [apps/sketch](apps/sketch) C Arduino/Wiring/Processing type program in `setup()` and `loop()` style
|
||||||
* [apps/rust-hello](apps/rust-hello) Rust hello world program (note, the version of rust installed by brew on mac has issues, use the official rust installer from https://rust-lang.org/learn/get-started/)
|
* [apps/rust-hello](apps/rust-hello) Rust hello world program (note, the version of rust installed by brew on mac has issues, use the official rust installer from https://rust-lang.org/learn/get-started/)
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,12 @@ all:
|
||||||
(cd helloworld && make)
|
(cd helloworld && make)
|
||||||
(cd zig-mandel && make)
|
(cd zig-mandel && make)
|
||||||
(cd rust-hello && make)
|
(cd rust-hello && make)
|
||||||
|
(cd hello-asm && make)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
(cd sketch && make clean)
|
(cd sketch && make clean)
|
||||||
(cd helloworld && make clean)
|
(cd helloworld && make clean)
|
||||||
(cd zig-mandel && make clean)
|
(cd zig-mandel && make clean)
|
||||||
(cd rust-hello && make clean)
|
(cd rust-hello && make clean)
|
||||||
|
(cd hello-asm && make clean)
|
||||||
|
|
||||||
|
|
|
||||||
27
apps/hello-asm/Makefile
Normal file
27
apps/hello-asm/Makefile
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
PROJECT:=hello-asm
|
||||||
|
|
||||||
|
DOCKER_IMAGE=riscv-dev
|
||||||
|
DOCKER_CMD:=docker run --rm -v ${PWD}../../../:/data -w /data/apps/${PROJECT} ${DOCKER_IMAGE}
|
||||||
|
PREFIX:=${DOCKER_CMD} riscv64-unknown-elf-
|
||||||
|
CFLAGS+=-I../../common
|
||||||
|
CFLAGS+=-fno-stack-protector
|
||||||
|
CFLAGS+=-static-libgcc -fdata-sections -ffunction-sections
|
||||||
|
CFLAGS+=-g -Os -march=rv32ima_zicsr -mabi=ilp32 -static
|
||||||
|
LDFLAGS:= -T ../linker.ld -nostdlib -Wl,--gc-sections
|
||||||
|
LIBS:= #-lgcc # needed for softfp
|
||||||
|
|
||||||
|
SRCS=hello-asm.s
|
||||||
|
|
||||||
|
all:
|
||||||
|
${PREFIX}gcc -o ${PROJECT}.elf ${CFLAGS} ${LDFLAGS} ${SRCS} ${LIBS}
|
||||||
|
$(PREFIX)objcopy ${PROJECT}.elf -O binary ${PROJECT}.bin
|
||||||
|
|
||||||
|
disasm: all
|
||||||
|
$(PREFIX)objdump -S -d -f ${PROJECT}.elf
|
||||||
|
|
||||||
|
test: all
|
||||||
|
../../host/host ${PWD}/${PROJECT}.bin
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f ${PROJECT}.o ${PROJECT}.elf ${PROJECT}.bin
|
||||||
|
|
||||||
9
apps/hello-asm/hello-asm.s
Normal file
9
apps/hello-asm/hello-asm.s
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
.section .initial_jump , "ax", %progbits
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
la a5, str
|
||||||
|
csrrw zero,0x13b,a5 # println
|
||||||
|
csrwi 0x138,0 # halt
|
||||||
|
str:
|
||||||
|
.ascii "Hi"
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue