Microsoft KB Archive/40528

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

MASM Version 5.00 Mixed-Language Example with BASIC ID Number: Q40528

5.00 MS-DOS

Summary:

Below are the demonstration files BA.ASM and BAMAIN.BAS from the MASM Version 5.00 Disk 1 mixed directory.

More Information:

The following is BA.ASM:

.MODEL medium .CODE

BASIC function for QuickBASIC, Version 4 and future versions ; of Microsoft and IBM BASIC Compilers
    PUBLIC  Power2

Power2 PROC push bp ; Entry sequence - save old BP mov bp,sp ; Set stack framepointer

    mov     bx,[bp+8]       ; Load Arg1 into
    mov     ax,[bx]         ;   AX
    mov     bx,[bp+6]       ; Load Arg2 into
    mov     cx,[bx]         ;   CX
    shl     ax,cl           ; AX = AX * (2 to power of CX)
                            ; Leave return value in AX

    pop     bp              ; Restore old framepointer
    ret     4               ; Exit, and restore 4 bytes of args

Power2 ENDP

BASIC subprogram for QuickBASIC, Versions 1, 2, and 3; ; for the Microsoft BASIC Compiler through Version 5.36 ; for the IBM BASIC Compiler through Version 2.02
    PUBLIC  Power2S

Power2S PROC push bp ; Entry sequence - save old BP mov bp,sp ; Set stack framepointer

    mov     bx,[bp+10]      ; Load Arg1 into
    mov     ax,[bx]         ;   AX
    mov     bx,[bp+8]       ; Load Arg2 into
    mov     cx,[bx]         ;   CX
    shl     ax,cl           ; AX = AX * (2 to power of CX)
    mov     bx,[bp+6]       ; Store result in
    mov     [bx],ax         ;   Arg3

    pop     bp              ; Restore old framepointer
    ret     4               ; Exit, and restore 4 bytes of args

Power2S ENDP END

The following is BAMAIN.BAS:

DEFINT A-Z

’ Function call for QuickBASIC, Version 4, ’ and for future versions of Microsoft and IBM BASIC Compilers ’ Comment out for older versions

DECLARE FUNCTION Power2(A AS INTEGER, B AS INTEGER) PRINT “3 times 2 to the power of 5 is”; PRINT Power2(3,5)

’ Subprogram equivalent to function for QuickBASIC, Versions 1, 2, and 3; ’ for the Microsoft BASIC Compiler through Version 5.36 ’ for the IBM BASIC Compiler through Version 2.02

CALL Power2S(3, 5, C) PRINT “3 times 2 to the power of 5 is”; C

END