Microsoft KB Archive/49394

= Example of Passing User-Defined Type from MASM to Basic =

Article ID: 49394

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBASIC 4.0b, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 4.5 for MS-DOS, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q49394



SUMMARY
The two programs below demonstrate how Microsoft assembly language can pass a user-defined type to Basic.

This information about interlanguage calling applies to QuickBasic versions 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2 and to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2.



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 BUTYPE.BAS, which receives a user-defined type from an assembly language program and prints it out: DEFINT A-Z DECLARE SUB MasmSub TYPE mixed i AS INTEGER l AS LONG s AS SINGLE d AS DOUBLE fx AS STRING * 19 END TYPE DIM dummy AS mixed CLS PRINT &quot;Calling assembly routine which will fill the&quot;; PRINT &quot; user-defined type.&quot; CALL MasmSub END

SUB BasicSub (dummy AS mixed) PRINT &quot;Values in user-defined type:&quot; PRINT PRINT &quot;Integer: &quot;, dummy.i  PRINT &quot;Long: &quot;, dummy.l   PRINT &quot;Single: &quot;, dummy.s   PRINT &quot;Double: &quot;, dummy.d   PRINT &quot;fixed-length String: &quot;, dummy.f 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.10 Double:   12345.67 fixed-length String: Fixed-length string

Additional query words: QuickBas BasicCom

Keywords: KB49394

-

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

© Microsoft Corporation. All rights reserved.