Microsoft KB Archive/49382

From BetaArchive Wiki
Knowledge Base


Article ID: 49382

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 Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1



This article was previously published under Q49382

SUMMARY

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

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 BSTRF.BAS, which passes a string descriptor (of a variable-length string) to assembly language by far reference:

    A$ = "This is the String" + "$"    ' "$" terminates the string for
                                      ' INT call
   CALLS RString(A$)   ' CALLS passes far address
   END
                

The following program is ASTRF.ASM, which gets a Basic string descriptor, then prints the string:

; The following handy .MODEL directive is found in MASM 5.10 but not
; in earlier versions:
.MODEL MEDIUM, Basic
.CODE
        PUBLIC RString
RString PROC
        push bp
        mov bp, sp       ; set stack frame
        push ds
        mov ds, [bp+8]   ; segment of descriptor
        mov bx, [bp+6]   ; offset of descriptor
        mov dx, [bx+2]   ; address of actual string
        mov ah, 9        ; DOS interrupt to print string
        int 21h
        pop ds
        pop bp
        ret 4
RString ENDP
        END
                

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

BC BSTRF.BAS;
MASM ASTRF.ASM;
LINK BSTRF ASTRF;


BSTRF.EXE produces the following output:

This is the string


Additional query words: QuickBas BasicCom

Keywords: KB49382