vbdpss.hlp (Table of Contents; Topic list)
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 Q49398
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Example of Passing Basic Two-Dimensional Integer Array to MASM - Q49398
 
 The two programs shown below demonstrate how a Microsoft Basic program
 can pass a two-dimensional integer array to assembly language.
 
 More Information:
 
 The following Basic program is BTWODIMI.BAS, which passes an
 uninitialized two-dimensional integer array to an assembly routine
 that initializes the array.
 
 Code Example
 ------------
 
 DECLARE SUB TwoInt(BYVAL ASeg AS INTEGER, BYVAL AOff AS INTEGER)
 
 DIM IntArray(1 TO 2, 1 TO 3) AS INTEGER
 
 CALL TwoInt(VARSEG(IntArray(1, 1)), VARPTR(IntArray(1, 1)))
 FOR row% = 1 TO 2
    FOR col% = 1 TO 3
       PRINT IntArray(row%, col%)
    NEXT
 NEXT
 END
 
 The following program is ATWODIMI.ASM, which initializes a
 two-dimensional integer array passed from Basic:
 
 .MODEL MEDIUM, BASIC
 .DATA
         i11 DW 11           ; Initialize data table.
         i21 DW 21
         i12 DW 12
         i22 DW 22
         i13 DW 13
         i23 DW 23
 .CODE
         PUBLIC TwoInt
 TwoInt  PROC
         push bp
         mov bp, sp          ; Set stack frame.
         push es
         push si
         push di
 
         mov es, [bp+8]      ; Segment of array.
         mov di, [bp+6]      ; Offset of array.
         mov si, OFFSET i11
         mov cx, 6           ; Number of items to copy.
         rep movsw           ; Copy data to array.
         pop di
         pop si
         pop es
         pop bp
         ret 4
 TwoInt  ENDP
         END
 
 To demonstrate these programs from an .EXE program, compile and link
 as follows:
 
    BC BTWODIMI.BAS;
    MASM ATWODIMI.ASM;
    LINK BTWODIMI ATWODIMI;
 
 BTWODIMI.EXE produces the following output:
 
 11
 12
 13
 21
 22
 23