[英]In MIPS Assembly why do we use syscall? Why doesn't the program operate on the instructions given automatically?
由于像'li $ v0,4'这样的函数已经告诉程序打印字符串,所以为什么需要syscall?
syscall
allows you to access the system library. syscall
允许您访问系统库。 The instruction that you point out, li $v0,4
is simply used to request that syscall
perform the relevant operation. 您指出的指令li $v0,4
仅用于请求syscall
执行相关操作。
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. 以最高特权级别运行的内核不是允许直接访问物理设备,而是通过syscall
, int 0x80
, sysenter
或您所使用的体系结构和操作系统所使用的任何机制来代理对设备的访问。 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 . 虽然您没有说明实际的平台/操作系统是什么,但是可以在此处找到 MIPS的一组标准系统调用示例。 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. 您会发现Windows,Linux,BSD,Solaris等都是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.