Microsoft KB Archive/49384

= Example of Passing Basic String Descriptor to MASM (Near) =

Article ID: 49384

Article Last Modified on 11/21/2006



This article was previously published under Q49384



SUMMARY
The two programs below demonstrate how a Microsoft Basic program passes a Basic string descriptor to assembly language by near reference.

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 BSTRN.BAS, which passes a string descriptor to assembly language by near reference: DECLARE SUB RString(A AS STRING) A$ = &quot;This is the String&quot; + &quot;$&quot; ' &quot;$&quot; terminates the string '    for INT call CALL RString(A$) END The following program is ASTRN.ASM, which gets a string descriptor from Basic by near reference and prints the string out: ; The following handy .MODEL MEDIUM,Basic directive is found in MASM .MODEL MEDIUM, Basic .CODE PUBLIC RString RString PROC push bp       mov bp, sp        mov bx, [bp+6]     ; get offset of string descriptor mov dx, [bx+2]    ; get address of string mov ah, 9         ; int call to print string int 21h pop bp
 * 5.10 but not in earlier versions:

ret 2 RString ENDP

END To demonstrate these programs from an .EXE program, compile and link as follows:

BC BSTRN.BAS;

MASM ASTRN.ASM;

LINK BSTRN ASTRN;

BSTRN.EXE produces the following output:

This is the string

Additional query words: QuickBas BasicCom

Keywords: KB49384

-

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

© Microsoft Corporation. All rights reserved.