Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'software solution for engineers and scientist episode 11', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 874 Appendix D high addresses low addresses X X Argument 2 int type - BP 6 Argument 1 int type - BP 4 NEAR Return Address BP 2 Saved BP BP Figure AD.2 C Stack Frame Example Return Values in Microsoft C Compilers In the Microsoft implementations of C for the PC parameters are returned to the calling routine in the AX register or in the AX and the DX registers. Table AD.2 shows the Microsoft language conventions for returning values. Table AD.2 Microsoft C Returned Values DATA TYPE OR POINTER REGISTER OR REGISTER PAIR Char short int unsigned char unsigned short unsigned int AX Long DX high-order word unsigned long AX low-order word struc or union float or double AX address value near pointer AX offset value of address far pointer DX segment value of address AX offset value of address Multiple File Programs 875 Another way of interchanging values between the C and assembly language code is to access the C variables by name as demonstrated in the previous example . This method requires that the assembly code use the same storage format as the C source. Since variable storage formats change in different implementations of C this access technique must be adapted to each particular implementation of the language. AD.4.2 Borland C to Assembly Interface The following example coded in Borland C and in x86 assembly language also implements a C to assembly language interface. The C code can be compiled using Borland C Version 3.1 and later. The assembler code is crated using either Borland s TASM or Microsoft MASM. The example consists of passing a structure to an assembly language source. The call is made using the FAR access type and the address of the structure is a FAR reference. Program name TEST1.CPP Other files Project ASMTEST.PRJ in C BORLANDC Assembly Source File CCALLS.OBJ in C BORLANDC include iostream.h include string.h extern C int SETSTR struct pix_params t Passing a structure by reference __ structure tag name Procedure name _SETSTR in assembler source file .