Microsoft KB Archive/49401

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Article ID: 49401

Article Last Modified on 10/20/2003



APPLIES TO

  • Microsoft BASIC Professional Development System 7.1
  • Microsoft BASIC Professional Development System 7.0



This article was previously published under Q49401

SUMMARY

The two programs shown below demonstrate how a Microsoft Basic program can pass an array of double-precision variables to assembly language.

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 BDBL.BAS, which passes an uninitialized array of double precision numbers to an assembly routine that initializes the array:

  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:

; The following handy .MODEL MEDIUM,Basic directive is found in MASM
; 5.10 but not in earlier versions:
.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                  ; Preserve (push) es, di, si
        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                   ; Restore (pop) si, di, es
        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



Additional query words: QuickBas BasicCom

Keywords: KB49401