Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- newLine: .asciiz "\n"
- nameFile_input: .asciiz "D:\input.txt"
- nameFile_output: .asciiz "D:\output.txt"
- buffer_File: .space 1024
- endString: .byte '\0'
- Time1: .space 1024
- Time2: .space 1024
- nhuan: .asciiz"la nam nhuan"
- thuong: .asciiz"la nam thuong"
- day:.space 10
- mounth:.space 20
- year:.space 10
- #
- slash: .byte '/'
- .text
- main:
- #open a file for writing
- li $v0, 13 # system call for open file
- la $a0, nameFile_input # board file name
- li $a1, 0 # Open for reading
- li $a2, 0
- syscall # open a file (file descriptor returned in $v0)
- move $s6, $v0 # save the file descriptor
- #read from file
- li $v0, 14 # system call for read from file
- move $a0, $s6 # file descriptor
- la $a1, buffer_File # address of buffer to which to read
- li $a2, 1024 # hardcoded buffer length
- syscall
- # Close the file
- li $v0, 16 # system call for close file
- move $a0, $s6 # file descriptor to close
- syscall
- #
- la $a0,buffer_File
- la $a1,Time1
- jal load_buffer_to_Time1
- la $a0,buffer_File
- la $a1,Time2
- jal load_buffer_to_Time2
- li $v0,4
- la $a0,Time1
- syscall
- li $v0,4
- la $a0,Time2
- syscall
- #---------------------
- load_buffer_to_Time1: #void load_buffer_to_Time (char *buffer, char * Time1 ) ; $a0 = buffer , $a1 = Time1
- addi $sp,$sp,-8
- sw $ra,($sp)
- lb $t0,($a0)
- sb $t0,($a1)
- lb $t0,1($a0)
- sb $t0,1($a1)
- lb $t0,slash
- sb $t0,2($a1)
- lb $t0,3($a0)
- sb $t0,3($a1)
- lb $t0,4($a0)
- sb $t0,4($a1)
- lb $t0,slash
- sb $t0,5($a1)
- lb $t0,6($a0)
- sb $t0,6($a1)
- lb $t0,7($a0)
- sb $t0,7($a1)
- lb $t0,8($a0)
- sb $t0,8($a1)
- lb $t0,9($a0)
- sb $t0,9($a1)
- lb $t0,endString
- sb $t0,10($a1)
- lw $ra,($sp)
- addi $sp,$sp,8
- jr $ra
- load_buffer_to_Time2:
- addi $sp,$sp,-8
- sw $ra,($sp)
- lb $t0,12($a0)
- sb $t0,($a1)
- lb $t0,13($a0)
- sb $t0,1($a1)
- lb $t0,slash
- sb $t0,2($a1)
- lb $t0,15($a0)
- sb $t0,3($a1)
- lb $t0,16($a0)
- sb $t0,4($a1)
- lb $t0,slash
- sb $t0,5($a1)
- lb $t0,18($a0)
- sb $t0,6($a1)
- lb $t0,19($a0)
- sb $t0,7($a1)
- lb $t0,20($a0)
- sb $t0,8($a1)
- lb $t0,21($a0)
- sb $t0,9($a1)
- lb $t0,endString
- sb $t0,10($a1)
- lw $ra,($sp)
- addi $sp,$sp,8
- jr $ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement