home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / ASM / A86B.ZIP / COMPAT.DOC < prev    next >
Encoding:
Text File  |  1986-06-22  |  9.3 KB  |  172 lines

  1. ---COMPAT.DOC---
  2.  
  3. Compatibility with "standard" assembly language
  4.  
  5. I gave heavy priority to compatibility when I designed A86; a priority just a
  6. shade behind the higher priorities of reliability, speed, convenience, and
  7. power.  For those of you who feel that "close, but incompatible" is like saying
  8. "a little bit pregnant", I'm sorry to report that A86 will not assemble all
  9. Intel/IBM/MSDOS programs, unmodified. But I do think that a vast majority of
  10. programs ultimately producing .COM files can, with a surprisingly little amount
  11. of massaging, be made to assemble under A86.  Furthermore, the massaging can be
  12. done in such a way as to make the programs still acceptible to that old,
  13. behemoth assembler.
  14.  
  15.  
  16. Conversion of Intel/IBM/MSDOS programs to A86
  17.  
  18. Following is a list of the things you should watch out for when converting from
  19. Intel/IBM to A86:
  20.  
  21. 1. If your program does not fit into 64K, with all the segment registers
  22.    pointing to the same value, then there may be instructions in the program
  23.    for which the old assembler generates segment-override prefixes "behind your
  24.    back".  You will need to find such references, and generate explicit
  25.    overrides for them.  If there are data-tables within the program itself, a
  26.    CS-override is needed.    If there are data-structures in the stack segment
  27.    not accessed via a BP-index, an SS-override is needed. If ES points to its
  28.    own segment, then an ES-override is needed for accesses (other than STOS and
  29.    MOVS destinations) to that segment.
  30.  
  31.    If you want to remain compatible with the old assembler, then you code the
  32.    overrides by placing the segment register name, with a colon, before the
  33.    memory-access operand in the instruction.  If you do not need further
  34.    compatibility, you can place the segment register name before the
  35.    instruction mnemonic.  For example:
  36.         MOV AL,CS:TABLE[SI]    ; if you want compatibility do it this way
  37.         CS MOV AL,TABLE[SI]    ; if not you can do it this way
  38.  
  39. 2. A86 is a bit more restrictive with respect to forward-references than IBM's
  40.    assembler.  In particular, forward references to variable-names are not
  41.    allowed.  What this means is that you must move variable-declarations to the
  42.    top of your program (a sound practice anyway).  Sometimes this means that
  43.    you must add a JMP statement the very top of the program, around the
  44.    variable declarations, to the start of execution-code.
  45.  
  46. 3. A86 has the feature, not seen in Intel/IBM, that the default base for
  47.    numbers with leading digit 0 is hexadecimal, not decimal.  This means that
  48.    you must remove any leading zeroes from decimal numbers in your old
  49.    programs.  Note that all constants other than those without leading zeroes
  50.    and without trailing base-specifiers are handled identically by A86 and by
  51.    Intel/IBM.  The ONLY thing you need to worry about is decimal numbers with
  52.    leading zeroes.  Example: the old code line MOV AX,00100, meaning decimal
  53.    100, should be recoded MOV AX,100, without the leading zeroes.
  54.  
  55.    Alternatively, I have added the RADIX command, for compatibility with the
  56.    .RADIX command of IBM's assembler.  If the program has a .RADIX command at
  57.    the top of it, then my assembler will handle constants identically to the
  58.    IBM assembler; if it does not, you can add a .RADIX 10 to the top of the
  59.    program, for complete compatiblity.
  60.  
  61. 4. A86's macro definition language is different than Intel/IBM's.  Most macros
  62.    can be translated by replacing the named parameters of the old macros with
  63.    the dedicated names #n of the A86 macro language; and by replacing ENDM
  64.    with #EM.  To retain compatibility, you isolate the old macro definitions
  65.    in an INCLUDE file (A86 will ignore the INCLUDE directive), and isolate the
  66.    A86 macro definitions in a separate file, not used in an Intel/IBM assembly
  67.    of the program.
  68.  
  69. 5. A86 supports a simpler segmentation model than Intel/IBM's.  The program
  70.    should go into a segment called CODE.  Data is declared in a single segment
  71.    called DATA.  To convert an old program to A86, you must fit all the segments
  72.    of the old program into the simpler model.  If the old program produces a
  73.    .COM file, this shouldn't be hard: the segmentation model must already be
  74.    simple, to accomodate the .COM format.
  75.  
  76.    As an additional compatiblity feature, I assume that all named segments with
  77.    names other than DATA are code segments; and I implicity EQU the name to
  78.    CODE.  For example, a CSEG SEGMENT directive with be treated just as a
  79.    CODE SEGMENT directive.
  80.  
  81. 6. A86 does not support a couple of the more exotic features of Intel/IBM
  82.    assembly language: the RECORD directive and its associated operators
  83.    WIDTH and MASK; and the usage of angle-brackets to initialize structure-
  84.    records.  These features would have added much complication to the
  85.    internal structure of symbol tables in A86; degrading the speed and the
  86.    reliability of the assembler.  I felt that their use was sufficiently rare
  87.    that it was not worth including them for compatibility.  I would like to
  88.    hear some feedback on this.  Does anybody out there use these features
  89.    heavily?  Will they be missed in A86?
  90.  
  91.    If your old program does use these features, you will have to re-work the
  92.    areas that use them.  Macros can be used to duplicate the record and
  93.    structure initializations.  Explicit symbol declarations can replace the
  94.    usage of the WIDTH and MASK operators.
  95.  
  96.  
  97. Compatiability-symbols recognized by A86
  98.  
  99. A86 has been programmed to ignore a variety of lines that have meaning to
  100. Intel/IBM/MSODS assemblers; but which do nothing for A86.  These include lines
  101. beginning with a period (execpt .RADIX, which is acted upon), percent sign, or
  102. dollar sign; and lines beginning with ASSUME, END, EXTRN, INCLUDE, NAME, PAGE,
  103. PUBLIC, SUBTTL, and TITLE. If you are porting your program to A86, and you wish
  104. to retain the option of returning to the other assembler, you may leave those
  105. lines in your program.  If you decide to stay with A86, you can remove those
  106. lines at your leisure.
  107.  
  108.  
  109. Conversion of A86 Programs to Intel/IBM/MSDOS
  110.  
  111. I consider this section a bit of a blasphemy, since it's a little silly to
  112. port programs from a superior assembler, to run on an inferior one.
  113. However, I myself have been motivated to do so upon occasion.  Possible
  114. reasons include:
  115.  
  116. * Programming for a client not familiar with A86; or whose computer doesn't
  117.   run A86; who therefore wants the final version to assemble on Intel's
  118.   assembler.  Since my assembler/debugger environment is so vastly superior
  119.   to any other environment, I develop the program using my assembler, and
  120.   port it to the client's environment at the end.
  121.  
  122. * Programming a module to link to a high-level language.  Again, I debug
  123.   the module in my superior environment; then port it.
  124.  
  125. The main key to success in following the above scenarios is to exercise supreme
  126. will power, and not use any of the wonderful language features that exist on
  127. A86, but not on the Intel/IBM assembler.  This is often not easy; and I have
  128. devised some methods for porting my features to Intel/IBM assemblers:
  129.  
  130. 1. I hate giving long sequences of PUSHes and POPs on separate lines.  If the
  131.    program is to be ported to a lesser assembler, then I put the following lines
  132.    into a file that only A86 will see:
  133.       PUSH2 EQU PUSH
  134.       PUSH3 EQU PUSH
  135.       POP2 EQU POP
  136.       POP3 EQU POP
  137.  
  138.    I define macros PUSH2, PUSH3, POP2, POP3 for the lesser assembler, that PUSH
  139.    or POP the appropriate number of operands.  Then, everywhere in the program
  140.    where I would ordinarily use A86's multiple PUSH/POP feature, I use one or
  141.    more of the PUSHn/POPn mnemonics instead.
  142.  
  143. 2. I refrain from using the feature of A86 whereby constants with a leading zero
  144.    are default-hexadecimal.  All my hex constants end with H.
  145.  
  146. 3. I will usually go ahead and use my local labels L0 through L9; then at the
  147.    last minute convert them to a long sequence of labels in sequence: Z100,
  148.    Z101, Z102, etc.  I take care to remove all the ">" forward-reference
  149.    specifiers when I make the conversion.  The "Z" is used to isolate the local
  150.    labels at the end of the lesser assembler's symbol-table listing.  This
  151.    improves the quality of the final program so much that it is worth the extra
  152.    effort needed to convert L0--L9's to Z100-Zxxx's.
  153.  
  154. 4. I will place declarations B EQU DS:BYTE PTR 0 and W EQU DS:WORD PTR 0 at the
  155.    top of the program.  Recall that A86 has a "duplicate definition" feature
  156.    whereby you can EQU an already-existing symbol, as long as it is equated to
  157.    the value it already has.  This feature extends to the built in symbols B
  158.    and W, so A86 will look at those equates and essentially ignore them.  On
  159.    the old assembler, the effect of the declarations is to add A86's notation
  160.    to the old language.  Example:
  161.  
  162.          B EQU DS:BYTE PTR 0
  163.          W EQU DS:WORD PTR 0
  164.          MOV AX,W[0100]    ; replaces MOV AX, DS:WORD PTR 0100
  165.          MOV AL,B[BX]      ; replaces MOV AL, DS:BYTE PTR [BX]
  166.  
  167.    Note that I've just given you a tip that means even if you don't choose to
  168.    use A86, you'll never have to use BYTE PTR or WORD PTR again!  Now don't you
  169.    just hate BYTE PTR and WORD PTR?  Isn't the tip alone worth sending me at
  170.    least $5 for?
  171.  
  172.