KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q57363: How to Pass a Variable Length String from BASIC to MASM

Article: Q57363
Product(s): See article
Version(s): 7.00   | 7.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | SR# S891017-100 | mspl13_basic
Last Modified: 17-JAN-1990

The example below demonstrates how to pass a variable-length string
from a compiled BASIC program to a MASM procedure. This information
applies to Microsoft BASIC Professional Development System (PDS)
Version 7.00 for MS-DOS and MS OS/2.

BASIC to MASM Example
---------------------

Compile and link as follows:

Compile: BC /Fs/d basmasm.bas;
         MASM masmtest;
Link:    LINK basmasm+masmtest,,,BRT70EFR;

REM ==BASIC to MASM code===
DEFINT A-Z
DECLARE SUB printmessage (BYVAL segm, BYVAL offs)
CLS
a$ = "Assembly test successful" + "$"
CALL printmessage(SSEG(a$), SADD(a$))
LOCATE 10, 10
PRINT "Back from assembly"
END

;MASM code here
                    .Model    Medium,basic
                    .stack
                    .code
                    public    printmessage
printmessage        proc      uses ds,segm,offs
                    mov       ax,segm
                    mov       ds,ax
                    mov       dx,offs
                    mov       ah,9
                    int       21h
                    ret
printmessage        endp
                    end

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.