Article ID: 49395
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 Professional Development System 7.0
- Microsoft BASIC Professional Development System 7.1
- Microsoft BASIC Compiler 6.0
- Microsoft BASIC Compiler 6.0b
This article was previously published under Q49395
SUMMARY
The two programs below demonstrate how a Microsoft Basic program passes standard numeric types to assembly language by value.
MORE INFORMATION
For more information about passing other types of parameters between Basic and MASM, search in the Microsoft Knowledge Base using the following word:
BAS2MASM
Code Example
The following Basic program is BNUMVAL.BAS, which passes two standard numeric types to assembly language by value:
DECLARE SUB ValInt(BYVAL i%) DECLARE SUB ValLong(BYVAL l&) i% = ASC("A") l& = ASC("B") * 65536 + ASC("C") CLS CALL ValInt(i%) CALL ValLong(l&) END
The following program is ANUMVAL.ASM, which gets two standard numeric types by value and prints them out:
; The following handy .MODEL MEDIUM,Basic directive is found in MASM ; 5.10 but not in earlier versions: .MODEL MEDIUM, Basic .CODE PUBLIC ValInt, ValLong ValInt PROC push bp mov bp, sp ; set stack frame mov dx, [bp+6] ; get integer mov ah, 02 ; DOS interrupt to print character int 21h pop bp ret 2 ValInt ENDP ValLong PROC push bp mov bp, sp ; set stack frame mov dx, [bp+6] ; get first part of long mov ah, 02 ; DOS interrupt to print character int 21h mov dx, [bp+8] ; get second part of long int 21h ; print it pop bp ret 4 ValLong ENDP END
To demonstrate these programs from an .EXE program, compile and link as follows:
BC BNUMVAL.BAS;
MASM ANUMVAL.ASM;
LINK BNUMVAL ANUMVAL;
BNUMVAL.EXE produces the following output:
ABC
Additional query words: QuickBas BasicCom
Keywords: KB49395