Đang chuẩn bị liên kết để tải về tài liệu:
linux assembly language programming PHẦN 8
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
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 9.3 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 unistd.h. In Linux 2.0 write is system call number 4.T0 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 unistd.h. According to the conventions used in Linux 2.2 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 9.4 illustrates this. In debugging system calls the strace utility is invaluable. For example after getting an a.out from gcc from for Program 9.4 we could use linuxbox strace a.out to check on things in the event of difficulty. Program 9.4 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