home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TPINLINE.ZIP / INLINE.DOC < prev   
Encoding:
Text File  |  1987-06-12  |  8.9 KB  |  217 lines

  1.                                                              January 20, 1985
  2.  
  3.                                INLINE ASSEMBLER
  4.                                  Version 2.0
  5.  
  6. OVERVIEW
  7.  
  8. INLINE.COM  is an assembler designed to produce Inline 8086/8088 and 8087 code
  9. for  Turbo  Pascal (tm) version 3  programs.  Like  other  assemblers,  INLINE
  10. accepts as input an assembly language source file and produces an object file.
  11. However, in this case, the 'object' file is an ASCII file consisting of Inline
  12. statements which may be inserted into the Turbo Pascal program.
  13.  
  14. Figure  1  illustrates a Pascal function with Inline code generated by  INLINE
  15. using the source file of Figure 2.
  16.  
  17.  
  18. LOADING AND RUNNING INLINE
  19.  
  20. INLINE is called at the DOS prompt with two filename parameters specifying the
  21. names  of the source and object files.  If no extensions are given,  .ASM  and
  22.  .OBJ are used by default. For instance,
  23.  
  24.   INLINE ABC DEF
  25.  
  26. will  cause INLINE to look for a source file,  ABC.ASM,  and create an  object
  27. file,  DEF.OBJ.  Files  with no extension may be input or created by  using  a
  28. simple '.' for the extension.
  29.  
  30. If  one  or  more filenames are missing from the command line,  they  will  be
  31. requested once execution starts.
  32.  
  33. Once  execution begins,  INLINE will run to completion with the  only  console
  34. output being error messages.
  35.  
  36.  
  37. SYNTAX
  38.  
  39. The  appendix  lists the mnemonics accepted by INLINE.  Syntax  and  mnemonics
  40. correspond  to  that  used by most assemblers but note should be made  of  the
  41. following:
  42.  
  43.   1. Turbo Pascal symbols may be used within instruction entries by  preceding
  44.      the  symbol  with  a '>' (16 bit symbol) or a '<'  (8  bit  symbol).  The
  45.      characters  '+'  and '-' are considered part of the symbol.  This  allows
  46.      computations  using  symbols to be passed on to the  compiler  where  the
  47.      computation can be made. For instance in
  48.  
  49.         MOV     AX,[>SYMBOL+4]          ;'>SYMBOL+4' is passed on
  50.         MOV     AX,[BP+>SYMBOL+4]       ;again '>SYMBOL+4' is passed on
  51.         MOV     AX,>SYMBOL+4[BP]        ;also acceptable
  52.  
  53.      Note that
  54.  
  55.         MOV AX,[>SYMBOL+4+BP]
  56.  
  57.      is  not  correct  since  the  wrong instruction  will  be  generated  and
  58.      '>SYMBOL+4+BP' will be passed on.
  59.  
  60.   2. Labels  (for  use  with  jump instructions)  may  be  defined  simply  by
  61.      appending a ':' to the first item on a line.
  62.  
  63.   3. Numerical  entries  are  assumed to be decimal unless preceded by  a  '$'
  64.      indicating  a hexadecimal entry.  Characters within single quotes may  be
  65.      used for numerical entries as:
  66.  
  67.         CMP     AL,'a'
  68.  
  69.   4. Square brackets are used to indicate 'contents of'. If no square brackets
  70.      are used, an immediate operand is assumed.
  71.  
  72.         MOV     AX,[>DATA]      ;Load AX with the contents of DATA.
  73.         MOV     AX,>DATA        ;Load AX with DATA.
  74.  
  75.   5. Instruction  prefixes  and  segment override  prefixes  may  precede  the
  76.      instruction  on  the same line or may be included on a previous  line.  A
  77.      colon is optional after the segment prefix.
  78.  
  79.         ES: MOV AX,[1234]       :ok
  80.         REPNE MOVSB             :ok
  81.         MOV     AX,ES:[1234]    :incorrect syntax for INLINE
  82.  
  83.   6. Comments may be included in the source. They are delimited by a ';'.
  84.  
  85.   7. Instructions which don't clearly specify the data size require that  BYTE
  86.      PTR,  WORD PTR,  DWORD PTR, QWORD PTR, or TBYTE PTR be used. These may be
  87.      abbreviated by using the first two letters.
  88.  
  89.         INC     BYTE PTR [>BDATA]
  90.         DEC     WO >WARRAY[DI]
  91.         FLD     QWORD [>DBL_REAL]
  92.  
  93.   8. JMP  instructions  may  use  SHORT,  NEAR,  or FAR (they  should  not  be
  94.      abbreviated).  In the absence of one of these words, a SHORT jump will be
  95.      encoded if the label is already defined and is within range. If the label
  96.      is not defined, a NEAR JMP will be encoded unless SHORT is used.
  97.  
  98.      A  FAR  CALL or JMP may be made to a direct address by stating  both  the
  99.      segment and offset separated by a colon.
  100.  
  101.         CALL    FAR $1234:$5678
  102. RESTRICTIONS
  103.  
  104. The object file is limited to 32k. This includes comments and spaces.
  105.  
  106. Symbols (including any addons from + and -) are limited to 32 characters.
  107.  
  108. Labels may be used in jump statements only and not as data  references.  While
  109. there is a DB pseudo-opcode, it is not very useful with this restriction.
  110.  
  111. The number of statement labels that may be defined is limited only by the heap
  112. space available.
  113.  
  114. Please report all bugs,  suggestions, and problems to Dave Baldwin, CompuServe
  115. ID #76327,53.
  116.  
  117.           Turbo Pascal is a trademark of Borland International Inc.
  118.  
  119. FUNCTION SCAN(LIMIT :INTEGER; CH :CHAR; VAR T ): INTEGER;
  120. {SCAN LIMIT CHARACTERS FOR CH. RETURN THE NUMBER OF CHARACTERS
  121.  SKIPPED TO FIND A MATCH.  IF NOT FOUND, RETURN RESULT=LIMIT.
  122.  LIMIT MAY BE NEGATIVE FOR A BACKWARDS SCAN.}
  123. BEGIN    {SCAN MUST BE FAST--USE ASSEMBLY LANGUAGE}
  124. Inline(
  125.   $FC                   {    CLD                ;ASSUME FORWARD}
  126.   /$8A/$46/<CH          {    MOV AL,<CH[BP]     ;CHAR TO SEARCH FOR}
  127.   /$8B/$4E/<LIMIT       {    MOV CX,<LIMIT[BP];BYTES TO SEARCH}
  128.   /$09/$C9              {    OR CX,CX           ;CHECK SIGN}
  129.   /$9C                  {    PUSHF              ;SAVE FLAGS}
  130.   /$79/$03              {       JNS X1}
  131.   /$F7/$D9              {    NEG CX             ;MAKE POSITIVE}
  132.   /$FD                  {    STD                ;BUT SEARCH IN REVERSE}
  133.   /$89/$CA              {X1: MOV DX,CX  ;SAVE FULL COUNT}
  134.   /$C4/$7E/<T           {    LES DI,<T[BP]      ;PTR TO START}
  135.   /$F2/$AE              {    REPNE: SCASB       ;SEARCH}
  136.   /$75/$01              {       JNE X2}
  137.   /$41                  {    INC CX             ;FOUND A MATCH}
  138.   /$29/$CA              {X2: SUB DX,CX  ;FIND COUNT TO MATCH}
  139.   /$9D                  {    POPF}
  140.   /$79/$02              {       JNS X3}
  141.   /$F7/$DA              {    NEG DX             ;MAKE NEGATIVE IF REVERSE}
  142.   /$89/$56/$0C          {X3: MOV [BP+$C],DX     ;PUT IN FUNCTION RESULT}
  143. );
  144. END;
  145.                  Figure 1: Pascal Function using Inline Code
  146.  
  147.         CLD                             ;ASSUME FORWARD
  148.         MOV     AL,<CH[BP]              ;CHAR TO SEARCH FOR
  149.         MOV     CX,<LIMIT[BP]           ;BYTES TO SEARCH
  150.         OR      CX,CX                   ;CHECK SIGN
  151.         PUSHF                           ;SAVE FLAGS
  152.          JNS    X1
  153.         NEG     CX                      ;MAKE POSITIVE
  154.         STD                             ;BUT SEARCH IN REVERSE
  155. X1:     MOV     DX,CX                   ;SAVE FULL COUNT
  156.         LES     DI,<T[BP]               ;PTR TO START
  157.         REPNE: SCASB                    ;SEARCH
  158.          JNE    X2
  159.         INC     CX                      ;FOUND A MATCH
  160. X2:     SUB     DX,CX                   ;FIND COUNT TO MATCH
  161.         POPF
  162.          JNS    X3
  163.         NEG     DX                      ;MAKE NEGATIVE IF REVERSE
  164. X3:     MOV     [BP+$C],DX              ;PUT IN FUNCTION RESULT  
  165.  
  166.                          Figure 2:  INLINE Input File
  167.  
  168. APPENDIX
  169.  
  170.                8086/8088 Opcode Mnemonics Recognized by INLINE
  171.  
  172.         AAA     HLT     JNE     LOOPNZ  ROR
  173.         AAD     IDIV    JNG     LOOPZ   SAHF
  174.         AAM     IMUL    JNGE    MOV     SAL
  175.         AAS     IN      JNL     MOVSB   SAR
  176.         ADC     INC     JNLE    MOVSW   SBB
  177.         ADD     INT     JNO     MUL     SCASB
  178.         AND     INTO    JNP     NEG     SCASW
  179.         CALL    IRET    JNS     NOP     SHL
  180.         CBW     JA      JNZ     NOT     SHR
  181.         CLC     JAE     JO      OR      SS
  182.         CLD     JB      JP      OUT     STC
  183.         CLI     JBE     JPE     POP     STD
  184.         CMC     JC      JPO     POPF    STI
  185.         CMP     JCXZ    JS      PUSH    STOSB
  186.         CMPSB   JE      JZ      PUSHF   STOSW
  187.         CMPSW   JG      LAHF    RCL     SUB
  188.         CS      JGE     LDS     RCR     TEST
  189.         CWD     JL      LEA     REP     WAIT
  190.         DAA     JLE     LES     REPE    XCHG
  191.         DAS     JMP     LOCK    REPNE   XLAT
  192.         DB      JNA     LODSB   REPNZ   XOR
  193.         DEC     JNAE    LODSW   REPZ
  194.         DIV     JNB     LOOP    RET
  195.         DS      JNBE    LOOPE   RETF
  196.         ES      JNC     LOOPNE  ROL
  197.  
  198.  
  199.                   8087 Opcode Mnemonics Recognized by INLINE
  200.  
  201.         F2XM1   FDIVRP  FLD     FNOP    FSTP
  202.         FABS    FENI    FLD1    FNSAVE  FSTSW
  203.         FADD    FFREE   FLDCW   FNSTCW  FSUB
  204.         FADDP   FIADD   FLDENV  FNSTENV FSUBP
  205.         FBLD    FICOM   FLDL2E  FNSTSW  FSUBR
  206.         FBSTP   FICOMP  FLDL2T  FPATAN  FSUBRP
  207.         FCHS    FIDIV   FLDLG2  FPREM   FTST
  208.         FCLEX   FIDIVR  FLDLN2  FPTAN   FXAM
  209.         FCOM    FILD    FLDPI   FRNDINT FXCH
  210.         FCOMP   FIMUL   FLDZ    FRSTOR  FXTRACT
  211.         FCOMPP  FINCSTP FMUL    FSAVE   FYL2X
  212.         FDECSTP FINIT   FMULP   FSCALE  FYL2XP1
  213.         FDISI   FIST    FNCLEX  FSQRT   FWAIT
  214.         FDIV    FISTP   FNDISI  FST
  215.         FDIVP   FISUB   FNENI   FSTCW
  216.         FDIVR   FISUBR  FNINIT  FSTENV
  217.