-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello-world.asm
More file actions
31 lines (23 loc) · 756 Bytes
/
hello-world.asm
File metadata and controls
31 lines (23 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# hello-world.asm
# Written by: Gabriel Bauer
# Date: 06/02/2023
.globl main # make main global
.data # Data section
hello: .asciz "Hello, world!" # string declaration
.text # Executable section
main:
# System Call #64: Write to a file descriptor
# Requires: a0 (file descriptor), a1 (buffer from which to read, and finally a2 (buffer length)
# In this case, setting a0 to 1 means that we are referencing stdout
li a0, 1 # li means Load Immediate
la a1, hello # la means Load Address
li a2, 13
li a7, 64
ecall
# System Call #93: Exit command
# Requires: a0 (exit code)
# If we have made it this far, our program has successfully executed without a problem,
# so we can just return an error code 0
li a0, 0
li a7, 93
ecall