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
|
.global _start, source_code
.equ SYS_READ, 63
.equ SYS_WRITE, 64
.equ SYS_EXIT, 93
.equ STDIN, 0
.equ STDOUT, 1
.equ STDERR, 2
.equ SOURCE_BUFFER_SIZE, 2048
.section .bss
.type source_code, @object
.size source_code, SOURCE_BUFFER_SIZE
source_code: .zero SOURCE_BUFFER_SIZE
.section .text
_start:
# Read the source from the standard input.
la a0, source_code
li a1, SOURCE_BUFFER_SIZE # Buffer size.
call read_file
# Write the source to the standard output.
mv a1, a0
la a0, source_code
call write_out
# Call exit.
li a0, 0 # Use 0 return code.
call exit
|