From 9ab2fe967dceab9b8015e26b42a00bfde8432846 Mon Sep 17 00:00:00 2001 From: unlockable Date: Thu, 2 May 2024 21:54:26 +0800 Subject: [PATCH] 1.1 --- 1/homework/exp1/a.in | Bin 0 -> 8 bytes 1/homework/exp1/a.out | Bin 0 -> 8 bytes 1/homework/exp1/exp1_1.asm | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 1/homework/exp1/a.in create mode 100644 1/homework/exp1/a.out create mode 100644 1/homework/exp1/exp1_1.asm diff --git a/1/homework/exp1/a.in b/1/homework/exp1/a.in new file mode 100644 index 0000000000000000000000000000000000000000..6f363cafee10987d6044d3f321d5521858979b7c GIT binary patch literal 8 NcmZQ%U|`?^VgLX*01N;C literal 0 HcmV?d00001 diff --git a/1/homework/exp1/a.out b/1/homework/exp1/a.out new file mode 100644 index 0000000000000000000000000000000000000000..6f363cafee10987d6044d3f321d5521858979b7c GIT binary patch literal 8 NcmZQ%U|`?^VgLX*01N;C literal 0 HcmV?d00001 diff --git a/1/homework/exp1/exp1_1.asm b/1/homework/exp1/exp1_1.asm new file mode 100644 index 0000000..4073168 --- /dev/null +++ b/1/homework/exp1/exp1_1.asm @@ -0,0 +1,41 @@ +.data +file_buff: .space 8 # A space of 2 bytes +input_file_name: .asciiz "a.in" +.align 2 +output_file_name: .asciiz "a.out" +.align 2 +.text + +la $a0, input_file_name +li $a1, 0 # set mode as read +li $a2, 0 # meaning nothing, really +li $v0, 13 # open file +syscall #now $v0 is the file handler + +move $a0, $v0 #move file handler to a0 as first syscall arg +la $a1, file_buff +li $a2, 8 # read in 8 bytes +li $v0, 14 +syscall +li $v0, 16 +syscall # close file + +la $a0, output_file_name +li $a1, 1 # set mode as write +li $a2, 0 # meaning nothing, really +li $v0, 13 # open file +syscall + +move $a0, $v0 +la $a1, file_buff +li $a2, 8 # write 8 bytes +li $v0, 15 # write file +syscall +li $v0, 16 +syscall + +li $v0 5 # read integer +syscall +addi $a0, $v0, 10 # a0 = v0 + 10 +li $v0 1 # print integer +syscall