call
IP ,
.
, . -, , - , - , .
far ptr
.
.
, , , .
NEAR, CALL - . FAR, CALL - CS, .
CALL IP. FAR, CALL CS.
CS.
IP, , CS: IP.
NEAR , :
CALL WORD PTR [ ]
;
CALL WORD PTR [ BX ] [ SI ]
;
CALL WORD PTR VARIABLE_NAE
CALL WORD PTR VARIABLE_NAME [ BX ];
CALL MEM_WORD
CALL WORD PTR ES: [ BX ] [ SI ]
;
FAR , , :
CALL DWORD PTR [ BX ]
CALL MEM_DWORD
CALL DWORD PTR SS: VARIABLE_NAME [ SI ]
CALL , . . .
. . CALL 2 4 , .
23.3. RET
(RETurn from procedure)
RET
RETN
RETF
ret , .
ret , (near), - retn, - . .
ret , far, retf, : .
.
|
|
: ret , call. ret - ret, retn, retf.
, . ret retn . retf . , ; ret . ret
23.4. .
void _cdecl: Func (int A,int B, int C, int D) {}
_cdecl - ( ,
-
- , ..
- ,
void _stdcall Func (int A,int B, int C, int D){}
-
-
-
void _fastcall Func (int A,int B, int C, int D){}
- stdcall, eax edx
_pascal:
-
-
-
23.5.
16- Windows, C C++: -16- AX,
-32- DX:AX,
- ST(0)
AX, BX, CX, DX, ES ; .
, ESI, EDI, EBP, DS SS
32- Windows, C++ :
- EAX,
- ST(0).
EAX, ECX, EDX ( EBX) ;
B .
.
CS, DS, ES SS . FS .
GS , .
, : 0 . . , ST(0) . EBX, ESI, EDI, EBP .
#include <stdio.h>
#include <stdlib.h>
extern "C" int _cdecl SubInt(int, int);
extern "C" int _cdecl SumAInt(int[], int,int*);
|
|
void Rnd_array (int ar[],int *n)
{//
int i,j;
printf("Enter dimension n \n");
scanf("%d",n);
for (i=0;i<*n;i++)
ar[i]=rand()%100;; }
void Print_array (int ar[],int n)
//
{ printf("Items array\n");
for (int i=0;i<n;i++)
printf("%5d",ar[i]);
printf("\n");}
void main()
{int x,y;
printf ("Enter 2 number");
scanf("%d%d",&x,&y);
int r=SubInt(x, y);
// y x
printf ("difference=%d\n",r);
int b[20],n,k;
Rnd_array(b, &n);
Print_array(b, n);
SumAInt(b,n,&k);
// &k,n,&b
printf ("summa=%d\n",k); }
.asm
.486
.model flat;
.data;
.code
Public _SubInt
_SubInt proc
; 4
push ebp;4
mov ebp,esp
mov eax,[ebp+8]; x
sub eax,[ebp+12]; y
pop ebp
ret
SubInt endp
Public _SumAInt
_ SumAInt proc
push ebp
mov ebp,esp
mov esi,[ebp+8];&array
mov ecx,[ebp+12];n
xor eax,eax
for1: add eax,[esi]
add esi,4
loop for1
mov edi,[ebp+16];&k
mov [edi],eax
pop ebp
ret
_SumAInt endp
end
MASM
1990-, , Borland TASM - x86 NASM MASM.
2000 , MASM 6.15 Visual C++ , .
Visual C++ 6.0, MASM, Visual C++.
Visual C++ 2005 64- MASM ( ml64.exe).
MASM, MASM .
MASM Win32, , NASM, FASM HLA.
MASM Win32. .
.
MASM invoke, API - . call, TASM, . :
Invoke <>, <1>, <2>, <3>
Hello World, .
.386.model flat, stdcall
option casemap:none
include \masm32\include\masm32.inc
include \masm32\include\kernel32.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\kernel32.lib
.code
start: print "Hello world"
exit
end start