由于像'li $ v0,4'这样的函数已经告诉程序打印字符串,所以为什么需要syscall?
syscall
allows you to access the system library. The instruction that you point out, li $v0,4
is simply used to request that syscall
perform the relevant operation.
This is a very common programming pattern. Rather than allow direct access to the physical devices, the kernel, operating at the highest privilege level, brokers access to the devices through syscall
, int 0x80
, sysenter
or whichever mechanism is used for the architecture and operating system that you are working under. This helps the system to be more stable overall.
While you don't state what your actual platform/OS is, an example set of standard system calls for MIPS can be found here . If you look at it, you'll see that it allows for a number of operations with devices to which you otherwise would not have access:
A platform may have as many or as few system library functions as are deemed necessary by the designers. You will find that this is true of Windows, Linux, BSD, Solaris, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.