home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB28.ZIP / INLINE.DOC < prev    next >
Encoding:
Text File  |  1986-02-22  |  9.0 KB  |  331 lines

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