commit 112859b68b19ef3ede8c8d6b462e29e3a4231197 from: Benjamin Stürz date: Tue Feb 20 19:11:00 2024 UTC cleanup commit - ff146ca7952073cfa50cef3136f5ad8bf6249dfb commit + 112859b68b19ef3ede8c8d6b462e29e3a4231197 blob - 56c7fd9329171d775185b57763c510b8323df1a0 blob + c1b64dea367cf49f7f9f16f859eb4ff99407573e --- Makefile +++ Makefile @@ -10,7 +10,7 @@ CROSS = ./tools/bin/${TARGET} CFLAGS = -std=c2x -fPIC -O0 -g LDFLAGS = -pie -static -lpthread OBJ = rvemu.o ecall.o cpu.o exec.o -PROGS = test.elf test2.elf hello.elf +PROGS = test.elf hello.elf all: rvemu ${PROGS} blob - 2d4bd3fa404ee1f85babb18ff8609923bbd281e4 blob + 8f4a68660eee0892775ff39ba5a6f7f43029bf82 --- hello.S +++ hello.S @@ -1,7 +1,4 @@ .include "syscalls.inc" -#include "syscalls.inc" -#.set SYS_write, 64 -#.set SYS_exit, 93 .section .rodata str: .string "Hello World\n" blob - 85a84552dd1982a85a006dc9c3b5193fa5b25c11 (mode 644) blob + /dev/null --- test2.S +++ /dev/null @@ -1,103 +0,0 @@ -.include "syscalls.inc" - -.section .data -parent: .string "Parent\n" -child: .string "Child\n" -arg0: -path: .string "./hello.elf" -argv: - .dword arg0 - .dword 0 - -envp: - .dword 0 - -.section .text -.global _start -.type _start, %function -_start: - addi sp, sp, -4 - - li a0, 17 - li a1, 0 - li a7, SYS_clone - ecall - - beq a0, zero, .Lchild - - li a0, 1 - la a1, parent - li a2, 7 - li a7, SYS_write - ecall - - la a0, path - la a1, argv - la a2, envp - li a7, SYS_execve - ecall - - jal printhex - - li a0, 0 - li a7, SYS_exit - ecall - -.Lchild: - li a0, 1 - la a1, child - li a2, 6 - li a7, SYS_write - ecall - - li a0, 0 - li a7, SYS_exit - ecall - -# printhex(u64 a0) -printhex: - addi sp, sp, -12 - sw s0, 8(sp) - sw s1, 4(sp) - li s0, 52 - mv s1, a0 - -.Loop: - srl t0, s1, s0 - andi t0, t0, 0xf - - li t1, 10 - blt t0, t1, .Ldec - addi t0, t0, 55 - j .Lprint - -.Ldec: - addi t0, t0, 48 - -.Lprint: - sb t0, 0(sp) - li a0, 1 - mv a1, sp - li a2, 2 - li a7, 64 - ecall - - beq s0, zero, .Lret - addi s0, s0, -4 - j .Loop - -.Lret: - li t0, 10 - sw t0, 0(sp) - li a0, 1 - mv a1, sp - li a2, 1 - ecall - - lw s1, 4(sp) - lw s0, 8(sp) - addi sp, sp, 12 - ret - - -