qc.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.
POWER2.C
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
/* POWER2.C */
#include <stdio.h>
 
int power2( int num, int power );
 
void main( void )
{
   printf( "3 times 2 to the power of 5 is %d\n", \
           power2( 3, 5) );
}
 
int power2( int num, int power )
{
   _asm
   {
      mov ax, num    ; Get first argument
      mov cx, power  ; Get second argument
      shl ax, cl     ; AX = AX * ( 2 to the power of CL )
   }
   /* Return with result in AX */
}