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 Q49394
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Example of Passing User-Defined Type from MASM to Basic - Q49394
The two programs below demonstrate how Microsoft assembly language can
pass a user-defined type to Basic.
More Information:
The following Basic program is BUTYPE.BAS, which receives a
user-defined type from an assembly language program and prints it out.
Code Example
------------
DEFINT A-Z
DECLARE SUB MasmSub
TYPE mixed
i AS INTEGER
lng AS LONG
s AS SINGLE
d AS DOUBLE
fx AS STRING * 19
END TYPE
DIM dummy AS mixed
CLS
PRINT "Calling assembly routine which will fill the";
PRINT " user-defined type."
CALL MasmSub
END
SUB BASICSub (dummy AS mixed)
PRINT "Values in user-defined type:"
PRINT
PRINT "Integer: ", dummy.i
PRINT "Long: ", dummy.lng
PRINT "Single: ", dummy.s
PRINT "Double: ", dummy.d
PRINT "fixed-length String: ", dummy.fx
END SUB
The following program is AUTYPE.ASM, which builds a user-defined type
and passes it to Basic:
.MODEL MEDIUM
usrdefType STRUC
iAsm DW 10
lAsm DD 43210
sAsm DD 32.10
dAsm DQ 12345.67
fxAsm DB 'Fixed-length string'
usrdefType ENDS
EXTRN BASICSub:PROC
.DATA
BASICRec usrdefType <>
.CODE
PUBLIC MasmSub
MasmSub PROC ; No stack frame is needed
; because no arguments are
; passed to assembly.
mov ax, OFFSET BASICRec ; Get address of structure.
push ax ; Pass it as argument to Basic.
CALL BASICSUb
ret
MasmSub ENDP
END
To demonstrate these programs from an .EXE program, compile and link
as follows:
BC BUTYPE.BAS;
MASM AUTYPE.ASM;
LINK BUTYPE AUTYPE;
BUTYPE.EXE produces the following output:
Integer: 10
Long: 43210
Single: 32.1
Double: 12345.67
fixed-length String: Fixed-length string