home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / FORTH / PASM386C.ZIP / FPC-9.PRN < prev    next >
Encoding:
Text File  |  1989-10-01  |  107.1 KB  |  1,513 lines

  1.  
  2.  
  3.  
  4.                                 The  F-PC  Assembler
  5.                                 The  F-PC  Assembler
  6.  
  7.  
  8.          Section 9:  The F-PC Assembler
  9.          Section 9:  The F-PC Assembler
  10.          ______________________________
  11.                                                              Updated 01 Oct 89
  12.                                                              Updated 01 Oct 89
  13.                                                              _________________
  14.  
  15.  
  16.  
  17.               PASM, The F-PC Assembler ____________________________ 2
  18.                   PREFIX or POSTFIX ? _____________________________ 2
  19.                   The 80386 and 80386SX ___________________________ 3
  20.                   PASM386.SEQ _____________________________________ 3
  21.                   Disassembler ____________________________________ 3
  22.  
  23.               PASM Glossary _______________________________________ 4
  24.  
  25.               Addressing Modes ____________________________________ 5
  26.                   Register Mode ___________________________________ 5
  27.                       386 Registers _______________________________ 6
  28.                       X87 Registers _______________________________ 6
  29.                   Immediate Mode __________________________________ 6
  30.                   Direct Mode _____________________________________ 7
  31.                   Index Mode ______________________________________ 7
  32.                   Implied Mode and Segment Override _______________ 8
  33.                   x87 Operand Types _______________________________ 9
  34.  
  35.               Macros ______________________________________________ 9
  36.  
  37.               INLINE Code ________________________________________ 10
  38.  
  39.               Local Labels _______________________________________ 10
  40.                   Example ________________________________________ 11
  41.                   Long Jump ______________________________________ 11
  42.  
  43.               Supported Instructions _____________________________ 11
  44.                   Hawkins Mnemonic Jumps _________________________ 11
  45.                   Some Structure Constructs ______________________ 12
  46.                   x86 and x87 Instructions _______________________ 12
  47.  
  48.               Register Usage _____________________________________ 19
  49.  
  50.               Assembler Internals ________________________________ 20
  51.                   PostFix ________________________________________ 21
  52.                   PreFix _________________________________________ 21
  53.  
  54.               PASM Syntax Comparison _____________________________ 22
  55.  
  56.               CODE Structure _____________________________________ 24
  57.                   Regular Next ___________________________________ 24
  58.                   Inline  NEXT ___________________________________ 24
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                                                                    9-1
  70.                                                                    9-1
  71.  
  72.  
  73.                                 The  F-PC  Assembler
  74.                                 The  F-PC  Assembler
  75.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  76.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  77.  
  78.                                              The assembler supports prefix
  79.                                              syntax in an attempt to provide
  80.          PASM, The F-PC Assembler
  81.          PASM, The F-PC Assembler
  82.          ________________________            a syntax which is more readable
  83.                                              to programmers of other
  84.          PASM.SEQ is an assembler which      languages. The use of sequential
  85.          is based on an 8086 assembler       text file for source code
  86.          published in Dr. Dobb's Journal,    encourages the programmer to
  87.          February 1982, by Ray Duncan.       write programs in the vertical
  88.          This assembler was subsequently     code style with one statement
  89.          modified by Robert L. Smith to      per line.  This style is what
  90.          repair bugs, and support the        traditional assembler requires.
  91.          prefix assembler notation.  Bob     F-PC works well in this style,
  92.          discovered a very simple method     if you choose to do so. However,
  93.          to let a postfix assembler to       F-PC does not prevent you to
  94.          assemble prefix code, by            write in the horizontal code
  95.          deferring assembly until the        style, by which you can squeeze
  96.          next assembler command or the       many statements into one line
  97.          end of line, when all the           and make you own life miserable.
  98.          arguments for the previous          It supports postfix syntax to
  99.          assembler command are piled on      prevent alienating the
  100.          the top of the data stack.  Tom     established base of F83 users.
  101.          Zimmer has made additional
  102.          modifications to allow syntax       The prefix notation is close to
  103.          switching, and to increase          the original Intel assembly
  104.          compatibility in postfix mode       syntax, and certainly will be
  105.          with the F83 Assembler.             more familiar to programmers of
  106.                                              other languages.  All the code
  107.                                              words defined in F-PC are coded
  108.          PREFIX or POSTFIX ?
  109.          PREFIX or POSTFIX ?
  110.          ___________________                 in the prefix notation.  Please
  111.                                              consider writing any new
  112.          PASM supports dual syntaxes.        assembly code you need in the
  113.          The words PREFIX and POSTFIX        prefix mode for distribution and
  114.          switch between the two supported    assimilation.
  115.          modes.  The postfix mode is very
  116.          similar to F83's CPU8086
  117.          Assembler.  Prefix mode, which
  118.          is the default mode, allows a
  119.          syntax which is much closer to
  120.          MASM used by Intel and
  121.          MicroSoft.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.                                                                    9-2
  140.                                                                    9-2
  141.  
  142.  
  143.                                 The  F-PC  Assembler
  144.                                 The  F-PC  Assembler
  145.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  146.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  147.  
  148.          The assembly of a machine                - 286/386 unique
  149.          instruction is generally                   instructions.
  150.          deferred to the following three          - Extended (32 bit) size
  151.          events: when the next assembly             registers and memory.
  152.          mnemonic is encountered, at the          - Extra segment registers.
  153.          end of a line, or when the
  154.          command END-CODE or A; is           Not Supported:
  155.          executed.  Therefore, a good
  156.          style in writing code words in           - ENTER, LEAVE.
  157.          F-PC is to put one assembly              - Long (2 byte) offset
  158.          instruction in one line,                   conditional jumps.
  159.          followed by the parameter                - Extended (32 bit)
  160.          specification or the arguments.            addressing.
  161.          Multiple assembly instructions           - MOV with CRx or DRx
  162.          are allowed in the same line,              registers.
  163.          except the assembly directives           - Protected mode
  164.          which build control structures             instructions in general.
  165.          in a code word, such as IF,
  166.          ELSE, THEN, BEGIN, WHILE, AGAIN,
  167.          etc.  These directives must be      Disassembler
  168.                                              Disassembler
  169.                                              ____________
  170.          the first or the only
  171.          instruction in a line because       In order to facilitate writing
  172.          they act immediately, not           assembler language (CODE)
  173.          waiting for the next assembly       definitions, DASM386.SEQ is a
  174.                                              definitions, DASM386.SEQ is a
  175.                                                           ___________
  176.          instruction.  It is a good ideal    full disassembler for the 80386
  177.          to put these structure words in     and the 80387 (numeric
  178.          separate lines with proper          processor).  Beheading is used
  179.          indentation so that the nested      to minimize clutter but some
  180.          structures in a code definition     extra defitions are placed into
  181.          can be perceived more readily.      the DASM386 vocabulary.  In
  182.                                              the DASM386 vocabulary.  In
  183.                                              addition, the following words
  184.                                              are defined in the FORTH
  185.                                              are defined in the FORTH
  186.          The 80386 and 80386SX
  187.          The 80386 and 80386SX
  188.          _____________________               vocabulary:
  189.  
  190.          The Intel 80286 offers little       DM   ( addr -- )
  191.                                              DM   ( addr -- )
  192.          extra capability which is useful         Display memory starting at
  193.          in a Forth system.  The                  address addr in DUMP
  194.                                                           ____
  195.          386/386SX (and 486 when it is            format.
  196.          available) is a big step and
  197.          does add capabilities which         DIS  ( addr -- )
  198.                                              DIS  ( addr -- )
  199.          could be useful in FORTH - the           Disassembler instructions
  200.          least of which is 32 bit                 starting at address addr.
  201.                                                                       ____
  202.          registers and operations which
  203.          can be used to extend F-PC (F-      IDIS ( n -- )
  204.                                              IDIS ( n -- )
  205.          TZ, etc.) into a 32 bit world.           Disassemble the interrupt
  206.                                                   procedure whose interrupt
  207.                                                   number is n.
  208.                                                             _
  209.          PASM386.SEQ
  210.          PASM386.SEQ
  211.          ___________
  212.                                              SEEN ( addr -- )
  213.                                              SEEN ( addr -- )
  214.          This documentation reflects              Disassembler F-PC CODE
  215.          Version 1.0 of the 80386
  216.          Version 1.0 of the 80386                 definitions starting at
  217.          instruction implementation -             address addr.  If addr does
  218.                                                           ____
  219.          PASM386.SEQ.                             not point to a CODE
  220.                                                   definition, then control is
  221.          Supported                                passed to the regular
  222.                                                   routine (SEE).
  223.                                                           _____
  224.  
  225.                                                                    9-3
  226.                                                                    9-3
  227.  
  228.  
  229.                                 The  F-PC  Assembler
  230.                                 The  F-PC  Assembler
  231.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  232.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  233.  
  234.          SEE  ( | name )
  235.          SEE  ( | name )                     CODE
  236.                                              CODE
  237.               This replaces the regular           Define "name" as a new code
  238.               SEE.  It invokes SEEN to
  239.               ___              ____               definition. Assembly
  240.               perform disassembly.                language follows,
  241.                                                   terminated by END-CODE.
  242.                                                                 ________
  243.          The display and be paused by
  244.                             ______
  245.          entering a space or stopped by      END-CODE
  246.                                              END-CODE
  247.          entering an escape.                      Terminates CODE
  248.                                                              ____
  249.                                                   definitions, checks error
  250.                                                   conditions, and makes the
  251.                                                   code definition available
  252.          PASM Glossary
  253.          PASM Glossary
  254.          _____________                            for searching and
  255.                                                   execution.
  256.          Here we will only give a small
  257.          list of PASM words in this          A;
  258.                                              A;
  259.          glossary.  All assembly                  Completes the assembly of
  260.          mnemonics are identical to those         the previous instruction.
  261.          defined in F83 8086 Assembler.
  262.          All the structure directives and    LOCAL_REF
  263.                                              LOCAL_REF
  264.          test conditions are also                 This functions sets the
  265.          identical to those in F83.  Only         mode so that local labels
  266.          the most important FORTH words           will NOT cross CODE word
  267.                                                   will NOT cross CODE word
  268.          controlling the assembler are            boundaries.  The local
  269.          listed here.                             label mechanism is cleared
  270.                                                   each time a new CODE word
  271.          PREFIX
  272.          PREFIX                                   is started.  This is the
  273.               Assert prefix mode for the          default mode.
  274.               following code definitions.
  275.                                              GLOBAL_REF
  276.                                              GLOBAL_REF
  277.          POSTFIX
  278.          POSTFIX                                  This function sets the mode
  279.               Assert postfix mode for the         so that local labels can
  280.               following code definitions.         cross CODE definition
  281.                                                   boundaries.  All local
  282.          ASM.8086
  283.          ASM.8086                                 label definitions will be
  284.               Assert 8086 mode for the            available and the mechanism
  285.               following code definitions          is NOT reset at the
  286.                                                   is NOT reset at the
  287.               - this is the default.              beginning of a CODE
  288.               This mode limits the                definition.  The local
  289.               assembler to the (original)         label mechanism must be
  290.               8086 limits, registers,             reset with the CLEAR_LABELS
  291.                                                                  ____________
  292.               etc.                                function before using
  293.                                                   global referencing mode.
  294.          ASM.386
  295.          ASM.386
  296.               Assert 386 mode for the        CLEAR_LABELS
  297.                                              CLEAR_LABELS
  298.               following code definitions.         Clear the local label
  299.               This mode permits 386 32bit         mechanism to a clean or
  300.               registers, 386 extra                unused state in preparation
  301.               segment registers, unique           for using local labels.
  302.               386 instructions, and 386           This word need only be used
  303.               extensions to existing              if in the GLOBAL_REFS mode.
  304.                                                             ___________
  305.               instructions to be used.            In the LOCAL_REFS mode,
  306.                                                          __________
  307.                                                   CLEAR_LABELS is performed
  308.                                                   ____________
  309.                                                   automatically.
  310.  
  311.  
  312.  
  313.  
  314.                                                                    9-4
  315.                                                                    9-4
  316.  
  317.  
  318.                                 The  F-PC  Assembler
  319.                                 The  F-PC  Assembler
  320.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  321.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  322.  
  323.          BYTE
  324.          BYTE                                #
  325.                                              #
  326.               Assemble current and                indicates an immediate
  327.               subsequent code using byte          number.
  328.               arguments, if register size
  329.               is not explicitly              #)
  330.                                              #)
  331.               specified.                          indicates swapping source
  332.                                                   and destination registers
  333.          WORD
  334.          WORD                                     and/or memory addresses.
  335.               Assemble current and
  336.               subsequent code using 16
  337.               bit arguments, if register
  338.               size is not explicitly         Addressing Modes
  339.                                              Addressing Modes
  340.                                              ________________
  341.               specified.
  342.                                              The most difficult problem in
  343.          LABEL
  344.          LABEL                               using 8086 assembler is to
  345.               Start an assembly              figure out the correct
  346.               subroutine or mark the         addressing mode and code it into
  347.               current code address to be     an instruction. You can get a
  348.               referenced later.              good ideal and probably figure
  349.                                              out most of the addressing mode
  350.          >PRE
  351.          >PRE                                syntax from the above table.
  352.               save the current prefix /      However, there are cases the
  353.               postfix setting and set        table fells short.  Here we will
  354.               prefix.                        try to summarize the addressing
  355.                                              syntax more systematically to
  356.          PRE>
  357.          PRE>                                show you how F-PC handles
  358.               restore the previous prefix    addresses in the prefix mode.
  359.               / postfix setting.
  360.  
  361.          INLINE
  362.          INLINE                              Register Mode
  363.                                              Register Mode
  364.                                              _____________
  365.               begin assembly code inside
  366.               of a colon definition.         Source or destination is a
  367.                                              register in the CPU.  The source
  368.          END-INLINE
  369.          END-INLINE                          registers specifications are:
  370.               terminate assembly code
  371.               inside of a colon
  372.               definition and revert to          AL    BL    CL    DL
  373.                                                 AL    BL    CL    DL
  374.               normal colon compilation.         AH    BH    CH    DH
  375.                                                 AH    BH    CH    DH
  376.                                                 AX    BX    CX    DX
  377.                                                 AX    BX    CX    DX
  378.          INLINEON
  379.          INLINEON                               SP    BP    SI    DI
  380.                                                 SP    BP    SI    DI
  381.               turns generation of inline        IP    RP
  382.                                                 IP    RP
  383.               NEXT on.
  384.               ____                              CS    DS    SS    ES
  385.                                                 CS    DS    SS    ES
  386.  
  387.          INLINEOFF
  388.          INLINEOFF                           Destination register
  389.               turns generation of inline     specifications are:
  390.               NEXT off.
  391.               ____
  392.  
  393.          FAR
  394.          FAR                                    AL,   BL,   CL,   DL,
  395.                                                 AL,   BL,   CL,   DL,
  396.               is used to designate an           AH,   BH,   CH,   DH,
  397.                                                 AH,   BH,   CH,   DH,
  398.               external segment jump.            AX,   BX,   CX,   DX,
  399.                                                 AX,   BX,   CX,   DX,
  400.                                                 SP,   BP,   SI,   DI,
  401.                                                 SP,   BP,   SI,   DI,
  402.          []
  403.          []                                     IP,   RP,
  404.                                                 IP,   RP,
  405.               is used with FAR for long
  406.                            ___                  CS,   DS,   SS,   ES,
  407.                                                 CS,   DS,   SS,   ES,
  408.               labels.
  409.  
  410.  
  411.  
  412.                                                                    9-5
  413.                                                                    9-5
  414.  
  415.  
  416.                                 The  F-PC  Assembler
  417.                                 The  F-PC  Assembler
  418.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  419.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  420.  
  421.          Note that IP is the same as the
  422.          Note that IP is the same as the
  423.                    __                        The destination register
  424.          SI register and that RP is the
  425.          __                   __             specifications are:
  426.          same as the BP register.  This
  427.                      __
  428.          additional register names are
  429.          provided for compatibility with        ST(0),     ST(1),
  430.                                                 ST(0),     ST(1),
  431.          most Forth systems.                    ST(2),     ST(3),
  432.                                                 ST(2),     ST(3),
  433.                                                 ST(4),     ST(5),
  434.                                                 ST(4),     ST(5),
  435.                                                 ST(6),     ST(7),
  436.                                                 ST(6),     ST(7),
  437.          386 Registers
  438.          386 Registers
  439.          _____________
  440.                                              In addition, the register
  441.          The 32bit source registers          specifications ST and ST, are
  442.                                              specifications ST and ST, are
  443.          specifications are:                 used in some instructions to
  444.                                              specify an implied ST(0).
  445.                                              specify an implied ST(0).
  446.                                                         _______
  447.  
  448.             EAX   EBX   ECX   EDX
  449.             EAX   EBX   ECX   EDX
  450.             ESP   EBP   ESI   EDI
  451.             ESP   EBP   ESI   EDI            Immediate Mode
  452.                                              Immediate Mode
  453.                                              ______________
  454.  
  455.          The 16bit source segment            The argument is assembled as a
  456.          registers specifications are:       literal in the instruction.  The
  457.                                              immediate value must be preceded
  458.                                              by the symbol #, which is a word
  459.                                                            _
  460.             CS    DS    SS    ES
  461.             CS    DS    SS    ES             and must be delimited by spaces:
  462.             FS    GS
  463.             FS    GS
  464.  
  465.          The 32bit destination registers        MOV  AX, # 1234
  466.                                                 MOV  AX, # 1234
  467.          specifications are:                    ADD  CL, # 32
  468.                                                 ADD  CL, # 32
  469.                                                 ROL  AX, # 3
  470.                                                 ROL  AX, # 3
  471.  
  472.             EAX,  EBX,  ECX,  EDX,
  473.             EAX,  EBX,  ECX,  EDX,           For some 386 instructions, 32-
  474.             ESP,  EBP,  ESI,  EDI,
  475.             ESP,  EBP,  ESI,  EDI,           bit immediate data is expected
  476.                                              and must be specified.  This can
  477.          The 16bit destination segment       be specified and two successive
  478.          registers specifications are:       16-bit values or a single
  479.                                              double-value.    For example:
  480.  
  481.             CS,   DS,   SS,   ES,
  482.             CS,   DS,   SS,   ES,
  483.             FS,   GS,
  484.             FS,   GS,                           MOV   EAX,  # $1234 $5678
  485.                                                 MOV   EAX,  # $1234 $5678
  486.  
  487.                                                 MOV   EAX,  # $5678.1234
  488.                                                 MOV   EAX,  # $5678.1234
  489.          X87 Registers
  490.          X87 Registers
  491.          _____________
  492.                                              If a double value is specified,
  493.          The support for the (floating       note that it is stored in
  494.          point) numeric processor such as    reverse order on the stack.
  495.          the 8087 and the 80387 add a
  496.          number of register definitions
  497.          to the assembler.
  498.  
  499.          The source register
  500.          specifications are:
  501.  
  502.  
  503.             ST(0)      ST(1)
  504.             ST(0)      ST(1)
  505.             ST(2)      ST(3)
  506.             ST(2)      ST(3)
  507.             ST(4)      ST(5)
  508.             ST(4)      ST(5)
  509.             ST(6)      ST(7)
  510.             ST(6)      ST(7)
  511.  
  512.  
  513.                                                                    9-6
  514.                                                                    9-6
  515.  
  516.  
  517.                                 The  F-PC  Assembler
  518.                                 The  F-PC  Assembler
  519.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  520.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  521.  
  522.          Direct Mode
  523.          Direct Mode
  524.          ___________                         Examples are:
  525.  
  526.          An address is assembled into the
  527.          instruction.  This is used to           CMP  2 [BP], SI
  528.                                                  CMP  2 [BP], SI
  529.          specify an address to be jumped         DEC  3 [SI]
  530.                                                  DEC  3 [SI]
  531.          to or a memory location for data        MOV  BP, 0 [BX]
  532.                                                  MOV  BP, 0 [BX]
  533.          reference.  The address is used
  534.          directly as a 16 bit number.        The following register index
  535.          Depending on the instruction,       specifications are allowed in F-
  536.          the address may be assembled        PC for source register
  537.          unmodified or assembled as an       designations:
  538.          eight bit offset in the branch
  539.          instructions.  To jump or call
  540.          beyond a 64K byte segment, the          [SI]      [IP]
  541.                                                  [SI]      [IP]
  542.          address must be preceded by             [BP]      [RP]
  543.                                                  [BP]      [RP]
  544.          FAR [].
  545.          ______                                  [DI]
  546.                                                  [DI]
  547.                                                  [BX]
  548.                                                  [BX]
  549.          Examples are:
  550.                                                  [BX+SI]   [SI+BX]
  551.                                                  [BX+SI]   [SI+BX]
  552.                                                  [BX+IP]   [IP+BX]
  553.                                                  [BX+IP]   [IP+BX]
  554.             CALL FAR [] <label>
  555.             CALL FAR [] <label>
  556.             JMP  <dest>
  557.             JMP  <dest>                          [BX+DI]   [DI+BX]
  558.                                                  [BX+DI]   [DI+BX]
  559.             MOV  BX, <source>
  560.             MOV  BX, <source>
  561.             INC  <dest> WORD
  562.             INC  <dest> WORD                     [BP+SI]   [SI+BP]
  563.                                                  [BP+SI]   [SI+BP]
  564.             JZ   <label>
  565.             JZ   <label>                         [BP+IP]   [IP+BP]
  566.                                                  [BP+IP]   [IP+BP]
  567.                                                  [RP+IP]   [IP+RP]
  568.                                                  [RP+IP]   [IP+RP]
  569.          The destination address may be
  570.          taken from the data stack               [BP+DI]   [DI+BP]
  571.                                                  [BP+DI]   [DI+BP]
  572.          directly:                               [RP+DI]   [DI+RP]
  573.                                                  [RP+DI]   [DI+RP]
  574.  
  575.                                              Destination registers are
  576.             MOV  CX, # 16
  577.             MOV  CX, # 16                    specified in a similar manner
  578.             HERE ( save current code
  579.             HERE ( save current code         by:
  580.          address on stack)
  581.          address on stack)
  582.                  ...
  583.                  ...
  584.                  ...
  585.                  ...                             [SI],     [IP],
  586.                                                  [SI],     [IP],
  587.             LOOPZ ( loop back to HERE if
  588.             LOOPZ ( loop back to HERE if         [BP],     [RP],
  589.                                                  [BP],     [RP],
  590.          condition fails)
  591.          condition fails)                        [DI],
  592.                                                  [DI],
  593.                                                  [BX],
  594.                                                  [BX],
  595.  
  596.          Index Mode
  597.          Index Mode
  598.          __________                              [BX+SI],  [SI+BX],
  599.                                                  [BX+SI],  [SI+BX],
  600.                                                  [BX+IP],  [IP+BX],
  601.                                                  [BX+IP],  [IP+BX],
  602.          One or two registers can be used
  603.          as index registers to scan              [BX+DI],  [DI+BX],
  604.                                                  [BX+DI],  [DI+BX],
  605.          through data arrays.  The
  606.          contents of the index register          [BP+SI],  [SI+BP],
  607.                                                  [BP+SI],  [SI+BP],
  608.          or the sum of the contents of           [BP+IP],  [IP+BP],
  609.                                                  [BP+IP],  [IP+BP],
  610.          two index registers are added to
  611.          form a base address, an offset          [BP+DI],  [DI+BP],
  612.                                                  [BP+DI],  [DI+BP],
  613.          is added to the base address to
  614.          form the true address for data      Note that the available
  615.          reference.                          specifications are NOT
  616.                                              symmetric.
  617.  
  618.  
  619.  
  620.  
  621.                                                                    9-7
  622.                                                                    9-7
  623.  
  624.  
  625.                                 The  F-PC  Assembler
  626.                                 The  F-PC  Assembler
  627.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  628.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  629.  
  630.          There must be an offset number      If you need to specify an
  631.          preceding the index register        address with a segment register
  632.          specification, even if the          other than the default implied
  633.          offset is 0.  This offset must
  634.          offset is 0.  This offset must
  635.                        ________________      register, use a segment override
  636.          be specified even if the
  637.          be specified even if the
  638.          ________________________            instruction before the address
  639.          instruction does not use it
  640.          instruction does not use it
  641.          ___________________________         specification:
  642.          (e.g., the push and pop
  643.                     ____     ___
  644.          instructions can push/pop values
  645.          indirectly or indexed but do not
  646.          indirectly or indexed but do not        CS:   DS:  ES:  SS:
  647.                                                  CS:   DS:  ES:  SS:
  648.          use the offset).
  649.                                              The 386 adds two more segment
  650.                                              The 386 adds two more segment
  651.          When the index register is used     registers.  These are similar to
  652.          as destination, a comma must be     the ES register and can be used
  653.                                              the ES register and can be used
  654.                                                  __
  655.          appended immediately:               in similar ways.  The extra 386
  656.                                              segment over-rides are:
  657.  
  658.              MOV  0 [BX+IP], AX
  659.              MOV  0 [BX+IP], AX
  660.                                                  FS:   GS:
  661.                                                  FS:   GS:
  662.          32-bit index registers require
  663.          support of 32-bit addressing.       Examples are:
  664.          This is not currently supported.
  665.  
  666.                                                  MOV  ES: BP, SI
  667.                                                  MOV  ES: BP, SI
  668.          Implied Mode and Segment
  669.          Implied Mode and Segment
  670.          ________________________                CMP  CS: 2 [BP], AX
  671.                                                  CMP  CS: 2 [BP], AX
  672.          Override
  673.          Override
  674.          ________                                ADD  AX, ES: 10 [BX+DI]
  675.                                                  ADD  AX, ES: 10 [BX+DI]
  676.  
  677.          The implied mode is where           The 8086 addressing modes are so
  678.          mistakes are most likely to         confusing that even experienced
  679.          occur because you will have to      programmer needs a good Intel
  680.          be keenly aware of which segment    8086 manual to find the right
  681.          register is used by the             addressing mode and the F-PC
  682.          instruction at any instance.        assembler syntax table to
  683.          Since the segment register is       determine the correct argument
  684.          implied and not stated              list.
  685.          explicitly, the bug generally
  686.          can hide very securely              The best way to write assembly
  687.          underneath laughing at you.  The    code is still keeping the code
  688.          code works when you test it but     short and simple.  It is very
  689.          fails when the segment register     easy in F-PC to break a long
  690.          is modified.                        CODE definition into many small
  691.                                              ____
  692.                                              fragments which are initially
  693.          -- Branch and jump instructions     defined as separate CODE
  694.                                                                  ____
  695.          use CS segment register.            definitions.  After verifying
  696.                                              that each fragment works, you
  697.          -- Data movement instructions       can edit out the CODE, NEXT, and
  698.                                                               ____  ____
  699.          use DS segment register.            END-CODE lines to combine the
  700.                                              ________
  701.                                              fragments into a single CODE
  702.                                                                      ____
  703.          -- Stack instructions use SS        definition.
  704.          segment.
  705.  
  706.          -- String instructions use DS:SI
  707.          as source and ES:DI as
  708.          destination.
  709.  
  710.  
  711.  
  712.  
  713.                                                                    9-8
  714.                                                                    9-8
  715.  
  716.  
  717.                                 The  F-PC  Assembler
  718.                                 The  F-PC  Assembler
  719.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  720.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  721.  
  722.          Charles Curley kindly               Macros
  723.                                              Macros
  724.                                              ______
  725.          contributes an 8086 disassembler
  726.          with a single step debugger.  It    Another area of interest is the
  727.          is helpful to disassemble the       macros.  Here is the definition
  728.          CODE word you defined and see
  729.          ____                                of the NEXT macro:
  730.          what the computer thinks of what
  731.          you mean. There is always this
  732.          'Do what I mean, not what I say'        : NEXT  >PRE    JMP >NEXT A;
  733.                                                  : NEXT  >PRE    JMP >NEXT A;
  734.          syndrome. Stepping through a        PRE> ;
  735.                                              PRE> ;
  736.          piece of code one instruction at
  737.          a time is the last thing you        The macro itself is simply the
  738.          have to do if everything else       sequence JMP >NEXT. The
  739.                                                       _________
  740.          failed.                             surrounding words are used for
  741.                                              support. Since PASM supports
  742.                                              both postfix as well as prefix
  743.          x87 Operand Types
  744.          x87 Operand Types
  745.          _________________                   notation, it is not known on
  746.                                              entry to a macro what mode is
  747.          Many x87 instructions require       selected. The words >PRE and
  748.                                                                  ____
  749.          specifying a operand type           PRE> select prefix, and restore
  750.                                              ____
  751.          designation.  The valid one are:    the previous mode so macros will
  752.                                              always be in prefix notation.
  753.                                              The A; after >NEXT, forces the
  754.                                                  __       _____
  755.             REAL*4
  756.             REAL*4                           assembly of the JMP instruction
  757.                                                              ___
  758.             REAL*8
  759.             REAL*8                           before the mode switch.
  760.             INTEGER*2
  761.             INTEGER*2
  762.             INTEGER*4
  763.             INTEGER*4                        The standard predefined macros
  764.             INTEGER*8
  765.             INTEGER*8                        in PASM include NEXT (a JMP or
  766.                                                              ____
  767.             BCD
  768.             BCD                              inline next function), 1PUSH
  769.                                                                     _____
  770.             REAL_TEMP
  771.             REAL_TEMP                        (pushes AX on the stack and then
  772.                                              (pushes AX on the stack and then
  773.                                              does NEXT), and 2PUSH (pushes
  774.                                                   ____       _____
  775.          If one is not specified but it      DX, AX and then does NEXT).
  776.                                              DX, AX and then does NEXT).
  777.                                                                   ____
  778.          is needed, REAL*4 is assumed.
  779.          is needed, REAL*4 is assumed.
  780.          Normally, these are needed for
  781.          instructions referencing memory
  782.          - those with a floating point
  783.          stack register specification do
  784.          not need this (it is ignored).
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.                                                                    9-9
  806.                                                                    9-9
  807.  
  808.  
  809.                                 The  F-PC  Assembler
  810.                                 The  F-PC  Assembler
  811.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  812.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  813.  
  814.          INLINE Code
  815.          INLINE Code
  816.          ___________                         Local Labels
  817.                                              Local Labels
  818.                                              ____________
  819.  
  820.          INLINE allows us to include
  821.          ______                              To support large code
  822.          machine code inside a high level    definitions, Bob Smith
  823.          colon definition.  This is          introduced 'local labels' to F-
  824.          easily done in F-PC because it      PC.  The local labels are place
  825.          is built on direct threaded         markers $: preceded by a number.
  826.          code.  Every word is compiled as    They are used to mark locations
  827.          a code address in the colon         in a large code definition for
  828.          definition.  The code in the        forward and backward jumps and
  829.          code field pointed to by the        branches.  They can be used
  830.          code address is executed            quite freely in a range of code
  831.          directly because it is genuine      words and reused to save head
  832.          8086 machine code.  Whether the     space by replacing LABELs which
  833.                                                                 _____
  834.          code belongs to a colon             have global names and cannot be
  835.          definition or a code definition     reused.
  836.          does not make any difference.
  837.          INLINE only has to compile the      The use of local labels is best
  838.          address pointing to the top of      demonstrated by an example taken
  839.          the dictionary in the code          from the software floating point
  840.          segment.  The assembler can then    package SFLOAT.SEQ by Bob Smith.
  841.          be invoked to compile machine       Up to 32 local labels can be
  842.          code.  If the code is terminated    used to mark addresses of
  843.          by NEXT or one of its
  844.             ____                             assembly code.  They can be
  845.          derivatives, the next word          referred to before or after
  846.          compiled in the colon definition    their placements.  They can be
  847.          will be executed after the          referenced across code word
  848.          assembly code is done.  END-
  849.                                  ____        boundaries.  The command LLAB-
  850.                                                                       _____
  851.          INLINE only has to clean up the
  852.          ______                              INIT defines the boundary where
  853.                                              ____
  854.          assembly environment and return     the local label referencing
  855.          the control back to the colon       cannot cross.  Between two
  856.          compiler.                           consecutive LLAB-INIT, local
  857.                                                          _________
  858.                                              labels can be freely placed and
  859.          Here is an example on how to use    referenced.  The LLAB-INIT
  860.                                                               _________
  861.          INLINE and END-INLINE to add        function is from George Hawkins
  862.          assembly code in the middle of a    enhancement to PASM.  It is
  863.          colon definition:                   similar to the CLEAR-LABELS
  864.                                                             ____________
  865.                                              function in the original PASM.
  866.  
  867.              : TEST ( -- )
  868.              : TEST ( -- )                   This technique is especially
  869.                5 0 DO
  870.                5 0 DO                        useful where the one-entry-one-
  871.                    I             \ Get
  872.                    I             \ Get       exit dogma is very awkward when
  873.          loop index
  874.          loop index                          a piece of code has multiple
  875.                    INLINE
  876.                    INLINE                    entry points and can be shared
  877.                      pop ax       \ pop I
  878.                      pop ax       \ pop I    among many code word
  879.                      add ax, # 23 \ add
  880.                      add ax, # 23 \ add      definitions.  It allows us to
  881.          23
  882.          23                                  construct structured spaghetti
  883.                      1push        \ push
  884.                      1push        \ push     code, if there were such thing.
  885.          sum
  886.          sum
  887.                    END-INLINE
  888.                    END-INLINE
  889.                    .              \ print
  890.                    .              \ print
  891.          results
  892.          results
  893.                LOOP
  894.                LOOP
  895.              ;
  896.              ;
  897.  
  898.  
  899.  
  900.                                                                   9-10
  901.                                                                   9-10
  902.  
  903.  
  904.                                 The  F-PC  Assembler
  905.                                 The  F-PC  Assembler
  906.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  907.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  908.  
  909.          The implementation of local         Supported Instructions
  910.                                              Supported Instructions
  911.                                              ______________________
  912.          labels in PASM has been enhanced
  913.          by George Hawkins to correct
  914.          some bugs as well as to add some
  915.          features.  For example, it is no    Hawkins Mnemonic Jumps
  916.                                              Hawkins Mnemonic Jumps
  917.                                              ______________________
  918.          longer necessary to use LLAB-
  919.                                  _____
  920.          INIT (or CLEAR-LABELS) to
  921.          ____     ____________               George Hawkins has added a
  922.          initialize since this will be       number of mnemonic functions for
  923.          done automatically by CODE.
  924.                                ____          jumping in assembler CODE
  925.                                                                   ____
  926.                                              definitions.  These additional
  927.                                              definitions are:
  928.          Example
  929.          Example
  930.          _______
  931.                                                   J    JMP
  932.                                                   J    JMP
  933.          Short jump labels:
  934.                                                   J0<> JNE
  935.                                                   J0<> JNE
  936.                                                   J0=  JZ
  937.                                                   J0=  JZ
  938.                SUB  AX, AX
  939.                SUB  AX, AX                        J0>= JNS
  940.                                                   J0>= JNS
  941.                JNE  2  $
  942.                JNE  2  $                          J0<  JS
  943.                                                   J0<  JS
  944.               ....  up to 127 bytes of
  945.               ....  up to 127 bytes of
  946.          code
  947.          code                                     J<>  JNE
  948.                                                   J<>  JNE
  949.          2  $:  MOV  AX,  BX
  950.          2  $:  MOV  AX,  BX                      J=   JZ
  951.                                                   J=   JZ
  952.                  \ destination of short
  953.                  \ destination of short           J>=  JNL
  954.                                                   J>=  JNL
  955.          jump
  956.          jump                                     J<   JNGE
  957.                                                   J<   JNGE
  958.                                                   J>   JNLE
  959.                                                   J>   JNLE
  960.                                                   J<=  JNG
  961.                                                   J<=  JNG
  962.          Long Jump
  963.          Long Jump
  964.          _________
  965.                                                   JU>= JNC
  966.                                                   JU>= JNC
  967.          A single long label (more than           JU<  JNAE
  968.                                                   JU<  JNAE
  969.          127 bytes of code) is supported          JU>  JNBE
  970.                                                   JU>  JNBE
  971.          in each CODE definition.  This
  972.                  ____                             JU<= JNA
  973.                                                   JU<= JNA
  974.          long jump label can only be used
  975.          for forward addressing!  An
  976.              ___________________             These mnemonic jumps are very
  977.          example is:                         useful with local labels.
  978.  
  979.  
  980.                JMP  L$
  981.                JMP  L$
  982.              .....   any length
  983.              .....   any length
  984.           L$:  MOV  x, x
  985.           L$:  MOV  x, x
  986.                    \ destination of long
  987.                    \ destination of long
  988.          jump
  989.          jump
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.                                                                   9-11
  1008.                                                                   9-11
  1009.  
  1010.  
  1011.                                 The  F-PC  Assembler
  1012.                                 The  F-PC  Assembler
  1013.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1014.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1015.  
  1016.          Some Structure Constructs
  1017.          Some Structure Constructs
  1018.          _________________________           DS:     8086 Segment (prefix)
  1019.                                              DS:     8086 Segment (prefix)
  1020.                                                      Override - points to the
  1021.          PASM supports a number of                   standard (default) data
  1022.          constructs for structured                   segment - normally the
  1023.          programming.  These constructs              same as CS: in F-PC and
  1024.          are similar to those available              points to the beginning
  1025.          for colon definitions and                   of the CODE space.
  1026.          include the following:
  1027.                                              FS:     386
  1028.                                              FS:     386
  1029.               IF                                     Segment (prefix)
  1030.               THEN                                   Override
  1031.               ELSE
  1032.                                              GS:     386
  1033.                                              GS:     386
  1034.               BEGIN                                  Segment (prefix)
  1035.               UNTIL                                  Override
  1036.               AGAIN
  1037.               WHILE                          AAA     ASCII Adjust after
  1038.                                              AAA     ASCII Adjust after
  1039.               REPEAT                                 Addition
  1040.  
  1041.          There is also some shorthand for    AAD     ASCII Adjust after
  1042.                                              AAD     ASCII Adjust after
  1043.          comparison:                                 Division
  1044.  
  1045.                                              AAM     ASCII Adjust after
  1046.                                              AAM     ASCII Adjust after
  1047.             0=    0<>   0<    0>=
  1048.             0=    0<>   0<    0>=                    Multiplication
  1049.             <     >=    <=    >
  1050.             <     >=    <=    >
  1051.             U<    U>=   U<=   U>
  1052.             U<    U>=   U<=   U>             AAS     ASCII Adjust after
  1053.                                              AAS     ASCII Adjust after
  1054.             OV
  1055.             OV                                       Subtraction
  1056.             CX<>0
  1057.             CX<>0
  1058.                                              ADC     Arithmetic (integer) Add
  1059.                                              ADC     Arithmetic (integer) Add
  1060.                                                      with Carry
  1061.  
  1062.          x86 and x87 Instructions
  1063.          x86 and x87 Instructions
  1064.          ________________________            ADD     Arithmetic (integer)
  1065.                                              ADD     Arithmetic (integer)
  1066.                                                      Addition
  1067.          The following gives a list of
  1068.          the 8086, 80286, 80386, 8087,       AND     (logical) and
  1069.                                              AND     (logical) and
  1070.          80287, and 80387 instructions
  1071.          supported by the F-PC assembler.    BSF     386
  1072.                                              BSF     386
  1073.                                                      Scan Bit Forward
  1074.          ES:     8086 Segment (prefix)
  1075.          ES:     8086 Segment (prefix)
  1076.                  Override                    BSR     386
  1077.                                              BSR     386
  1078.                                                      Scan Bit Reverse
  1079.          CS:     8086 Segment (prefix)
  1080.          CS:     8086 Segment (prefix)
  1081.                  Override - Code Segment     BT      386
  1082.                                              BT      386
  1083.                  - points to F-PC's CODE             Bit Test
  1084.                  space.
  1085.                                              BTC     386
  1086.                                              BTC     386
  1087.          SS:     8086 Segment (prefix)
  1088.          SS:     8086 Segment (prefix)               Bit Test and Complement
  1089.                  Override - points to the
  1090.                  Stack segment               BTR     386
  1091.                                              BTR     386
  1092.                                                      Bit Test and Reset
  1093.  
  1094.                                              BTS     386
  1095.                                              BTS     386
  1096.                                                      Bit Test and Set
  1097.  
  1098.                                              CALL    Call Procedure
  1099.                                              CALL    Call Procedure
  1100.  
  1101.  
  1102.                                                                   9-12
  1103.                                                                   9-12
  1104.  
  1105.  
  1106.                                 The  F-PC  Assembler
  1107.                                 The  F-PC  Assembler
  1108.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1109.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1110.  
  1111.          CBW     Convert Byte to Word
  1112.          CBW     Convert Byte to Word        FCOMP   x87 Compare
  1113.                                              FCOMP   x87 Compare
  1114.                                                      (real/integer and pop
  1115.          CLC     Clear Carry Flag
  1116.          CLC     Clear Carry Flag
  1117.                                              FCOMPP  x87 Compare Real and Pop
  1118.                                              FCOMPP  x87 Compare Real and Pop
  1119.          CLD     Clear Direction Flag
  1120.          CLD     Clear Direction Flag                twice
  1121.                  (increasing)
  1122.                                              FCOS    387
  1123.                                              FCOS    387
  1124.          CLI     Clear Interrupt Flag
  1125.          CLI     Clear Interrupt Flag                Cosine of ST(0)
  1126.                  (Disable)
  1127.                                              FDECSTP x87 Decrement stack
  1128.                                              FDECSTP x87 Decrement stack
  1129.          CLTS    386
  1130.          CLTS    386                                 pointer
  1131.                  Clear Task Switched Flag
  1132.                                              FDISI   8087
  1133.                                              FDISI   8087
  1134.          CMC     Complement Carry Flag
  1135.          CMC     Complement Carry Flag               DISABLE interrupts
  1136.  
  1137.          CMP     Compare Register/Memory
  1138.          CMP     Compare Register/Memory     FDIV    x87 Divide
  1139.                                              FDIV    x87 Divide
  1140.                  with memory or                      (real/integer)
  1141.                  Immediate.
  1142.                                              FDIVP   x87 Divide Real and Pop
  1143.                                              FDIVP   x87 Divide Real and Pop
  1144.          CMPS    Compare String
  1145.          CMPS    Compare String
  1146.                                              FDIVR   x87 Divide
  1147.                                              FDIVR   x87 Divide
  1148.          CMPSB   Compare (byte) String
  1149.          CMPSB   Compare (byte) String               (real/integer) REVERSE
  1150.  
  1151.          CMPSD   Compare (Dword) String
  1152.          CMPSD   Compare (Dword) String      FDIVRP  x87 Divide Real Reverse
  1153.                                              FDIVRP  x87 Divide Real Reverse
  1154.                                                      and Pop
  1155.          CMPSW   Compare (word) String
  1156.          CMPSW   Compare (word) String
  1157.                                              FENI    8087
  1158.                                              FENI    8087
  1159.          CWD     Convert Word to Dword
  1160.          CWD     Convert Word to Dword               ENABLE interrupts
  1161.  
  1162.          DAA     Decimal Adjust after
  1163.          DAA     Decimal Adjust after        FFREE   x87 Free Register
  1164.                                              FFREE   x87 Free Register
  1165.                  Addition
  1166.                                              FINCSTP x87 Increment Stack
  1167.                                              FINCSTP x87 Increment Stack
  1168.          DAS     Decimal Adjust after
  1169.          DAS     Decimal Adjust after                pointer
  1170.                  Subtraction
  1171.                                              FINIT   x87 Initialize Processor
  1172.                                              FINIT   x87 Initialize Processor
  1173.          DEC     Decrement
  1174.          DEC     Decrement
  1175.                                              FLD     x87 Load
  1176.                                              FLD     x87 Load
  1177.          DIV     Unsigned divide
  1178.          DIV     Unsigned divide                     (real/integer/bcd/temp_r
  1179.                                                      eal)
  1180.          F2XM1   x87 (2**x)-1
  1181.          F2XM1   x87 (2**x)-1
  1182.                                              FLD1    x87 Load +1.0
  1183.                                              FLD1    x87 Load +1.0
  1184.          FABS    x87 absolute value
  1185.          FABS    x87 absolute value
  1186.                                              FLDCW   x87 Load control word
  1187.                                              FLDCW   x87 Load control word
  1188.          FABS,   x87 - for compatability
  1189.          FABS,   x87 - for compatability
  1190.                                              FLDENV  x87 Load environment
  1191.                                              FLDENV  x87 Load environment
  1192.          FADD    x87 Add (real/integer)
  1193.          FADD    x87 Add (real/integer)
  1194.                                              FLDL2E  x87 Load LOG2(e)
  1195.                                              FLDL2E  x87 Load LOG2(e)
  1196.          FADDP   x87 Add Real and Pop
  1197.          FADDP   x87 Add Real and Pop
  1198.                                              FLDL2T  x87 Load LOG2(10)
  1199.                                              FLDL2T  x87 Load LOG2(10)
  1200.          FCHS    x87 Change Sign
  1201.          FCHS    x87 Change Sign
  1202.                                              FLDLG2  x87 Load LOG10(2)
  1203.                                              FLDLG2  x87 Load LOG10(2)
  1204.          FCLEX   x87 Clear Exceptions
  1205.          FCLEX   x87 Clear Exceptions
  1206.                                              FLDLN2  x87 Load LOGe(2)
  1207.                                              FLDLN2  x87 Load LOGe(2)
  1208.          FCOM    x87 Compare
  1209.          FCOM    x87 Compare
  1210.                  (real/integer)              FLDPI   x87 Load pi
  1211.                                              FLDPI   x87 Load pi
  1212.  
  1213.  
  1214.                                                                   9-13
  1215.                                                                   9-13
  1216.  
  1217.  
  1218.                                 The  F-PC  Assembler
  1219.                                 The  F-PC  Assembler
  1220.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1221.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1222.  
  1223.          FLDZ    x87 Load +0.0
  1224.          FLDZ    x87 Load +0.0               FSUBR   x87 Subtract
  1225.                                              FSUBR   x87 Subtract
  1226.                                                      (real/integer) REVERSE
  1227.          FMUL    x87 Multiply
  1228.          FMUL    x87 Multiply
  1229.                  (real/integer)              FSUBRP  x87 Subtract real
  1230.                                              FSUBRP  x87 Subtract real
  1231.                                                      reverse and Pop
  1232.          FMULP   x87 Multiply Real and
  1233.          FMULP   x87 Multiply Real and
  1234.                  Pop                         FTST    x87 Test stack top
  1235.                                              FTST    x87 Test stack top
  1236.                                                      against +0.0
  1237.          FNOP    x87 no-operation
  1238.          FNOP    x87 no-operation
  1239.                                              FUCOM   387
  1240.                                              FUCOM   387
  1241.          FPATAN  x87 Partial Arctangent
  1242.          FPATAN  x87 Partial Arctangent              unordered compare
  1243.  
  1244.          FPREM   x87 Partial Remainder
  1245.          FPREM   x87 Partial Remainder       FUCOMP  387
  1246.                                              FUCOMP  387
  1247.                                                      unordered compare and
  1248.          FPREM1  387
  1249.          FPREM1  387                                 pop
  1250.                  Partial Remainder
  1251.                                              FUCOMPP 387
  1252.                                              FUCOMPP 387
  1253.          FPTAN   x87 Partial Tangent
  1254.          FPTAN   x87 Partial Tangent                 unordered Compare and
  1255.                                                      Pop Twice
  1256.          FRNDINT x87 Round to Integer
  1257.          FRNDINT x87 Round to Integer
  1258.                                              FXAM    x87 Examine stack top
  1259.                                              FXAM    x87 Examine stack top
  1260.          FRSTOR  x87 Restore saved state
  1261.          FRSTOR  x87 Restore saved state
  1262.                                              FXCH    x87 Exchange registers
  1263.                                              FXCH    x87 Exchange registers
  1264.          FSAVE   x87 Save state
  1265.          FSAVE   x87 Save state
  1266.                                              FXTRACT x87 Extract exponent and
  1267.                                              FXTRACT x87 Extract exponent and
  1268.          FSCALE  x87 Scale
  1269.          FSCALE  x87 Scale                           significant
  1270.  
  1271.          FSIN    387
  1272.          FSIN    387                         FYL2X   x87 Y*(LOG2(X))
  1273.                                              FYL2X   x87 Y*(LOG2(X))
  1274.                  Sine of ST(0)
  1275.                                              FYL2XP1 x87 Y*(LOG2(X+1))
  1276.                                              FYL2XP1 x87 Y*(LOG2(X+1))
  1277.          FSINCOS 387
  1278.          FSINCOS 387
  1279.                  Sine and Cosine of ST(0)    HLT     Halt Processor !
  1280.                                              HLT     Halt Processor !
  1281.  
  1282.          FSQRT   x87 Square root
  1283.          FSQRT   x87 Square root             IDIV    (integer) Signed Divide
  1284.                                              IDIV    (integer) Signed Divide
  1285.  
  1286.          FSQRT,  x87 -- for compat.
  1287.          FSQRT,  x87 -- for compat.          IMUL    (integer) Signed
  1288.                                              IMUL    (integer) Signed
  1289.                                                      Multiply
  1290.          FST     x87 Store (real/integer)
  1291.          FST     x87 Store (real/integer)
  1292.                                              IN      Input from an I/O Port
  1293.                                              IN      Input from an I/O Port
  1294.          FSTCW   x87 Store control word
  1295.          FSTCW   x87 Store control word
  1296.                                              INC     Increment
  1297.                                              INC     Increment
  1298.          FSTENV  x87 Store environment
  1299.          FSTENV  x87 Store environment
  1300.                                              INS     386
  1301.                                              INS     386
  1302.          FSTP    x87 Store
  1303.          FSTP    x87 Store                           Input String - DX port
  1304.                  (real/integer/BCD/temp_r
  1305.                  eal) and Pop                INSB    386
  1306.                                              INSB    386
  1307.                                                      Input (byte) String - DX
  1308.          FSTSW   x87 Store status word
  1309.          FSTSW   x87 Store status word               port
  1310.  
  1311.          FSUB    x87 Subtract
  1312.          FSUB    x87 Subtract                INSD    386
  1313.                                              INSD    386
  1314.                  (real/integer)                      Input (Dword) String -
  1315.                                                      DX port
  1316.          FSUBP   x87 Subtract real and
  1317.          FSUBP   x87 Subtract real and
  1318.                  pop                         INSW    386
  1319.                                              INSW    386
  1320.                                                      Input (word) String - DX
  1321.                                                      port
  1322.  
  1323.                                                                   9-14
  1324.                                                                   9-14
  1325.  
  1326.  
  1327.                                 The  F-PC  Assembler
  1328.                                 The  F-PC  Assembler
  1329.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1330.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1331.  
  1332.          INT     Call to Software-
  1333.          INT     Call to Software-           JNB     Jump if Not Below
  1334.                                              JNB     Jump if Not Below
  1335.                  Interrupt Procedure                 (CF=0)
  1336.  
  1337.          INTO    On Overflow, call
  1338.          INTO    On Overflow, call           JNBE    Jump if Not Below or
  1339.                                              JNBE    Jump if Not Below or
  1340.                  interrupt procedure                 Equal
  1341.                                                      (CF=0 and ZF=0)
  1342.          IRET    Interrupt Return -
  1343.          IRET    Interrupt Return -
  1344.                  restore 16 bit regs         JNC     Jump if Not Carry
  1345.                                              JNC     Jump if Not Carry
  1346.                                                      (CF=0)
  1347.          IRETD   386
  1348.          IRETD   386
  1349.                  Interrupt Return -          JNE     Jump if Not Equal
  1350.                                              JNE     Jump if Not Equal
  1351.                  restore 32 bit regs                 (ZF=0)
  1352.                  (protected mode)
  1353.                                              JNG     Jump if Not Greater
  1354.                                              JNG     Jump if Not Greater
  1355.          JA      Jump if Above
  1356.          JA      Jump if Above                       (ZF=1 or SF<>OF)
  1357.                  (CF=0 and ZF=0)
  1358.                                              JNGE    Jump if Not Greater or
  1359.                                              JNGE    Jump if Not Greater or
  1360.          JAE     Jump if Above or Equal
  1361.          JAE     Jump if Above or Equal              Equal
  1362.                  (CF=0)                              (SF<>OF)
  1363.  
  1364.          JB      Jump if Below
  1365.          JB      Jump if Below               JNL     Jump if Not Less
  1366.                                              JNL     Jump if Not Less
  1367.                  (CF=1)                              (SF=OF)
  1368.  
  1369.          JBE     Jump if Below or Equal
  1370.          JBE     Jump if Below or Equal      JNLE    Jump if Not Less or
  1371.                                              JNLE    Jump if Not Less or
  1372.                  (CF=1 or ZF=1)                      Equal
  1373.                                                      (ZF=0 and SF=OF)
  1374.          JC      Jump if Carry
  1375.          JC      Jump if Carry
  1376.                  (CF=1)                      JNO     Jump if Not Overflow
  1377.                                              JNO     Jump if Not Overflow
  1378.                                                      (OF=0)
  1379.          JCXZ    Jump if CX Register is
  1380.          JCXZ    Jump if CX Register is
  1381.                  Zero                        JNP     Jump if Not Parity
  1382.                                              JNP     Jump if Not Parity
  1383.                                                      (PF=0)
  1384.          JE      Jump if Equal
  1385.          JE      Jump if Equal
  1386.                  (ZF=1)                      JNS     Jump if Not Sign
  1387.                                              JNS     Jump if Not Sign
  1388.                                                      (SF=0)
  1389.          JG      Jump if Greater
  1390.          JG      Jump if Greater
  1391.                  (ZF=0 and SF=OF)            JNZ     Jump if Not Zero
  1392.                                              JNZ     Jump if Not Zero
  1393.                                                      (ZF=0)
  1394.          JGE     Jump if Greater of Equal
  1395.          JGE     Jump if Greater of Equal
  1396.                  (SF=OF)                     JO      Jump if Overflow
  1397.                                              JO      Jump if Overflow
  1398.                                                      (OF=1)
  1399.          JL      Jump if Less
  1400.          JL      Jump if Less
  1401.                  (SF<>OF)                    JP      Jump if Parity
  1402.                                              JP      Jump if Parity
  1403.                                                      (PF=1)
  1404.          JLE     Jump if Less or Equal
  1405.          JLE     Jump if Less or Equal
  1406.                  (ZF=1 or SF<>OF)            JPE     Jump if Parity Even
  1407.                                              JPE     Jump if Parity Even
  1408.                                                      (PF=1)
  1409.          JMP     Unconditional JUMP
  1410.          JMP     Unconditional JUMP
  1411.                                              JPO     Jump if Parity Odd
  1412.                                              JPO     Jump if Parity Odd
  1413.          JNA     Jump if Not Above
  1414.          JNA     Jump if Not Above                   (PF=0)
  1415.                  (CF=1 and ZF=1)
  1416.                                              JS      Jump if Sign
  1417.                                              JS      Jump if Sign
  1418.          JNAE    Jump if Not Above or
  1419.          JNAE    Jump if Not Above or                (SF=1)
  1420.                  Equal
  1421.                  (CF=1)                      JZ      Jump if Zero
  1422.                                              JZ      Jump if Zero
  1423.                                                      (ZF=1)
  1424.  
  1425.                                                                   9-15
  1426.                                                                   9-15
  1427.  
  1428.  
  1429.                                 The  F-PC  Assembler
  1430.                                 The  F-PC  Assembler
  1431.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1432.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1433.  
  1434.          LAHF    Load Flags into AH
  1435.          LAHF    Load Flags into AH          MOVSX   386
  1436.                                              MOVSX   386
  1437.                  register                            move to reg with Sign
  1438.                                                      Extension
  1439.          LDS     Load pointer into DS
  1440.          LDS     Load pointer into DS
  1441.                  register                    MOVZX   386
  1442.                                              MOVZX   386
  1443.                                                      move to reg with Zero
  1444.          LEA     Load Effective Address
  1445.          LEA     Load Effective Address              Extension
  1446.  
  1447.          LES     Load pointer into ES
  1448.          LES     Load pointer into ES        MUL     Unsigned Multiply
  1449.                                              MUL     Unsigned Multiply
  1450.                  register
  1451.                                              NEG     Negate
  1452.                                              NEG     Negate
  1453.          LFS     386
  1454.          LFS     386
  1455.                  Segment Register Load       NOP     No Operation
  1456.                                              NOP     No Operation
  1457.  
  1458.          LGS     386
  1459.          LGS     386                         NOT     (Logical) Not
  1460.                                              NOT     (Logical) Not
  1461.                  Segment Register Load
  1462.                                              OR      (logical) Or
  1463.                                              OR      (logical) Or
  1464.          LOCK    Bus Lock
  1465.          LOCK    Bus Lock
  1466.                                              OUT     Write to I/O Port
  1467.                                              OUT     Write to I/O Port
  1468.          LODS    Load String
  1469.          LODS    Load String
  1470.                                              OUTS    386
  1471.                                              OUTS    386
  1472.          LODSB   Load (byte) String
  1473.          LODSB   Load (byte) String                  Output String - DX port
  1474.  
  1475.          LODSD   Load (Dword) String
  1476.          LODSD   Load (Dword) String         OUTSB   386
  1477.                                              OUTSB   386
  1478.                                                      Output (byte) String -
  1479.          LODSW   Load (word) String
  1480.          LODSW   Load (word) String                  DX port
  1481.  
  1482.          LOOP    Loop with CX as counter
  1483.          LOOP    Loop with CX as counter     OUTSD   386
  1484.                                              OUTSD   386
  1485.                                                      Output (Dword) String -
  1486.          LOOPE   Loop with CX as counter
  1487.          LOOPE   Loop with CX as counter             DX port
  1488.                  and Equal
  1489.                                              OUTSW   386
  1490.                                              OUTSW   386
  1491.          LOOPNE  Loop with CX as Counter
  1492.          LOOPNE  Loop with CX as Counter             Output (word) String -
  1493.                  and NOT Equal                       DX port
  1494.  
  1495.          LOOPNZ  Loop with CX as Counter
  1496.          LOOPNZ  Loop with CX as Counter     POP     Pop off Stack
  1497.                                              POP     Pop off Stack
  1498.                  and NOT Zero
  1499.                                              POPA    386
  1500.                                              POPA    386
  1501.          LOOPZ   Loop with CX as Counter
  1502.          LOOPZ   Loop with CX as Counter             Pop All 16 bit Registers
  1503.                  and Zero
  1504.                                              POPAD   386
  1505.                                              POPAD   386
  1506.          LSS     386
  1507.          LSS     386                                 Pop All 32 bit Registers
  1508.                  Segment Register Load
  1509.                                              POPF    Pop Flags off Stack
  1510.                                              POPF    Pop Flags off Stack
  1511.          MOV     Move
  1512.          MOV     Move
  1513.                                              POPFD   386
  1514.                                              POPFD   386
  1515.          MOVS    Move String
  1516.          MOVS    Move String                         Pop 32 bit Flags off
  1517.                                                      Stack
  1518.          MOVSB   Move (byte) String
  1519.          MOVSB   Move (byte) String
  1520.                                              PUSH    Push onto Stack
  1521.                                              PUSH    Push onto Stack
  1522.          MOVSD   Move (Dword) String
  1523.          MOVSD   Move (Dword) String
  1524.                                              PUSHA   386
  1525.                                              PUSHA   386
  1526.          MOVSW   Move (word) String
  1527.          MOVSW   Move (word) String                  Push All 16 bit
  1528.                                                      Registers
  1529.  
  1530.  
  1531.  
  1532.                                                                   9-16
  1533.                                                                   9-16
  1534.  
  1535.  
  1536.                                 The  F-PC  Assembler
  1537.                                 The  F-PC  Assembler
  1538.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1539.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1540.  
  1541.          PUSHAD  386
  1542.          PUSHAD  386                         SETAE   386
  1543.                                              SETAE   386
  1544.                  Push All 16 bit                     SET if Above or Equal
  1545.                  Registers                           (CF=0)
  1546.  
  1547.          PUSHF   Push Flags onto Stack
  1548.          PUSHF   Push Flags onto Stack       SETB    386
  1549.                                              SETB    386
  1550.                                                      SET if Below
  1551.          PUSHFD  386
  1552.          PUSHFD  386                                 (CF=1)
  1553.                  Push 32 bit Flags onto
  1554.                  Stack                       SETBE   386
  1555.                                              SETBE   386
  1556.                                                      SET if Below or Equal
  1557.          RCL     Rotate through Carry
  1558.          RCL     Rotate through Carry                (CF=1 or ZF=1)
  1559.                  Left
  1560.                                              SETC    386
  1561.                                              SETC    386
  1562.          RCR     Rotate through Carry
  1563.          RCR     Rotate through Carry                SET if Carry
  1564.                  Right                               (CF=1)
  1565.  
  1566.          REP     Repeat
  1567.          REP     Repeat                      SETE    386
  1568.                                              SETE    386
  1569.                                                      SET if Equal
  1570.          REPE    Repeat while Equal
  1571.          REPE    Repeat while Equal                  (ZF=1)
  1572.  
  1573.          REPNE   Repeat while Not Equal
  1574.          REPNE   Repeat while Not Equal      SETG    386
  1575.                                              SETG    386
  1576.                                                      SET if Greater
  1577.          REPNZ   Repeat while Not Zero
  1578.          REPNZ   Repeat while Not Zero               (ZF=0 and SF=OF)
  1579.  
  1580.          REPZ    Repeat while Zero
  1581.          REPZ    Repeat while Zero           SETGE   386
  1582.                                              SETGE   386
  1583.                                                      SET if Greater of Equal
  1584.          RET     Return from Procedure
  1585.          RET     Return from Procedure               (SF=OF)
  1586.  
  1587.          RETF    Return from Inter-
  1588.          RETF    Return from Inter-          SETL    386
  1589.                                              SETL    386
  1590.                  Segment Procedure                   SET if Less
  1591.                                                      (SF<>OF)
  1592.          ROL     Rotate Left
  1593.          ROL     Rotate Left
  1594.                                              SETLE   386
  1595.                                              SETLE   386
  1596.          ROR     Rotate Right
  1597.          ROR     Rotate Right                        SET if Less or Equal
  1598.                                                      (ZF=1 or SF<>OF)
  1599.          SAHF    Store AH into Flags
  1600.          SAHF    Store AH into Flags
  1601.                                              SETNA   386
  1602.                                              SETNA   386
  1603.          SAL     Shift Arithmetic Left
  1604.          SAL     Shift Arithmetic Left               SET if Not Above
  1605.                                                      (CF=1 and ZF=1)
  1606.          SAR     Shift Arithmetic Right
  1607.          SAR     Shift Arithmetic Right
  1608.                                              SETNAE  386
  1609.                                              SETNAE  386
  1610.          SBB     Subtract with Borrow
  1611.          SBB     Subtract with Borrow                SET if Not Above or
  1612.                                                      Equal
  1613.          SCAS    Scan String
  1614.          SCAS    Scan String                         (CF=1)
  1615.  
  1616.          SCASB   Scan (byte) String
  1617.          SCASB   Scan (byte) String          SETNB   386
  1618.                                              SETNB   386
  1619.                                                      SET if Not Below
  1620.          SCASD   Scan (Dword) String
  1621.          SCASD   Scan (Dword) String                 (CF=0)
  1622.  
  1623.          SCASW   Scan (word) String
  1624.          SCASW   Scan (word) String          SETNBE  386
  1625.                                              SETNBE  386
  1626.                                                      SET if Not Below or
  1627.          SETA    386
  1628.          SETA    386                                 Equal
  1629.                  SET if Above                        (CF=0 and ZF=0)
  1630.                  (CF=0 and ZF=0)
  1631.  
  1632.  
  1633.  
  1634.                                                                   9-17
  1635.                                                                   9-17
  1636.  
  1637.  
  1638.                                 The  F-PC  Assembler
  1639.                                 The  F-PC  Assembler
  1640.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1641.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1642.  
  1643.          SETNC   386
  1644.          SETNC   386                         SETS    386
  1645.                                              SETS    386
  1646.                  SET if Not Carry                    SET if Sign
  1647.                  (CF=0)                              (SF=1)
  1648.  
  1649.          SETNE   386
  1650.          SETNE   386                         SETZ    386
  1651.                                              SETZ    386
  1652.                  SET if Not Equal                    SET if Zero
  1653.                  (ZF=0)                              (ZF=1)
  1654.  
  1655.          SETNG   386
  1656.          SETNG   386                         SHL     Shift (logical) Left
  1657.                                              SHL     Shift (logical) Left
  1658.                  SET if Not Greater
  1659.                  (ZF=1 or SF<>OF)            SHLD    386
  1660.                                              SHLD    386
  1661.                                                      Shift Left Double
  1662.          SETNGE  386
  1663.          SETNGE  386
  1664.                  SET if Not Greater or       SHR     Shift (logical) Right
  1665.                                              SHR     Shift (logical) Right
  1666.                  Equal
  1667.                  (SF<>OF)                    SHRD    386
  1668.                                              SHRD    386
  1669.                                                      Shift Right Double
  1670.          SETNL   386
  1671.          SETNL   386
  1672.                  SET if Not Less             STC     Set Carry Flag
  1673.                                              STC     Set Carry Flag
  1674.                  (SF=OF)
  1675.                                              STD     Set Direction Flag
  1676.                                              STD     Set Direction Flag
  1677.          SETNLE  386
  1678.          SETNLE  386                                 (decreasing)
  1679.                  SET if Not Less or Equal
  1680.                  (ZF=0 and SF=OF)            STI     Set Interrupt Flag
  1681.                                              STI     Set Interrupt Flag
  1682.                                                      (enable)
  1683.          SETNO   386
  1684.          SETNO   386
  1685.                  SET if Not Overflow         STOS    Store String
  1686.                                              STOS    Store String
  1687.                  (OF=0)
  1688.                                              STOSB   Store (byte) String
  1689.                                              STOSB   Store (byte) String
  1690.          SETNP   386
  1691.          SETNP   386
  1692.                  SET if Not Parity           STOSD   Store (Dword) String
  1693.                                              STOSD   Store (Dword) String
  1694.                  (PF=0)
  1695.                                              STOSW   Store (word) String
  1696.                                              STOSW   Store (word) String
  1697.          SETNS   386
  1698.          SETNS   386
  1699.                  SET if Not Sign             SUB     Subtract
  1700.                                              SUB     Subtract
  1701.                  (SF=0)
  1702.                                              TEST    Logical Compare
  1703.                                              TEST    Logical Compare
  1704.          SETNZ   386
  1705.          SETNZ   386
  1706.                  SET if Not Zero             WAIT    Wait for Coprocessor
  1707.                                              WAIT    Wait for Coprocessor
  1708.                  (ZF=0)
  1709.                                              XCHG    Exchange register with
  1710.                                              XCHG    Exchange register with
  1711.          SETO    386
  1712.          SETO    386                                 register/memory.
  1713.                  SET if Overflow
  1714.                  (OF=1)                      XLAT    Table Lookup Translation
  1715.                                              XLAT    Table Lookup Translation
  1716.  
  1717.          SETP    386
  1718.          SETP    386                         XOR     (logical) Exclusive Or.
  1719.                                              XOR     (logical) Exclusive Or.
  1720.                  SET if Parity
  1721.                  (PF=1)
  1722.  
  1723.          SETPE   386
  1724.          SETPE   386
  1725.                  SET if Parity Even
  1726.                  (PF=1)
  1727.  
  1728.          SETPO   386
  1729.          SETPO   386
  1730.                  SET if Parity Odd
  1731.                  (PF=0)
  1732.  
  1733.                                                                   9-18
  1734.                                                                   9-18
  1735.  
  1736.  
  1737.                                 The  F-PC  Assembler
  1738.                                 The  F-PC  Assembler
  1739.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1740.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1741.  
  1742.          Register Usage
  1743.          Register Usage
  1744.          ______________                      ES        The extra segment
  1745.                                              ES        The extra segment
  1746.                                                   register - this is used in
  1747.          F-PC implements a virtual                conjunction with the SI
  1748.                                                   conjunction with the SI
  1749.          machine which uses the more or           register to define the
  1750.          less standard set of                     current instruction.
  1751.          "registers":                             Therefore, it points
  1752.                                                   somewhere within the LIST
  1753.          SP   data stack pointer
  1754.          SP   data stack pointer                  or X segment.  This must be
  1755.                                                   or X segment.  This must be
  1756.                                                                  ____________
  1757.                                                   preserved by any code
  1758.                                                   _____________________
  1759.          RP   return stack pointer
  1760.          RP   return stack pointer                words.
  1761.                                                   ______
  1762.  
  1763.          IP   next word pointer
  1764.          IP   next word pointer              FS        Another extra segment
  1765.                                              FS        Another extra segment
  1766.                                                   register valid only on the
  1767.                                                   register valid only on the
  1768.          W    current word pointer
  1769.          W    current word pointer                80386.
  1770.                                                   80386.
  1771.  
  1772.          UP   user area pointer -
  1773.          UP   user area pointer -            GS        Another extra segment
  1774.                                              GS        Another extra segment
  1775.               implemented as a VARIABLE.          register valid only on the
  1776.                                                   register valid only on the
  1777.                                                   80386.
  1778.                                                   80386.
  1779.          The following 80x8x register
  1780.          usage is made in F-PC:              SP        the SP or data stack
  1781.                                              SP        the SP or data stack
  1782.                                                   pointer -- used as SS:SP.
  1783.                                                   pointer -- used as SS:SP.
  1784.          CS        The code segment
  1785.          CS        The code segment
  1786.               register used for any code     BP        the RP or return stack
  1787.                                              BP        the RP or return stack
  1788.               definitions.  This must be
  1789.               definitions.  This must be
  1790.                             ____________          pointer -- used as SS:BP.
  1791.                                                   pointer -- used as SS:BP.
  1792.               preserved by any code
  1793.               _____________________
  1794.               words.  F-PC primitives and
  1795.               ______                         ES:SI          the IP or
  1796.                                              ES:SI          the IP or
  1797.               basic operation depends on          instruction pointer -
  1798.               both CS and DS having the
  1799.               both CS and DS having the           points within the LIST or X
  1800.               same value.                         segment.  Both the ES and
  1801.                                                   segment.  Both the ES and
  1802.                                                             _______________
  1803.                                                   SI registers must be
  1804.                                                   SI registers must be
  1805.                                                   ____________________
  1806.          DS        The data segment
  1807.          DS        The data segment               preserved by a code
  1808.                                                   ___________________
  1809.               register used for any data          definition.
  1810.                                                   ___________
  1811.               other than ." or ""
  1812.               other than ." or ""
  1813.               strings.  This must be
  1814.               strings.  This must be
  1815.                         ____________         BX  CX  DX  DI
  1816.                                              BX  CX  DX  DI
  1817.               preserved by any code
  1818.               _____________________               scratch registers - can be
  1819.               words.  F-PC primitives and
  1820.               ______                              used without preserving in
  1821.               basic operation depends on          a code definition - not
  1822.               both CS and DS having the
  1823.               both CS and DS having the           assumptions are made about
  1824.               same value.                         their contents.
  1825.  
  1826.          SS        The stack segment
  1827.          SS        The stack segment         EBX  ECX  EDX  EDI
  1828.                                              EBX  ECX  EDX  EDI
  1829.               register used with SP and
  1830.               register used with SP and           32-bit forms of the above
  1831.               BP to define the location
  1832.               BP to define the location           scratch registers.
  1833.               of the F-PC stacks.  This
  1834.                                    ____
  1835.               must be preserved by any
  1836.               must be preserved by any
  1837.               ________________________       AX        W or current word
  1838.                                              AX        W or current word
  1839.               code words.  Currently, F-
  1840.               ___________                         pointer -- CS:AX points to
  1841.                                                   pointer -- CS:AX points to
  1842.               PC sets this to the same            the current machine code
  1843.               value as DS.
  1844.               value as DS.                        word on entry -- can be
  1845.                                                   used as a scratch register
  1846.                                                   since no assumptions are
  1847.                                                   made about its contents.
  1848.  
  1849.                                              EAX       the 32-bit form of the
  1850.                                              EAX       the 32-bit form of the
  1851.                                                   above register.
  1852.  
  1853.  
  1854.  
  1855.                                                                   9-19
  1856.                                                                   9-19
  1857.  
  1858.  
  1859.                                 The  F-PC  Assembler
  1860.                                 The  F-PC  Assembler
  1861.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1862.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1863.  
  1864.          DF        The Direction Flag
  1865.          DF        The Direction Flag        Although this was originally
  1866.               (used by string related        based on Duncan's 8086
  1867.               functions) -- assumed to be
  1868.                             _____________    assembler, Robert L. Smith and
  1869.               0 or increment.  If the
  1870.               0 or increment.  If the
  1871.               _______________                Tom Zimmer have modified this
  1872.               direction flag is changed      assembler to handle PREFIX
  1873.               in a code definition           notation.  This version is
  1874.               (through the use of the STD    highly dependent in Zimmer's
  1875.               instruction), then it must     Forth (F-PC, F-TZ, etc.). It is
  1876.               be reset (by the CLD           interesting to note how much of
  1877.               instruction) before the end    Duncan's original assembler
  1878.               (e.g., NEXT) of the code       still exists in this package.
  1879.               definition.  Since NEXT        In fact, this assembler seems to
  1880.               uses the string instruction    be closer to Duncan's original
  1881.               LODSW, disaster will result    than assembler in Laxon&Perry's
  1882.               if the direction flag is       F83.
  1883.               not set to 0.
  1884.                                              This assembler depends on the
  1885.          In general, CX is used for
  1886.          In general, CX is used for          Kernel functions:
  1887.          counts, AX and DX are used for
  1888.          counts, AX and DX are used for
  1889.          data, and BX is used for
  1890.          data, and BX is used for                 RUN,
  1891.          addresses.  For string                   DEFER,
  1892.          operations, DS:SI is used for
  1893.          operations, DS:SI is used for            CREATE,
  1894.          the source and ES:DI is used for
  1895.          the source and ES:DI is used for    and
  1896.          the destination.  While                  DOES>
  1897.          following such conventions, be
  1898.          sure to restore such registers      for its functioning.  DEFER is
  1899.                                                                    _____
  1900.          as are needed to preserve the       used (among other things) to
  1901.          virtual FORTH machine               provide the hooks for the meta-
  1902.          implemented by F-PC.                compilation process. CREATE and
  1903.                                                                   ______
  1904.                                              DOES> provide the capability to
  1905.                                              _____
  1906.          Caution should be used when
  1907.          _______                             create the defining words which
  1908.          using the extended (32 bit)         define the instructions as well
  1909.          forms of register or the 386        as the register notations.  RUN
  1910.                                                                          ___
  1911.          extra segment registers.  DOS       and DEFER are used to create the
  1912.                                                  _____
  1913.          does not support these extended     capability to handle the PREFIX
  1914.                                              capability to handle the PREFIX
  1915.          forms although everything should    notation.
  1916.          work properly.
  1917.                                              The register operand functions
  1918.          F-PC currently uses a single        define a set of words which use
  1919.          code segment of 64k bytes.  The     the register names as the
  1920.          CS, DS, and SS registers all
  1921.          CS, DS, and SS registers all        definition names.  At run-time,
  1922.          point to this single segment        these definitions store values
  1923.          with the stacks being located at    into a set of variables to
  1924.          the top (high addresses) of the     indicate what registers have
  1925.          segment.                            been specified and what their
  1926.                                              order was.  These information is
  1927.                                              used to complete the instruction
  1928.                                              at "instruction build" time.
  1929.          Assembler Internals
  1930.          Assembler Internals
  1931.          ___________________
  1932.  
  1933.          The bulk of the assembler in F-
  1934.          PC is contained in the file
  1935.          PASM.SEQ -- there are some
  1936.          primitives to support the
  1937.          assembler in the Kernel.
  1938.  
  1939.  
  1940.                                                                   9-20
  1941.                                                                   9-20
  1942.  
  1943.  
  1944.                                 The  F-PC  Assembler
  1945.                                 The  F-PC  Assembler
  1946.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1947.                        !"#$%&'()*+,-./0123456789:;<=>?@A...Z[\]^_`{|}~
  1948.  
  1949.          The basic process of the            PreFix
  1950.                                              PreFix
  1951.                                              ______
  1952.          assembler uses the CREATE DOES>
  1953.          construct to create the code to     The new PREFIX format modifies
  1954.                                              The new PREFIX format modifies
  1955.          handle both the register            the process slightly - the
  1956.          definitions and the instruction     instruction-word now occurs
  1957.          definitions.  Each set of           BEFORE the operand information.
  1958.          registers or instructions are       To accommodate this format, the
  1959.          grouped into categories and a       instruction-word saves the
  1960.          defining word is created for        address of passed data and the
  1961.          each category.  These defining      address of a subroutine to build
  1962.          words create the definitions        the instruction into a special
  1963.          (one for each register              (internal) variable: APRIOR.
  1964.                                              (internal) variable: APRIOR.
  1965.                                                                   ______
  1966.          specification or instruction)       Execution of the save
  1967.          which (at run-time) creates the     information is executed at a
  1968.          code which is the equivalent        deferred time - this time can be
  1969.          instruction.  My, how powerful      when the next assembly
  1970.          this is in that the whole           instruction mnemonic occurs,
  1971.          assembler is created using only     when the END-CODE function is
  1972.                                                       ________
  1973.          FORTH (no CODE definitions).
  1974.          FORTH (no CODE definitions).        executed or at the end of a
  1975.                                              physical line.  At the "deferred
  1976.                                              time", the instruction has all
  1977.          PostFix
  1978.          PostFix
  1979.          _______                             of the information necessary to
  1980.                                              build the correct code.
  1981.          The original POSTFIX format
  1982.          The original POSTFIX format
  1983.          process is fairly easy to
  1984.          understand. A defining word is
  1985.          created for each instruction
  1986.          category.  This word contains
  1987.          the fixed (e.g., opcode) portion
  1988.          of the instruction as data in
  1989.          the CREATE part of the defining
  1990.              ______
  1991.          word (the address of this data
  1992.          is passed to the run-time or
  1993.          DOES> code).  Immediate data or
  1994.          _____
  1995.          the addresses of VARIABLEs are
  1996.          placed on the stack.  The
  1997.          register functions set other
  1998.          (internal) variables to values
  1999.          which indicate the register,
  2000.          register size, etc.  The
  2001.          register specifications,
  2002.          immediate data, addresses, etc.
  2003.          must be place before the
  2004.          instruction. When the
  2005.          instruction-word is executed, it
  2006.          uses the data from the stack or
  2007.          internal variables together with
  2008.          the pre-compiled "opcode" data
  2009.          to assemble the instruction into
  2010.          memory.
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.                                                                   9-21
  2019.                                                                   9-21
  2020.  
  2021.  
  2022.                                 The  F-PC  Assembler
  2023.                                 The  F-PC  Assembler
  2024.  
  2025.  
  2026.  
  2027.  
  2028.          PASM Syntax Comparison
  2029.          PASM Syntax Comparison
  2030.          ______________________
  2031.  
  2032.  
  2033.          The differences among the F-PC prefix mode, the F83 postfix
  2034.          mode, and the Intel MASM notation are best illustrated by
  2035.          the following table.  Although the table is not exhaustive,
  2036.          it covers most of the cases useful in doing PASM
  2037.          programming.
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.                                                                   9-22
  2086.                                                                   9-22
  2087.  
  2088.  
  2089.                                 The  F-PC  Assembler
  2090.                                 The  F-PC  Assembler
  2091.  
  2092.  
  2093.                    PREFIX               POSTFIX              MASM
  2094.                    PREFIX               POSTFIX              MASM
  2095.  
  2096.                    AAA                  AAA                  AAA
  2097.                    ADC AX, SI           SI AX ADC            ADC AX,SI
  2098.                    ADC DX, 0 [SI]       0 [SI] DX ADC        ADC DX,0[SI]
  2099.                    ADC 2 [BX+SI], DI    DI 2 [BX+SI] ADC     ADC 2[BX][SI],DI
  2100.                    ADC MEM BX           BX MEM #) ADC        ADC MEM,BX
  2101.                    ADC AL, # 5          5 # AL ADC           ADC AL,5
  2102.                    AND AX, BX           BX AX AND            AND AX,BX
  2103.                    AND CX, MEM          CX MEM #) AND        AND CX,MEM
  2104.                    AND DL, # 3          3 # DL AND           AND DL,3
  2105.                    CALL NAME            NAME #) CALL         CALL NAME
  2106.                    CALL FAR [] NAME     FAR [] NAME #) CALL  ?????
  2107.                    CMP DX, BX           BX DX CMP            CMP DX,BX
  2108.                    CMP 2 [BP], SI       SI 2 [BP] CMP        CMP [BP+2],SI
  2109.                    DEC BP               BP DEC               DEC BP
  2110.                    DEC MEM              MEM DEC              DEC MEM
  2111.                    DEC 3 [SI]           3 [SI] DEC           DEC 3[SI]
  2112.                    DIV CL               CL DIV               DIV CL
  2113.                    DIV MEM              MEM DIV              DIV MEM
  2114.                    IN PORT# WORD        WORD PORT# IN        IN AX,PORT#
  2115.                    IN PORT#             PORT# IN             IN AL,PORT#
  2116.                    IN AX, DX            DX AX IN             IN AX,DX
  2117.                    INC MEM              BYTE MEM INC         INC MEM BYTE
  2118.                    INC MEM WORD         MEM #) INC           INC MEM WORD
  2119.                    INT 16               16 INT               INT 16
  2120.                    JA NAME              NAME JA              JA NAME
  2121.                    JNBE NAME            NAME #) JNBE         JNBE NAME
  2122.                    JMP NAME             NAME #) JMP          JMP
  2123.                    JMP FAR [] NAME      NAME [] FAR JMP      JMP [NAME]
  2124.                    JMP FAR $F000 $E987                       JMP F000:E987
  2125.                    LODSW                AX LODS              LODS WORD
  2126.                    LODSB                AL LODS              LODS BYTE
  2127.                    LOOP NAME            NAME #) LOOP         LOOP NAME
  2128.                    MOV DX, NAME         NAME #) DX MOV       MOV DX,[NAME]
  2129.                    MOV AX, BX           BX AX MOV            MOV AX,BX
  2130.                    MOV AH, AL           AL AH MOV            MOV AH,AL
  2131.                    MOV BP, 0 [BX]       0 [BX] BP MOV        MOV BP,0[BX]
  2132.                    MOV ES: BP, SI       ES: BP SI MOV        MOV ES:BP,SI
  2133.                    MOVSW                AX MOVS              MOVS WORD
  2134.                    POP DX               DX POP               POP DX
  2135.                    POPF                 POPF                 POPF
  2136.                    PUSH SI              SI PUSH              PUSH SI
  2137.                    REP                  REP                  REP
  2138.                    RET                  RET                  RET
  2139.                    ROL AX, # 1          AX ROL               ROL AX,1
  2140.                    ROL AX, CL           AX CL ROL            ROL AX,CL
  2141.                    SHL AX, # 1          AX SHL               SHL AX,1
  2142.                    XCHG AX, BP          BP AX XCHG           XCHG AX,BP
  2143.                    XOR CX, DX           DX, CX XOR           XOR CX,DX
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.                                                                   9-23
  2152.                                                                   9-23
  2153.  
  2154.  
  2155.                                 The  F-PC  Assembler
  2156.                                 The  F-PC  Assembler
  2157.  
  2158.  
  2159.          CODE Structure
  2160.          CODE Structure
  2161.          ______________
  2162.  
  2163.  
  2164.          This structure is used for CODE definitions.  The beginning
  2165.                                     ____
  2166.          of the name field contains the length (n) of the name.
  2167.          of the name field contains the length (n) of the name.
  2168.  
  2169.  
  2170.          Regular Next
  2171.          Regular Next
  2172.          ____________
  2173.  
  2174.  
  2175.                                          +--------------+
  2176.                        HEAD SPACE        [ VIEW offset  ] VIEW
  2177.                        HEAD SPACE        [ VIEW offset  ] VIEW
  2178.                                          [ LINK pointer ] LINK
  2179.                                          [      8n      ] NAME
  2180.                                          [   .          ]
  2181.                                          [   .          ] n bytes long
  2182.                                          [   . + 80 hex ]
  2183.                     Points to CODE space [ CFA pointer  ] >-------+
  2184.                                          +--------------+         |
  2185.                                                                   |
  2186.                                          +--------------+         |
  2187.                        CODE SPACE        [   .          ] CFA <---+
  2188.                        CODE SPACE        [   .          ] CFA <---+
  2189.                                          [   .          ]
  2190.                                          [   .          ] machine
  2191.                                          [   .          ] code
  2192.                                          [   .          ]
  2193.                                          [   .          ]
  2194.                                          [   JMP        ] end of CODE
  2195.                     Points to LIST space [   NEXT       ] definition
  2196.                                          +--------------+
  2197.  
  2198.  
  2199.          Inline  NEXT
  2200.          Inline  NEXT
  2201.          ____________
  2202.  
  2203.  
  2204.                                          +--------------+
  2205.                        HEAD SPACE        [ VIEW offset  ] VIEW
  2206.                        HEAD SPACE        [ VIEW offset  ] VIEW
  2207.                                          [ LINK pointer ] LINK
  2208.                                          [      8n      ] NAME
  2209.                                          [   .          ]
  2210.                                          [   .          ] n bytes long
  2211.                                          [   . + 80 hex ]
  2212.                     Points to CODE space [ CFA pointer  ] >-------+
  2213.                                          +--------------+         |
  2214.                                                                   |
  2215.                                          +--------------+         |
  2216.                        CODE SPACE        [   .          ] CFA <---+
  2217.                        CODE SPACE        [   .          ] CFA <---+
  2218.                                          [   .          ]
  2219.                                          [   .          ] machine
  2220.                                          [   .          ] code
  2221.                                          [   .          ]
  2222.                                          [   .          ]
  2223.                                          [  ES: LODSW   ] INLINE NEXT
  2224.                                                           ___________
  2225.                                          [  JMP AX      ] end of definition
  2226.                                          +--------------+
  2227.  
  2228.  
  2229.                                                                   9-24
  2230.                                                                   9-24