-
Notifications
You must be signed in to change notification settings - Fork 12
/
hello.s
32 lines (23 loc) · 812 Bytes
/
hello.s
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
32
.section .text
.globl _start
_start:
li a0, 1 # stdout
# la a0, msg # load address (pseudo instruction)
# # i.e. PC relative
# alternatively:
#1: auipc a1, %pcrel_hi(msg)
# addi a1, a1, %pcrel_lo(1b)
# alternatively (absolute/position dependent):
lui a1, %hi(msg)
addi a1, a1, %lo(msg)
li a2, 12 # string length
li a7, 64 # _NR_sys_write
ecall # invoke system call
li a0, 0 # exit status
li a7, 93 # _NR_sys_exit
ecall # invoke system call
.Loop:
j .Loop # in case exit syscall fails ...
.section .rodata
msg:
.string "Hello World\n"