Microsoft KB Archive/49390

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: 49390

Article Last Modified on 10/20/2003



APPLIES TO

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



This article was previously published under Q49390

SUMMARY

The two programs shown below demonstrate how Microsoft assembly language can pass common numeric types to Basic subprograms.

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 BNUM.BAS, which contains subprograms that receive common numeric types passed from assembly language:

  DECLARE SUB AssemSub(dummy AS INTEGER)

   CALL AssemSub(dummy%)
   END

   SUB NumInt(i AS INTEGER)
      PRINT "Integer : "; i
   END SUB

   SUB NumLong(l AS LONG)
      PRINT "Long    : "; l
   END SUB

   SUB NumSingle(s AS SINGLE)
      PRINT "Single  : "; s
   END SUB

   SUB NumDouble(d AS DOUBLE)
      PRINT "Double  : "; d
   END SUB
                

The following program is ANUM.ASM, which passes common numeric types to Basic subprograms:

; The following handy .MODEL MEDIUM,Basic directive is found in MASM
; 5.10 but not in earlier versions:
.MODEL MEDIUM, Basic
EXTRN NumInt:PROC        ; declare Basic procedures
EXTRN NumLong:PROC
EXTRN NumSingle:PROC
EXTRN NumDouble:PROC
.DATA
  intnum    DW 32767              ; initialize data
  Longnum   DD 37999
  Singlenum DD 123.45
  Doublenum DQ 1234.14159
.CODE
         PUBLIC AssemSub
AssemSub PROC
         push bp
         mov bp, sp

         mov ax, OFFSET intnum    ; get address of integer
         push ax
         call NumInt

         mov ax, OFFSET Longnum   ; get address of long
         push ax
         call NumLong

         mov ax, OFFSET Singlenum ; get address of single
         push ax
         call NumSingle

         mov ax, OFFSET Doublenum ; get address of double
         push ax
         call NumDouble

         pop bp
         ret 2
AssemSub ENDP
         END
                

To demonstrate these programs from an .EXE program, compile and link as follows:

BC BNUM.BAS;
MASM ANUM.ASM;
LINK BNUM ANUM;


BNUM.EXE produces the following output:

Integer : 32767
Long : 37999
Single : 123.45
Double : 1234.14159



Additional query words: QuickBas BasicCom

Keywords: KB49390