home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 181.img / TASM-101.ZIP / CHAPXMPL.ARC / SQRETBLE.C < prev    next >
Text File  |  1989-05-02  |  614b  |  17 lines

  1. /* Table of square values */
  2.  
  3. asm  SquareLookUpTable  label  word;
  4. asm  dw  0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100;
  5.  
  6. /* Function to look up the square of a value between 0 and 10 */
  7.  
  8. int LookUpSquare(int Value)
  9. {
  10.    asm  mov  bx,Value;             /* get the value to square */
  11.    asm  shl  bx,1;                 /* multiply it by 2 to look*/
  12.                                    /* up in a table of*/
  13.                                    /* word-sized elements */
  14.    asm  mov  ax,[SquareLookUpTable+bx];   /* look up the square */
  15.    return(_AX);                           /* return the result */
  16. }
  17.