Example of C Calling a MASM ProcedureLast reviewed: July 17, 1997Article ID: Q39309 |
5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a | 1.00 1.50
MS-DOS | OS/2 | WINDOWSkbprg
The information in this article applies to:
SUMMARYThe sample code below demonstrates a C program calling a MASM procedure. The C code declares an integer and passes the integer to the MASM procedure called mixed(). The mixed() function has an integer return value.
MORE INFORMATION
Sample Code 1
/* Code for the calling C function. * * Compile options needed: /c /AL */ #include <stdio.h> int retval, value, myvar;extern int mixed( int ); main() { value = 35; myvar = 25; retval = 0; retval = mixed( myvar ); printf( "%d\n%d\n", retval, value );}
Sample Code 2; Code for the called assembly procedure ; ; Assemble options needed: /c /Cx (MASM 6.0 and later) ; /Mx (MASM 5.10 and eariler)DOSSEG .MODEL LARGE, C .STACK 100h .DATA Dw 0.FARDATA EXTRN value:WORD.CODE PUBLIC mixed mixed PROC push bp mov bp,sp ; access and change value mov ax, SEG _DATA push ds mov ds, ax mov ax, SEG value mov es, ax mov es:value, 10h ; return the passed variable mov ax, [bp+6] pop ds pop bp ret mixed ENDPEND
|
Additional reference words: kbinf 1.00 1.50 5.10 6.00 6.00a 6.00ax 7.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |