Files
AssemblyHomework/1/example/example_0.asm
2024-05-02 21:49:44 +08:00

59 lines
1.3 KiB
NASM
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.data
in_buff: .space 512
out_buff: .space 512
input_file: .asciiz "example.in"
output_file: .asciiz "example.out"
comma: .asciiz ", "
.text
la $a0, input_file #input_file
li $a1, 0 #flag 0 1
li $a2, 0 #mode is ignored 0
li $v0, 13 #13 syscall
syscall # $v0中
move $a0,$v0 # $a0中
la $a1, in_buff #in_buff
li $a2, 512 #512byte
li $v0, 14 #14 syscall
syscall
li $v0 16 #16 syscall
syscall
#N
la $s0, in_buff
la $s1, out_buff
lw $s2, 0($s0)
li $t0, 0
#4 1
for: addi $s0, $s0, 4
addi $t0, $t0, 1
lw $t1, 0($s0)
sw $t1, 0($s1)
addi $s1, $s1, 4
#
move $a0, $t1
li $v0, 1
syscall
#
la $a0, comma
li $v0, 4
syscall
bne $t0 $s2 for
la $a0, output_file #output_file
li $a1, 1 #flag 0 1
li $a2, 0 #mode is ignored 0
li $v0, 13 #13 syscall
syscall # $v0中
move $a0,$v0 # $a0中
la $a1, out_buff #in_buff
sll $s2 $s2 2
move $a2, $s2 #512byte
li $v0, 15 #15 syscall
syscall
#$a0
# syscall 16
li $v0 16 #16 syscall
syscall