home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 9.ddi / CHAPXMPL.ZIP / SQRETBLE.C < prev    next >
Encoding:
Text File  |  1991-02-13  |  882 b   |  25 lines

  1. // Turbo Assembler    Copyright (c) 1988, 1991 By Borland International, Inc.
  2.  
  3. // SQRETBLE.C - Example of inline assembler code
  4.  
  5. // From the Turbo Assembler Users Guide - Interfacing Turbo Assembler
  6. //                                         with Borland C++
  7.  
  8.  
  9. /* Table of square values */
  10.  
  11. asm  SquareLookUpTable  label  word;
  12. asm  dw  0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100;
  13.  
  14. /* Function to look up the square of a value between 0 and 10 */
  15.  
  16. int LookUpSquare(int Value)
  17. {
  18.    asm  mov  bx,Value;             /* get the value to square */
  19.    asm  shl  bx,1;                 /* multiply it by 2 to look*/
  20.                                    /* up in a table of*/
  21.                                    /* word-sized elements */
  22.    asm  mov  ax,[SquareLookUpTable+bx];   /* look up the square */
  23.    return(_AX);                           /* return the result */
  24. }
  25.