SHARE
TWEET

Untitled

a guest Apr 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.    
  3.     newLine: .asciiz "\n"
  4.     nameFile_input: .asciiz "D:\input.txt"
  5.     nameFile_output: .asciiz "D:\output.txt"
  6.     buffer_File: .space 1024
  7.     endString: .byte '\0'
  8.     Time1: .space 1024
  9.     Time2: .space 1024
  10.     nhuan: .asciiz"la nam nhuan"
  11.     thuong: .asciiz"la nam thuong"
  12.     day:.space 10
  13.     mounth:.space 20
  14.     year:.space 10
  15. #
  16.     slash:  .byte   '/'
  17. .text
  18. main:
  19. #open a file for writing
  20.     li   $v0, 13       # system call for open file
  21.     la   $a0, nameFile_input      # board file name
  22.     li   $a1, 0        # Open for reading
  23.     li   $a2, 0
  24.     syscall            # open a file (file descriptor returned in $v0)
  25.     move $s6, $v0      # save the file descriptor
  26.  
  27. #read from file
  28.     li   $v0, 14       # system call for read from file
  29.     move $a0, $s6      # file descriptor
  30.     la   $a1, buffer_File   # address of buffer to which to read
  31.     li   $a2, 1024     # hardcoded buffer length
  32.     syscall
  33.  
  34. # Close the file
  35.     li   $v0, 16       # system call for close file
  36.     move $a0, $s6      # file descriptor to close
  37.     syscall
  38. #
  39.     la $a0,buffer_File
  40.     la $a1,Time1
  41.     jal load_buffer_to_Time1
  42.  
  43.     la $a0,buffer_File
  44.     la $a1,Time2
  45.     jal load_buffer_to_Time2
  46.  
  47.     li $v0,4
  48.     la $a0,Time1
  49.     syscall
  50.  
  51.     li $v0,4
  52.     la $a0,Time2
  53.     syscall
  54.  
  55.    
  56. #---------------------
  57. load_buffer_to_Time1:    #void load_buffer_to_Time (char *buffer, char * Time1 ) ; $a0 = buffer , $a1 = Time1
  58.     addi $sp,$sp,-8
  59.     sw $ra,($sp)
  60.  
  61.     lb $t0,($a0)
  62.     sb $t0,($a1)
  63.  
  64.     lb $t0,1($a0)
  65.     sb $t0,1($a1)
  66.    
  67.     lb $t0,slash
  68.     sb $t0,2($a1)
  69.  
  70.     lb $t0,3($a0)
  71.     sb $t0,3($a1)
  72.    
  73.     lb $t0,4($a0)
  74.     sb $t0,4($a1)
  75.    
  76.     lb $t0,slash
  77.     sb $t0,5($a1)
  78.  
  79.     lb $t0,6($a0)
  80.     sb $t0,6($a1)
  81.  
  82.     lb $t0,7($a0)
  83.     sb $t0,7($a1)
  84.  
  85.     lb $t0,8($a0)
  86.     sb $t0,8($a1)  
  87.  
  88.     lb $t0,9($a0)
  89.     sb $t0,9($a1)
  90.  
  91.     lb $t0,endString
  92.     sb $t0,10($a1)
  93.  
  94.     lw $ra,($sp)
  95.     addi $sp,$sp,8
  96.     jr $ra
  97.  
  98. load_buffer_to_Time2:
  99.     addi $sp,$sp,-8
  100.     sw $ra,($sp)
  101.    
  102.     lb $t0,12($a0)
  103.     sb $t0,($a1)
  104.  
  105.     lb $t0,13($a0)
  106.     sb $t0,1($a1)
  107.        
  108.     lb $t0,slash
  109.     sb $t0,2($a1)
  110.    
  111.     lb $t0,15($a0)
  112.     sb $t0,3($a1)
  113.  
  114.     lb $t0,16($a0)
  115.     sb $t0,4($a1)
  116.  
  117.     lb $t0,slash
  118.     sb $t0,5($a1)
  119.    
  120.     lb $t0,18($a0)
  121.     sb $t0,6($a1)
  122.    
  123.     lb $t0,19($a0)
  124.     sb $t0,7($a1)
  125.    
  126.     lb $t0,20($a0)
  127.     sb $t0,8($a1)  
  128.    
  129.     lb $t0,21($a0)
  130.     sb $t0,9($a1)
  131.    
  132.     lb $t0,endString
  133.     sb $t0,10($a1)
  134.  
  135.     lw $ra,($sp)
  136.     addi $sp,$sp,8
  137.     jr $ra
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top