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 Q49389
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Example Passing Fixed-Length String from Basic to MASM (Far) - Q49389
The two programs shown below demonstrate how Microsoft Basic passes a
fixed-length string to assembly language by far reference.
More Information:
The following Basic program is BFSTRF.BAS, which creates a
fixed-length string and passes it to assembly language to be printed.
Code Example
------------
DECLARE SUB RString(BYVAL ssg AS INTEGER, BYVAL soff AS INTEGER)
DIM a AS STRING * 20
CLS
a = "BASIC String$" ' "$" terminates string for assembly
CALL RString(VARSEG(a), VARPTR(a))
END
The following program is AFSTRF.ASM, which gets a fixed-length string
from Basic and prints it:
.MODEL MEDIUM, BASIC
.CODE
PUBLIC RString
RString PROC
push bp
mov bp, sp ; set stack frame
push ds
mov ds, [bp+8] ; segment of string
mov dx, [bp+6] ; offset of string
mov ah, 9 ; MS-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 BFSTRF.BAS;
MASM AFSTRF.ASM;
LINK BFSTRF AFSTRF;
BFSTRF.EXE produces the following output:
BASIC String