home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol6n20.zip / INLINE.ZIP / INLINE.DOC < prev    next >
Text File  |  1987-03-30  |  14KB  |  397 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                                      March 30, 1987
  9.  
  10.                                 INLINE ASSEMBLER
  11.                                   Version 2.14
  12.  
  13.  
  14.         OVERVIEW
  15.  
  16.         INLINE.COM is an assembler designed to produce Inline 8086/8088 
  17.         and 8087 code for Turbo Pascal (tm) version 3 programs.  Like 
  18.         other assemblers, INLINE accepts as input an assembly language 
  19.         source file and produces an object file.  However, in this case, 
  20.         the 'object' file is an ASCII file consisting of Inline 
  21.         statements which may be inserted into the Turbo Pascal program.
  22.  
  23.         Figure 1 illustrates a Pascal function with Inline code generated 
  24.         by INLINE using the source file of Figure 2.
  25.  
  26.  
  27.         LOADING AND RUNNING INLINE
  28.  
  29.         First create a COM file, INLINE.COM, by compiling INLINE.PAS 
  30.         using the Turbo Pascal compiler.  The normal default memory 
  31.         settings are suitable.
  32.  
  33.         INLINE is called at the DOS prompt with two filename parameters 
  34.         specifying the names of the source and object files.  If no 
  35.         extensions are given, .ASM and .OBJ are used by default.  For 
  36.         instance,
  37.  
  38.           INLINE ABC DEF
  39.  
  40.         will cause INLINE to look for a source file, ABC.ASM, and create 
  41.         an object file, DEF.OBJ.  Files with no extension may be input or 
  42.         created by using a simple '.' for the extension.
  43.  
  44.         If the object filename is missing from the command line, an OBJ 
  45.         file will be created using the same name as the source file.  If 
  46.         neither filename is specified, then names will be requested once 
  47.         execution starts.
  48.  
  49.         Once execution begins, INLINE will run to completion with the 
  50.         only console output being error messages.
  51.  
  52.  
  53.         SYNTAX
  54.  
  55.         The appendix lists the mnemonics accepted by INLINE.  Syntax and 
  56.         mnemonics correspond to that used by most assemblers but note 
  57.         should be made of the following:
  58.  
  59.  
  60.  
  61.  
  62.                                    1
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.           1. Turbo Pascal symbols may be used within instruction entries 
  75.              by preceding the symbol with a '>' (16 bit symbol) or a '<' 
  76.              (8 bit symbol).  The characters '+' and '-' are considered 
  77.              part of the symbol.  This allows computations using symbols 
  78.              to be passed on to the compiler where the computation can be 
  79.              made.  For instance, in
  80.  
  81.                  MOV AX,[>SYMBOL+4]       ;'>SYMBOL+4' is passed on
  82.                  MOV AX,[BP+>SYMBOL+4]    ;again '>SYMBOL+4' is passed on
  83.                  MOV AX,>SYMBOL+4[BP]     ;also acceptable
  84.  
  85.              Note that
  86.  
  87.                  MOV AX,[>SYMBOL+4+BP]
  88.  
  89.              is not correct since the wrong instruction will be generated 
  90.              and '>SYMBOL+4+BP' will be passed on.
  91.  
  92.           2. Labels (for use with jump instructions) may be defined 
  93.              simply by appending a ':' to the first item on a line.  
  94.              Avoid using CS:, DS:, ES:, and SS: as labels, as these 
  95.              specify segment overrides.
  96.  
  97.           3. Numerical entries are assumed to be decimal unless preceded 
  98.              by a '$' indicating a hexadecimal entry.  Characters within 
  99.              single quotes may be used for numerical entries as:
  100.  
  101.                  CMP AL,'a'
  102.  
  103.           4. Square brackets are used to indicate 'contents of'.  If no 
  104.              square brackets are used, an immediate operand is assumed.
  105.  
  106.                  MOV AX,[>DATA]  ;Load AX with the contents of DATA.
  107.                  MOV AX,>DATA    ;Load AX with DATA.
  108.  
  109.           5. Instruction prefixes and segment override prefixes may 
  110.              precede the instruction on the same line or may be included 
  111.              on a previous line.  A colon is optional after the segment 
  112.              prefix.
  113.  
  114.                  ES: MOV AX,[1234]    ;ok
  115.                  REPNE MOVSB          ;ok
  116.                  MOV AX,ES:[1234]     ;incorrect syntax for INLINE
  117.  
  118.           6. Comments may be included in the source.  They are delimited 
  119.              by a ';'.
  120.  
  121.           7. Instructions which don't clearly specify the data size 
  122.              require that BYTE PTR, WORD PTR, DWORD PTR, QWORD PTR, or 
  123.              TBYTE PTR be used.  These may be abbreviated by using the 
  124.              first two letters.
  125.  
  126.  
  127.  
  128.                                    2
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.                  INC BYTE PTR [>BDATA]
  141.                  DEC WO >WARRAY[DI]
  142.                  FLD QWORD [>DBL_REAL]
  143.  
  144.           8. JMP instructions may use SHORT, NEAR, or FAR (they should 
  145.              not be abbreviated).  In the absence of one of these words, 
  146.              a SHORT jump will be encoded if the label is already defined 
  147.              and is within range.  If the label is not defined, a NEAR 
  148.              JMP will be encoded unless SHORT is used.
  149.  
  150.              A FAR CALL or JMP may be made to a direct address by stating 
  151.              both the segment and offset separated by a colon.
  152.  
  153.                  CALL FAR $1234:$5678
  154.  
  155.              Direct CALL's or JMP's may be made to other Turbo procedures 
  156.              and functions using symbolic names.  The '*' location 
  157.              counter reference is required to allow Turbo to determine 
  158.              the correct displacement, as:
  159.  
  160.                  CALL >PROCNAME-*-2
  161.  
  162.              Null JMP's which may be required for delay between port 
  163.              calls on the 80286, may be made as;
  164.  
  165.                  JMP >0        ;or
  166.                  JMP SHORT <0
  167.  
  168.         Normally INLINE generates only one Inline statement per source 
  169.         file.  However, the 'NEW' pseudo-instruction may be used to 
  170.         terminate one Inline statement and begin another.  Using the NEW 
  171.         instruction, it is possible to create a number of Inline 
  172.         statements from one source file.
  173.  
  174.  
  175.         FLOATING POINT INSTRUCTIONS
  176.  
  177.         An automatic WAIT (FWAIT) opcode is generated for each floating 
  178.         point instruction except for the 'no wait' instructions (those 
  179.         with 'N' for the second letter.  However, the WAIT instruction 
  180.         may be required before a floating point instruction having a 
  181.         segment override to insure the WAIT is properly positioned.
  182.  
  183.                WAIT
  184.                ES:FMUL DWORD [BX]
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                                    3
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.         RESTRICTIONS
  207.  
  208.         The object file is limited to 32k.  This includes comments and 
  209.         spaces.
  210.  
  211.         Symbols (including any addons from + and -) are limited to 32 
  212.         characters.
  213.  
  214.         Labels may be used in jump statements only and not as data 
  215.         references.  While there is a DB pseudo-opcode, it is not very 
  216.         useful with this restriction.
  217.  
  218.         The number of statement labels that may be defined is limited 
  219.         only by the heap space available.
  220.  
  221.  
  222.         VERSIONS
  223.  
  224.         2.00 Added 8087 instructions.
  225.         2.01 Fixed bug which wiped out INT $A vector.
  226.         2.02 Fixed bug which prevented labels from starting with BY, WO, 
  227.              DW, QW, and TB.
  228.         2.1  Add NEW pseudo-instruction.  Fixed bug which occurred with 
  229.              filenames having no extension.  Other bugs fixed, notably 
  230.              those effecting IN and OUT.
  231.         2.11 Calculate restricted range for short jumps correctly.
  232.              Fix bug so CALL/JMP <register> may be used.
  233.         2.12 Allow CALL and JMP direct instructions.
  234.         2.13 Allow JMP >0 and JMP SHORT <0 for null JMP's.
  235.         2.14 Change output format to better sync with TMAP's line 
  236.              numbers.
  237.  
  238.         (C) Copyright 1985,86,87 by L. David Baldwin.
  239.  
  240.         INLINE may be copied and distributed freely providing that no fee 
  241.         is charged and it is not part of a package for which a charge is 
  242.         made.
  243.  
  244.         Please report all bugs, suggestions, and problems to Dave 
  245.         Baldwin, CompuServe ID #76327,53.
  246.  
  247.              22 Fox Den Rd., (Summer)     144 13th St. East,  (Winter)
  248.              Hollis, NH 03049             Tierra Verde, FL 33715
  249.              (603) 465-7857               (813) 867-3030
  250.  
  251.  
  252.              Turbo Pascal is a trademark of Borland International Inc.
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.                                    4
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.         FUNCTION Scan(Limit :Integer; Ch :Char; Var T ): Integer;
  273.         {Scan limit characters for Ch. Return the number of characters
  274.          skipped to find a match.  If not found, return result=Limit.
  275.          Limit may be negative for a backwards scan.}
  276.         BEGIN    {Use assembly language for speed}
  277.         Inline(
  278.           $FC/            {    cld              ;assume forward}
  279.           $8A/$46/<CH/    {    mov al,<Ch[bp]   ;char to search for}
  280.           $8B/$4E/<LIMIT/ {    mov cx,<Limit[bp];bytes to search}
  281.           $09/$C9/        {    or cx,cx         ;check sign}
  282.           $9C/            {    pushf            ;save flags}
  283.           $79/$03/        {      jns x1}
  284.           $F7/$D9/        {    neg cx           ;make positive}
  285.           $FD/            {    std              ;but search in reverse}
  286.           $89/$CA/        {x1: mov dx,cx        ;save full count}
  287.           $C4/$7E/<T/     {    les di,<T[bp]    ;ptr to start}
  288.           $F2/$AE/        {    repne: scasb     ;search}
  289.           $75/$01/        {      jne x2}
  290.           $41/            {    inc cx           ;found a match}
  291.           $29/$CA/        {x2: sub dx,cx        ;find count to match}
  292.           $9D/            {    popf}
  293.           $79/$02/        {      jns x3}
  294.           $F7/$DA/        {    neg dx           ;make negative if reverse}
  295.           $89/$56/$0C);   {x3: mov [bp+$C],dx   ;put in function result}
  296.         END;
  297.  
  298.                            Figure 1: Pascal Function using Inline Code
  299.  
  300.  
  301.             cld              ;assume forward
  302.             mov al,<Ch[bp]   ;char to search for
  303.             mov cx,<Limit[bp];bytes to search
  304.             or cx,cx         ;check sign
  305.             pushf            ;save flags
  306.               jns x1
  307.             neg cx           ;make positive
  308.             std              ;but search in reverse
  309.         x1: mov dx,cx        ;save full count
  310.             les di,<T[bp]    ;ptr to start
  311.             repne: scasb     ;search
  312.               jne x2
  313.             inc cx           ;found a match
  314.         x2: sub dx,cx        ;find count to match
  315.             popf
  316.               jns x3
  317.             neg dx           ;make negative if reverse
  318.         x3: mov [bp+$C],dx   ;put in function result
  319.  
  320.  
  321.                           Figure 2:  INLINE Input File
  322.  
  323.  
  324.  
  325.  
  326.                                    5
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.         APPENDIX
  341.  
  342.           8086/8088 Opcode Mnemonics Recognized by INLINE
  343.  
  344.                 AAA       HLT       JNE       LOOPNZ    ROR    
  345.                 AAD       IDIV      JNG       LOOPZ     SAHF   
  346.                 AAM       IMUL      JNGE      MOV       SAL    
  347.                 AAS       IN        JNL       MOVSB     SAR    
  348.                 ADC       INC       JNLE      MOVSW     SBB    
  349.                 ADD       INT       JNO       MUL       SCASB  
  350.                 AND       INTO      JNP       NEG       SCASW  
  351.                 CALL      IRET      JNS       NOP       SHL    
  352.                 CBW       JA        JNZ       NOT       SHR    
  353.                 CLC       JAE       JO        OR        SS     
  354.                 CLD       JB        JP        OUT       STC    
  355.                 CLI       JBE       JPE       POP       STD    
  356.                 CMC       JC        JPO       POPF      STI    
  357.                 CMP       JCXZ      JS        PUSH      STOSB  
  358.                 CMPSB     JE        JZ        PUSHF     STOSW  
  359.                 CMPSW     JG        LAHF      RCL       SUB    
  360.                 CS        JGE       LDS       RCR       TEST   
  361.                 CWD       JL        LEA       REP       WAIT   
  362.                 DAA       JLE       LES       REPE      XCHG   
  363.                 DAS       JMP       LOCK      REPNE     XLAT   
  364.                 DB        JNA       LODSB     REPNZ     XOR    
  365.                 DEC       JNAE      LODSW     REPZ   
  366.                 DIV       JNB       LOOP      RET    
  367.                 DS        JNBE      LOOPE     RETF   
  368.                 ES        JNC       LOOPNE    ROL    
  369.  
  370.  
  371.           8087 Opcode Mnemonics Recognized by INLINE
  372.  
  373.                 F2XM1     FDIVRP    FLD       FNOP      FSTP   
  374.                 FABS      FENI      FLD1      FNSAVE    FSTSW  
  375.                 FADD      FFREE     FLDCW     FNSTCW    FSUB   
  376.                 FADDP     FIADD     FLDENV    FNSTENV   FSUBP  
  377.                 FBLD      FICOM     FLDL2E    FNSTSW    FSUBR  
  378.                 FBSTP     FICOMP    FLDL2T    FPATAN    FSUBRP 
  379.                 FCHS      FIDIV     FLDLG2    FPREM     FTST   
  380.                 FCLEX     FIDIVR    FLDLN2    FPTAN     FXAM   
  381.                 FCOM      FILD      FLDPI     FRNDINT   FXCH   
  382.                 FCOMP     FIMUL     FLDZ      FRSTOR    FXTRACT
  383.                 FCOMPP    FINCSTP   FMUL      FSAVE     FYL2X  
  384.                 FDECSTP   FINIT     FMULP     FSCALE    FYL2XP1
  385.                 FDISI     FIST      FNCLEX    FSQRT     FWAIT  
  386.                 FDIV      FISTP     FNDISI    FST    
  387.                 FDIVP     FISUB     FNENI     FSTCW  
  388.                 FDIVR     FISUBR    FNINIT    FSTENV 
  389.  
  390.  
  391.  
  392.                                    6
  393.  
  394.  
  395.  
  396.  
  397.