Microsoft KB Archive/64429

= Example of Assembly Function Returning Integer to Basic =

Article ID: 64429

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q64429



SUMMARY
The two programs below demonstrate how an assembly language function can return an integer to a Microsoft Basic program.



MORE INFORMATION
For more information about passing other types of parameters between Basic and MASM, query in the Microsoft Knowledge Base using the following word:

BAS2MASM

Code Example
The following Basic program is IFUNC.BAS, which displays an integer returned from an assembly language function: DECLARE FUNCTION QPrint% FOR i% = 1 to 5 PRINT QPrint% NEXT The following assembly language program is AINT.ASM, which contains the QPrint function. The Qprint function returns an integer. .MODEL MEDIUM, Basic .DATA shortnum dw 12345

.CODE PUBLIC QPrint QPrint PROC mov ax, shortnum   ; return value in ax register ret QPrint ENDP END To demonstrate these programs from an .EXE program, compile and link as follows:

BC IFUNC.BAS;

MASM AINT.ASM;

LINK IFUNC AINT;

IFUNC.EXE produces the following output:

12345

12345

12345

12345

12345

Additional query words: QuickBas BasicCom

Keywords: KB64429

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.