From b2de6cebe9186914046fd4a6d37230688ab866c7 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Tue, 25 Jun 2024 15:27:39 +0000 Subject: [PATCH] Initial commit --- 01_exit/exit.s | 7 +++++++ 01_exit/makefile | 12 ++++++++++++ 02_hello/hello.s | 23 +++++++++++++++++++++++ 02_hello/makefile | 12 ++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 01_exit/exit.s create mode 100644 01_exit/makefile create mode 100644 02_hello/hello.s create mode 100644 02_hello/makefile diff --git a/01_exit/exit.s b/01_exit/exit.s new file mode 100644 index 0000000..18c8b20 --- /dev/null +++ b/01_exit/exit.s @@ -0,0 +1,7 @@ + .section .text + .global _start + + _start: + addi a0, zero, 0 + addi a7, zero, 93 + ecall diff --git a/01_exit/makefile b/01_exit/makefile new file mode 100644 index 0000000..a685760 --- /dev/null +++ b/01_exit/makefile @@ -0,0 +1,12 @@ + +build: + @as -o output.out ./*.s + @ld -o output output.out + +run: + $(MAKE) build + @./output $(EXEC) + $(MAKE) clear + +clear: + @rm -rf ./*.out output diff --git a/02_hello/hello.s b/02_hello/hello.s new file mode 100644 index 0000000..659ce42 --- /dev/null +++ b/02_hello/hello.s @@ -0,0 +1,23 @@ + .equ STDOUT , 0 + .equ EXIT_SUCCESS, 0 + .equ WRITE , 64 + .equ EXIT , 93 + + .section .data + msg: .ascii "Hello World!\n" + + .section .text + .global _start + + _start: + # WRITE + addi a0, zero, STDOUT # STDOUT value + la a1, msg # Load message + addi a2, zero, 13 # Message size + addi a7, zero, WRITE # Write syscall + ecall # Sycall execution + + # EXIT + addi a0, zero, EXIT_SUCCESS # Return value + addi a7, zero, EXIT # Exit syscall + ecall # Syscall execution diff --git a/02_hello/makefile b/02_hello/makefile new file mode 100644 index 0000000..a685760 --- /dev/null +++ b/02_hello/makefile @@ -0,0 +1,12 @@ + +build: + @as -o output.out ./*.s + @ld -o output output.out + +run: + $(MAKE) build + @./output $(EXEC) + $(MAKE) clear + +clear: + @rm -rf ./*.out output