Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Article Q49390
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Example of Passing Numerics from MASM to Basic -Q49390
The two programs shown below demonstrate how Microsoft assembly
language can pass common numeric types to Basic subprograms.
More Information:
The following Basic program is BNUM.BAS, which contains subprograms
that receive common numeric types passed from assembly language:
Code Example
------------
DECLARE SUB AssemSub(dummy AS INTEGER)
CALL AssemSub(dummy%)
END
SUB NumInt(i AS INTEGER)
PRINT "Integer : "; i
END SUB
SUB NumLong(lng AS LONG)
PRINT "Long : "; lng
END SUB
SUB NumSingle(s AS SINGLE)
PRINT "Single : "; s
END SUB
SUB NumDouble(d AS DOUBLE)
PRINT "Double : "; d
END SUB
The following program is ANUM.ASM, which passes common numeric types
to Basic subprograms:
.MODEL MEDIUM, BASIC
EXTRN NumInt:PROC ; Declare Basic procedures.
EXTRN NumLong:PROC
EXTRN NumSingle:PROC
EXTRN NumDouble:PROC
.DATA
intnum dw 32767 ; Initialize data.
Longnum dd 37999
Singlenum dd 123.45
Doublenum dq 1234.14159
.CODE
PUBLIC AssemSub
AssemSub PROC
push bp
mov bp, sp
mov ax, OFFSET intnum ; Get address of integer.
push ax
call NumInt
mov ax, OFFSET Longnum ; Get address of long.
push ax
call NumLong
mov ax, OFFSET Singlenum ; Get address of single.
push ax
call NumSingle
mov ax, OFFSET Doublenum ; Get address of double.
push ax
call NumDouble
pop bp
ret 2
AssemSub ENDP
END
To demonstrate these programs from an .EXE program, compile and link
as follows:
BC BNUM.BAS;
MASM ANUM.ASM;
LINK BNUM ANUM;
BNUM.EXE produces the following output:
Integer : 32767
Long : 37999
Single : 123.45
Double : 1234.14159