首页 > 解决方案 > 在 MIPS 中读取文件

问题描述

我是 MIPS 的完整初学者,我试图理解一段关于打开文件、保存文件然后关闭文件的代码。

#open file
    li $v0, 13
        la $a0, fname       #file name 
        li $a1, 1           #flags: 1-write file
        li $a2, 0           #mode: ignored
        syscall
    move $s1, $v0      # save the file descriptor

#check for errors - if the file was opened
#...

#save file
    li $v0, 15
    move $a0, $s1
    la $a1, image
    li $a2, BMP_FILE_SIZE
    syscall

#close file
    li $v0, 16
    move $a0, $s1
        syscall

除了“保存文件描述符部分”之外,我了解所有内容。谁能解释什么是文件描述符以及我们为什么在这里使用它?我不明白的说明:

  1. 移动 $s1, $v0
  2. 移动 $a0, $s1
  3. 移动 $a0, $s1

标签: assemblymipsfile-descriptor

解决方案


推荐阅读