home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc / qc25 / power2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-15  |  426 b   |  22 lines

  1. /* POWER2.C */
  2. #include <stdio.h>
  3.  
  4. int power2( int num, int power );
  5.  
  6. void main( void )
  7. {
  8.    printf( "3 times 2 to the power of 5 is %d\n", \
  9.            power2( 3, 5) );
  10. }
  11.  
  12. int power2( int num, int power )
  13. {
  14.    _asm
  15.    {
  16.       mov ax, num    ; Get first argument
  17.       mov cx, power  ; Get second argument
  18.       shl ax, cl     ; AX = AX * ( 2 to the power of CL )
  19.    }
  20.    /* Return with result in AX */
  21. }
  22.