MASM Version 5.00 Mixed-Language Example with C

ID Number: Q40529

5.00

MS-DOS

Summary:

Below are the demonstration files CA.ASM and CAMAIN.C from the MASM

Version 5.00 Disk 1 mixed directory.

More Information:

The following is CA.ASM:

.MODEL SMALL

.CODE

PUBLIC _Power2

_Power2 PROC

push bp ;Entry sequence

mov bp,sp

mov ax,[bp+4] ; Load Arg1 into AX

mov cx,[bp+6] ; Load Arg2 into CX

shl ax,cl ; AX = AX * (2 to power of CX)

; Leave return value in AX

pop bp ; Exit sequence

ret

_Power2 ENDP

END

The following is CAMAIN.C:

extern int Power2(int,int);

main()

{

printf("3 times 2 to the power of 5 is %d\n", Power2(3,5));

}