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

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