home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / usoftpd.zip / POWER2.ASM < prev    next >
Assembly Source File  |  1987-07-31  |  2KB  |  64 lines

  1. ; Default command line for BASIC:    MASM /Dmodel=medium /DBASIC power2;
  2. ; Default command line for C:        MASM /MX /Dmodel=small /DcLang power2;
  3. ; Default command line for FORTRAN:  MASM /Dmodel=large /DFORTRAN power2;
  4. ; Default command line for Pascal:   MASM /Dmodel=large /DPascal power2;
  5.  
  6.           INCLUDE mixed.inc
  7.           setModel %model
  8.  
  9.           IFDEF   BASIC
  10. reference EQU     1
  11.           ENDIF
  12.           IFDEF   FORTRAN
  13. reference EQU     1
  14.           ENDIF
  15.  
  16.           .CODE
  17.  
  18. ; Function for C, FORTRAN, Pascal, Version 4 of QuickBASIC, and
  19. ;   future versions of Microsoft and IBM BASIC Compilers
  20.  
  21.           IFDEF   reference          ; Pass by reference for BASIC or FORTRAN 
  22. hProc     Power2, Value:PTR, Count:PTR
  23.  
  24.           pLes    bx,Value           ; Load arguments passed by reference
  25.           mov     ax,FP[bx]
  26.           pLes    bx,Count
  27.           mov     cx,FP[bx]
  28.  
  29.           ELSE                       ; Pass by value for C or Pascal
  30. hProc     Power2, Value, Count
  31.  
  32.           mov     ax,Value           ; Load arguments passed by value
  33.           mov     cx,Count
  34.           ENDIF
  35.  
  36.           shl     ax,cl              ; AX = AX * (2 to power of CL)
  37.                                      ; Return result in AX
  38.           hRet
  39. hEndp
  40.  
  41.           IFDEF   BASIC
  42.  
  43. ; Subprogram for QuickBASIC, Versions 1, 2, and 3;
  44. ;     for the Microsoft BASIC Compiler through Version 5.36
  45. ;     for the IBM BASIC Compiler through Version 2.02
  46.  
  47. hProc     Power2S, Value, Count, RetVal
  48.  
  49.           pLes    bx,Value           ; Load BASIC arguments
  50.           mov     ax,FP[bx]          ;   passed by reference
  51.           pLes    bx,Count
  52.           mov     cx,FP[bx]
  53.  
  54.           shl     ax,cl              ; AX = AX * (2 to power of CL)
  55.  
  56.           pLes    bx,RetVal          ; Load return address
  57.           mov     FP[bx],ax          ;   and store result in it
  58.  
  59.           hRet
  60. hEndp
  61.           ENDIF   ; BASIC
  62.           END
  63.  
  64.