home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / xlt86.lbr / XLT86.DQC / XLT86.DOC
Text File  |  1985-09-16  |  9KB  |  341 lines

  1. ************************************************************************
  2.  
  3.                 XLT86
  4.  
  5.     Translates Intel 8080 assembly language source code
  6.        to Intel 8086 assembly language source code.
  7.  
  8.             11/11/84 Frank J. Zerilli
  9.  
  10.  
  11. ************************************************************************
  12.  
  13.      XLT86 processes lines with DR's exclamation point statement
  14. separator correctly.  It strips trailing blanks or tabs from lines.  It
  15. replaces initial asterisks in lines with semicolons.  It provides
  16. several options to format the output file for best appearance.  This
  17. program gives the choice of converting the case of instructions to upper
  18. or lower case or of trying to preserve the case of instructions.  An
  19. activity dot is printed on the console for every 100 lines of input
  20. processed.
  21.  
  22.      The program removes any colons terminating symbols on the same line
  23. with the pseudo-operators EQU, DB, DW, or RS and insures that all other
  24. labels are terminated with a colon.
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  Command line:
  31.  
  32.      XLT86 [d:]SRCFILE[.TYP] [d:DESTFILE.TYP]
  33.  
  34.      All parameters in brackets are optional, and, if omitted, the
  35. default values are:
  36.  
  37.   Source file-type      -- ASM
  38.   Destination file-type -- A86
  39.   Destination file-name -- same as the source file-name
  40.   Drive                 -- current drive
  41.  
  42.  
  43.  
  44. Examples:
  45.  
  46. XLT86 PRGM1                   --     translates PRGM1.ASM to PRGM1.A86
  47. XLT86 PRGM1 PRGM2             --     translates PRGM1.ASM to PRGM2.A86
  48. XLT86 PRGM1.TXT PRGM2.MAC     --     translates PRGM1.TXT to PRGM2.MAC
  49.  
  50.  
  51.  
  52. FLAG LOCATIONS:
  53.  
  54.  103H -- Change to non-zero value to suppress translation of several
  55.      non-standard opcodes:
  56.  
  57.       REQ, RNE, RLT, RGE, CEQ, CNE, CLT, CGE
  58.       JEQ, JNE, JLT, JGE,
  59.       ENT, NAM, RAM, ROG, IFC, ICL, LST, MAC
  60.  
  61.  
  62.  104H -- If non-zero (default) XLT86 converts lines with multiple
  63.      statements separated by DR's EP separator into separate lines.
  64.      Change to zero for output on a single line with the translated
  65.      statements separated by exclamation point (!).
  66.  
  67.  
  68.  107H -- If zero (default) XLT86 translates
  69.  
  70.         PUSH PSW            POP PSW
  71.  
  72.      to
  73.  
  74.         LAHF                POP AX
  75.         PUSH AX                SAHF
  76.  
  77.      Otherwise, the translation is
  78.  
  79.         LAHF                POP AX
  80.         XCHG AH,AL            XCHG AH,AL
  81.         PUSH AX                SAHF
  82.         XCHG AH,AL
  83.  
  84.  108H -- If zero (default) XLT86 translates
  85.  
  86.         INX rp                DCX rp
  87.  
  88.      to
  89.  
  90.         INC rp'                DEC rp'
  91.  
  92.      Otherwise, the translation is
  93.  
  94.         PUSHF                PUSHF
  95.         INC rp'                DEC rp'
  96.         POPF                POPF
  97.  
  98.  109H -- If zero (default) XLT86 translates
  99.  
  100.         DAD rp
  101.  
  102.      to                        -------------
  103.                             | rp  | rp' |
  104.         ADD BX,rp'                |-----|-----|
  105.                             | B   | CX  |
  106.      Otherwise, the translation is            | D   | DX  |
  107.                             | H   | BX  |
  108.         PUSHF                    | SP  | SP  |
  109.         ADD BX,rp'                -------------
  110.         POPF
  111.  
  112.  
  113.      The distributed version of XLT86 uses 4K of buffer space, 2K for
  114. the input buffer and 2K for the output buffer.  This can be changed by
  115. changing the equate MEMSIZ (currently set to 4) to the total buffer
  116. space desired (in Kb) and reassembling the program.  However, increasing
  117. the buffer space beyond 4K will not significantly increase the speed of
  118. translation.  For example, a 36K file was translated in 44 seconds
  119. (input and output files on the same double density 8" floppy) with
  120. MEMSIZ = 4 and in 42 seconds with MEMSIZ = 32.  Disk activity may be
  121. less with larger buffers, however.
  122.  
  123.      This program is based on similar programs for 8080-Z80 conversion
  124. (XLATE2, XLT80, XLTZ80). It is a simple-minded program.  While a simple
  125. minded program is ok for translation between 8080 and Z80 mnemonics, it
  126. is not as good for 8080 to 8086 conversion so that you will have to do a
  127. fair amount of editing of the converted file to get it to work properly.
  128. Following is a list of items to check for (it's by no means complete) in
  129. your post-conversion editing.
  130.  
  131.      Some of the following items are specific to CPM-86 and Digital
  132. Research's ASM86 although many will also apply to Intel's ASM86
  133. assembler.
  134.  
  135.  
  136. 1) BDOS FUNCTION CALLS
  137.  
  138.    Replace call to location 0005 (CALL BDOS) with INT 224:
  139.    for example, replace
  140.  
  141. BDOS    EQU    5
  142.  
  143.    with
  144.  
  145. BDOS:    INT    224
  146.     RET
  147.  
  148.    Alternatively, replace all CALL BDOS or CALL 5 with INT 224.
  149.  
  150.  
  151. 2) RETURN TO CCP
  152.  
  153.    Replace jumps to location 0000 (abort) with call to BDOS function 0:
  154.    for example, replace
  155.  
  156. ABORT    EQU    0
  157.  
  158.    with
  159.  
  160. ABORT:    MOV    CL,0
  161.     MOV    DL,0
  162.     CALL    BDOS
  163.  
  164.    An alternative is to restore the CCP stack pointer (you have to have
  165.    saved it, of course) and do a RETF.
  166.  
  167. *** Important Note: if the program uses a local stack instead of the CCP
  168.    stack then be sure to set SS (stack segment) register to the same value
  169.    as the CS (code segment) register.
  170.  
  171.    For example:
  172.  
  173. START:    MOV    AX,SS
  174.     MOV    CCPSS,AX    ; save CCP SS register
  175.     MOV    CCPSP,SP    ; save CCP stack pointer
  176.  
  177.     MOV    SP,OFFSET STACK    ; set local stack
  178.     MOV    AX,CS
  179.     MOV    SS,AX        ; set SS register to CS register
  180.     .
  181.     .
  182.     .
  183.  
  184. ABORT:    MOV    AX,CCPSS
  185.     MOV    SS,AX        ; restore CCP SS register
  186.     MOV    SP,CCPSP    ; restore CCP stack pointer
  187.     RETF            ; return to CCP
  188.  
  189. CCPSS    RW    1
  190. CCPSP    RW    1
  191.     RW    STACKLENGTH
  192. STACK    EQU    $
  193.  
  194.  
  195. 3) ALLOWED CHARACTERS IN SYMBOLS
  196.  
  197.    Change any '$' in symbols to '@' or '_'.
  198.  
  199.  
  200. 4) PAGE 0 EQUATES
  201.  
  202.    Replace equates which define page 0 addresses with data defining
  203.    pseudo-ops:  for example, replace
  204.  
  205. DFCB1    EQU    005CH
  206.  
  207.    with
  208.  
  209.     ORG    005CH
  210. DFCB1    RS    16
  211.  
  212.    Alternatively, add '.' to references to page 0 equates.  For example,
  213.    change any reference like
  214.  
  215.     MOV    AL,DFCB1
  216.  
  217.    to
  218.  
  219.     MOV    AL,.DFCB1
  220.  
  221.    Reason:  MOV    AL,DFCB1 is probably the translation of LDA DFCB1 (it
  222.    could also have come from MVI A,DFCB1 but this would only be due to
  223.    the weirdness of the programmer).  The period operator converts a
  224.    symbol of type number (DFCB1 got the type of number from the EQU to
  225.    005CH) into a variable.
  226.  
  227.  
  228. 5) LABELS WHICH SHOULD HAVE THE WORD TYPE ATTRIBUTE
  229.  
  230.    Change statements like
  231.  
  232. WORDLABEL RS    2
  233.  
  234.    to
  235.  
  236. WORDLABEL RW    1
  237.  
  238.    At the same time, change statements like
  239.  
  240.     MOV    AL,WORDLABEL+1
  241.  
  242.    to
  243.  
  244.     MOV    AL,BYTE PTR WORDLABEL+1
  245.  
  246.    Reason:  the assembler is very fussy about typing of operands
  247.  
  248.  
  249. 6) LABELS WHICH ARE ADDRESSES OF EXECUTABLE INSTRUCTIONS
  250.  
  251.    Change statements like
  252.  
  253.     MOV    AL,CODELABEL
  254.  
  255.    to
  256.  
  257.     MOV    AL,BYTE PTR CODELABEL
  258.  
  259.    (where CODELABEL is the symbol for a code segment address)
  260.  
  261.  
  262. 7) CONVERTING ADDRESSES TO NUMBERS
  263.  
  264.    Change statements like
  265.  
  266.     CMP    AL,(BUFFER_ADDRESS + BUFFER_LENGTH)/256
  267.  
  268.    to
  269.  
  270.     CMP    AL,(OFFSET BUFFER_ADDRESS + BUFFER_LENGTH)/256
  271.  
  272.  
  273. 8) CONVERTING ADDRESSES TO NUMBERS (continued)
  274.  
  275.    Change statements like
  276.  
  277.     MOV    CL,TABLE_END - TABLE_START
  278.  
  279.    to
  280.  
  281.     MOV    CL,OFFSET TABLE_END - OFFSET TABLE_START
  282.  
  283.  
  284. 9) OPCODES WHICH AFFECT FLAGS
  285.  
  286.    Watch out for this:  unlike the 8080, incrementing and decrementing
  287.    16 bit registers in the 8086 will affect the flags.  So if you have
  288.    some 8080 code like
  289.  
  290. RETZER:    MVI    B,1
  291.     LXI    H,0
  292.     DCR    B
  293.     INX    H
  294.     RET
  295.  
  296.   which would return with the zero flag set, it will be translated to
  297.  
  298. RETZER:    MOV    CH,1
  299.     MOV    BX,0
  300.     DEC    CH
  301.     INC    BX
  302.     RET
  303.  
  304.   which will return with the zero flag reset !   Therefore, the code
  305.   must be changed to
  306.  
  307. RETZER:    MOV    CH,1
  308.     MOV    BX,0
  309.     INC    BX
  310.     DEC    CH
  311.     RET
  312.  
  313.    which will return the flag as originally intended.
  314.  
  315.    XLT86 has a option (set location offset 108H non-zero) to translate
  316.    INX rp or DCX rp (rp stands for register pair B, D, H, or SP) to the
  317.    sequence
  318.  
  319.     PUSHF
  320.     INC or    DEC rp'
  321.     POPF
  322.  
  323.    There is a similar problem with DAD rp which affects only the carry
  324.    flag in the 8080.  Its translation is ADD BX,rp' which affects sign,
  325.    zero, half carry, parity, and overflow as well as the carry flag.
  326.    Setting location offset 109H in XLT86 to non-zero will PUSHF and POPF
  327.    as for INX and DCX but in this case there is still a problem if the
  328.    result of the operation on the carry flag must be preserved.
  329.  
  330.  
  331. 10) PUSH or POP PSW
  332.  
  333.    In the 8080, the A registers is the high byte of the word pushed onto
  334.    the stack.  The translation is PUSH AX in which the register
  335.    corresponding to A is AL which is the low byte of the word pushed
  336.    onto the stack.  This is would not be a problem unless the program
  337.    tries to pick the register directly from the stack.  Setting the
  338.    location offset 107H in XLT86 to non-zero will cause the translated
  339.    program to include an XCHG AH,AL before and after pushing to (and
  340.    after popping from) the stack.
  341.