Using System Calls
来源:互联网 发布:清华北大抢人 知乎 编辑:程序博客网 时间:2024/06/05 19:31
The Linux system calls are located at interrupt 0x80.
When the INT instruction is performed, all operations transfer to the system call handler in the kernel. When the system call is complete, execution
transfers back to the next instruction after the INT instruction (unless, of course, the exit system call is performed).
the EAX register is used to hold the system call value.
This value defines which system call is used from the list of system calls supported by the kernel.
movl $1, %eaxint 0x80
After placing the system call value in the EAX register,
the INT instruction is performed, using the vector value for the kernel system calls (0x80).
System call input values
The order in which the system calls expect input values is as follows:
. EBX (first parameter)
. ECX (second parameter)
. EDX (third parameter)
. ESI (fourth parameter)
. EDI (fifth parameter)
. EBX (first parameter)
. ECX (second parameter)
. EDX (third parameter)
. ESI (fourth parameter)
. EDI (fifth parameter)
System calls that require more than six input parameters use a different method of passing the parameters to the system call.
The EBX register is used to contain a pointer to the memory location of the input
parameters, stored in sequential order.
parameters, stored in sequential order.
The system call uses the pointer to access the memory location to read the parameters.
ssize_t write(int fd, const void *buf, size_t count);Using this convention, the input values would be assigned to the following registers:
❑ EBX: The integer file descriptor
❑ ECX: The pointer (memory address) of the string to display
❑ EDX: The size of the string to display
.section .dataoutput:.ascii “This is a test message.\n”output_end:.equ len, output_end - output.section .text.globl _start_start:movl $4, %eaxmovl $1, %ebxmovl $output, %ecxmovl $len, %edxint $0x80movl $1, %eaxmovl $0, %ebxint $0x80The file descriptor value for the output location is placed in the EBX. Linux systems contain three special
file descriptors:
❑ 0 (STDIN): The standard input for the terminal device (normally the keyboard)
❑ 1 (STDOUT): The standard output for the terminal device (normally the terminal screen)
❑ 2 (STDERR): The standard error output for the terminal device (normally the terminal screen)
阅读全文
0 0
- Using System Calls
- Kernel command using Linux system calls
- 8.1. System Calls
- Trace System Calls
- Linux System Calls
- Kernel System Calls
- Finding system calls
- [OS] Xv6 System Calls
- linux File-Handling System Calls
- Using RIL to hangup unwanted calls
- using System;
- using System;
- using System;
- using System;
- using System;
- using System;
- using System
- using System..................
- Java Web工作原理
- STL容器的删除元素问题
- HDU
- 待补充
- springcloud(二)
- Using System Calls
- solr-架构
- ありがとう
- 模型简单控制
- 如何在Linux上安装ftp组件
- C#中Math.Round()实现中国式四舍五入
- 符号常量
- Bluetooth MESH探究 --- (2) 协议栈架构
- java——内部类