1 6bf04703 2024-04-05 benni .section .rodata
2 6bf04703 2024-04-05 benni fmt: .asciz "Hello World\n"
3 6bf04703 2024-04-05 benni ifmt: .asciz "%d\n"
5 6bf04703 2024-04-05 benni .section .data
6 6bf04703 2024-04-05 benni arr: .dword 1, 2, 3, 4, 5
8 6bf04703 2024-04-05 benni .section .text
9 6bf04703 2024-04-05 benni .global main
11 6bf04703 2024-04-05 benni addi sp, sp, -16
12 6bf04703 2024-04-05 benni sd s0, 8(sp)
13 6bf04703 2024-04-05 benni sd ra, 0(sp)
17 6bf04703 2024-04-05 benni jal printarr
24 6bf04703 2024-04-05 benni jal printarr
38 6bf04703 2024-04-05 benni mv a0, zero
39 6bf04703 2024-04-05 benni ld ra, 0(sp)
40 6bf04703 2024-04-05 benni ld s0, 8(sp)
41 6bf04703 2024-04-05 benni addi sp, sp, 16
44 6bf04703 2024-04-05 benni // void hello (void);
49 6bf04703 2024-04-05 benni // void nl (void);
54 6bf04703 2024-04-05 benni // void print (int);
56 6bf04703 2024-04-05 benni addi sp, sp, -8
57 6bf04703 2024-04-05 benni sd ra, 0(sp)
60 6bf04703 2024-04-05 benni la a0, ifmt
63 6bf04703 2024-04-05 benni ld ra, 0(sp)
64 6bf04703 2024-04-05 benni addi sp, sp, 8
67 6bf04703 2024-04-05 benni // void printarr (void);
69 6bf04703 2024-04-05 benni addi sp, sp, -32
70 6bf04703 2024-04-05 benni sd ra, 16(sp)
71 6bf04703 2024-04-05 benni sd s0, 8(sp)
72 6bf04703 2024-04-05 benni sd s1, 0(sp)
75 6bf04703 2024-04-05 benni mv s1, zero
78 6bf04703 2024-04-05 benni add a0, s0, s1
79 6bf04703 2024-04-05 benni ld a0, 0(a0)
82 6bf04703 2024-04-05 benni addi s1, s1, 8
83 6bf04703 2024-04-05 benni li t0, (5 * 8)
84 6bf04703 2024-04-05 benni bne s1, t0, ploop
87 6bf04703 2024-04-05 benni ld s1, 0(sp)
88 6bf04703 2024-04-05 benni ld s0, 8(sp)
89 6bf04703 2024-04-05 benni ld ra, 16(sp)
90 6bf04703 2024-04-05 benni addi sp, sp, 32
93 6bf04703 2024-04-05 benni // void swap (long *v, size_t n);
95 6bf04703 2024-04-05 benni slli a1, a1, 3
96 6bf04703 2024-04-05 benni add t0, a0, a1
97 6bf04703 2024-04-05 benni ld t1, 0(t0)
98 6bf04703 2024-04-05 benni ld t2, 8(t0)
99 6bf04703 2024-04-05 benni sd t2, 0(t0)
100 6bf04703 2024-04-05 benni sd t1, 8(t0)
103 6bf04703 2024-04-05 benni // long avg(long *v, size_t n);
105 6bf04703 2024-04-05 benni slli a1, a1, 3
106 6bf04703 2024-04-05 benni add a0, a0, a1
107 6bf04703 2024-04-05 benni ld t0, 0(a0)
108 6bf04703 2024-04-05 benni ld t1, 8(a0)
109 6bf04703 2024-04-05 benni add a0, t0, t1
110 6bf04703 2024-04-05 benni srli a0, a0, 1
113 6bf04703 2024-04-05 benni // bool even(long);
115 6bf04703 2024-04-05 benni andi a0, a0, 1
116 6bf04703 2024-04-05 benni xor a0, a0, 1