Better format.
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
.data
|
||||
file_buff: .space 8 # A space of 2 bytes
|
||||
.align 3
|
||||
input_file_name: .asciiz "a.in"
|
||||
.align 3
|
||||
output_file_name: .asciiz "a.out"
|
||||
.align 3
|
||||
.text
|
||||
.data
|
||||
file_buff: .space 8 # A space of 2 bytes
|
||||
.align 3
|
||||
input_file_name: .asciiz "a.in"
|
||||
.align 3
|
||||
output_file_name: .asciiz "a.out"
|
||||
.align 3
|
||||
.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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
li $v0, 5 # read integer
|
||||
syscall
|
||||
addi $a0, $v0, 10 # a0 = v0 + 10
|
||||
li $v0, 1 # print integer
|
||||
syscall
|
||||
|
||||
Reference in New Issue
Block a user