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 Q49401
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Example of Passing Array of Doubles from Basic to MASM - Q49401
The two programs shown below demonstrate how a Microsoft Basic program
can pass an array of double-precision variables to assembly language.
More Information:
The following Basic program is BDBL.BAS, which passes an uninitialized
array of double precision numbers to an assembly routine that
initializes the array.
Code Example
------------
DECLARE SUB FillDbl(BYVAL ASeg AS INTEGER, BYVAL AOff AS INTEGER)
DIM DblArray(1 TO 5) AS DOUBLE
CALL FillDbl(VARSEG(DblArray(1)), VARPTR(DblArray(1)))
FOR i% = 1 TO 5
PRINT DblArray(i%)
NEXT
END
The following program is ADBL.ASM, which initializes an array of
double-precision numbers passed from Basic:
.MODEL MEDIUM, BASIC
.DATA
Dbl1 DQ 123.45 ; Initialize data table.
Dbl2 DQ 456.78
Dbl3 DQ 98765.432
Dbl4 DQ 12345.678
Dbl5 DQ 777.888
.CODE
PUBLIC FillDbl
FillDbl PROC
push bp
mov bp, sp ; Set stack frame.
push es
push di
push si
mov es, [bp+8] ; Segment of array.
mov di, [bp+6] ; Offset of array.
mov si, OFFSET Dbl1 ; Get offset of data table.
mov cx, 40 ; Length of data in table.
rep movsb ; Copy data table to array.
pop si
pop di
pop es
pop bp
ret 4
FillDbl ENDP
END
To demonstrate these programs from an .EXE program, compile and link
as follows:
BC BDBL.BAS;
MASM ADBL.ASM;
LINK BDBL ATWODBL;
BDBL.EXE produces the following output:
123.45
456.78
98765.432
12345.678
777.888