ID Number: Q39309
5.10 | 5.10
MS-DOS | OS/2
Summary:
The 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. The C code is compiled in the large-memory model and the
MASM code is assembled with the /ML option.
More Information:
The following is the code:
#include <stdio.h>
int retval, value, foo;
extern int mixed(int);
main() {
value = 35;
foo = 25;
retval = 0;
retval = mixed(foo);
printf("%d\n%d\n",retval,value);
}
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
mov ds,ax
mov ax,SEG _value
mov es,ax
mov es:_value,10h
; return the passed variable
mov ax,[bp+6]
pop bp
ret
_mixed ENDP
END