tailieunhanh - linux assembly language programming PHẦN 8

Phạt cảnh cáo Các byteorder (3) chức năng có thể được thực hiện như các macro trên một số hệ thống. Linux hệ thống chạy trên các CPU bằng cách sử dụng các byte bigendian đặt hàng có thể cung cấp một macro đơn giản thay vào đó, bởi vì không có chuyển đổi của giá trị là cần thiết. | Program main char s Hello world n write l s 13 But despite appearances the write system call IS not an ordinary c function. Like all system calls in Linux it uses INT 8 0H to transfer control to the kernel. Each system call in Linux has a number. A list of these calls and their numbers can be found in usr src linux arch i-38 6 . In Linux write is system call number carry out this system call the number 4 must be stored in the EAX register before INT 8ŨH is called. In DOS many system calls are made using INT 21H. The number stored in the AH register determines which system call is being made. A list of most of these calls can be found in standard books on DOS. The book UndocumentedDOSVty Andrew Schulman et. al. attempts to list all of them. The existence of undocumented DOS system calls gave rise to considerable bitterness on the part of developers who could have put such functions to good use had they but known of them. Needless to say programmers at Microsoft did not encounter this obstacle. To use a system call from assembler it is necessary to know the parameter passing conventions. These conventions are established by macros also located in . According to the conventions used in Linux the parameters are stored in left to right order in the registers EBX ECX EDX EDI and ESI respectively using as many of these registers as are needed to store the parameters. Thesystemcall write 1 s 13 forexample canbecompletedifl3isstoredinEBX thestring pointer is stored in ECX and 1 is stored in EDX. Program illustrates this. In debugging system calls the strace utility is invaluable. For example after getting an from gcc from for Program we could use linuxbox strace to check on things in the event of difficulty. Program This program makes a system call. global main main ABC MOV MOV MOV MOV INT RET db Hello world 0AH 0 EAX EBX ECX EDX 8ŨH 4 1 ABC 13 Write is system call 4. 1 is number for standard output. ABC is the string

TỪ KHÓA LIÊN QUAN