home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 113_01 / a15tbl1.csm < prev    next >
Text File  |  1985-03-10  |  7KB  |  293 lines

  1.     TITLE    'Machine Language Functions for 1805A Cross-Assembler V 1.2'
  2.     PAGE    60
  3. ;
  4. ;    1805A Cross-Assembler Version 1.2
  5. ;
  6. ;    Copyright (c) 1980, 82, 83, 85 William C. Colley, III.
  7. ;
  8. ;    July 1982 -- Adapted from my 1802 cross-assembler.  WCC3.
  9. ;
  10. ;    Vers 1.0 -- March 1983 -- Added 1805A opcodes to the 1805 set.  WCC3.
  11. ;
  12. ;    Vers 1.1 -- March 1983 -- Added CPU pseudo-op to combine 1802 and 1805A
  13. ;            cross-assemblers into a single program.  WCC3.
  14. ;
  15. ;    Vers 1.2 -- June 1985 -- Fixed IF block nesting mechanism bug and bug
  16. ;            in 1805A SCAL opcode.  WCC3.
  17. ;
  18. ; File:    A15TBL1.CSM
  19. ;
  20. ; Machine Language Functions -- Module #1 of 2.
  21. ;
  22.  
  23. ;
  24. ; Arguments are passed via offsets from the stack pointer.
  25. ; They are defined as follows:
  26. ;
  27. ARG0    EQU    2        ;First argument.
  28. ARG1    EQU    4        ;Second argument.
  29. ARG2    EQU    6        ;Third argument.
  30. ARG3    EQU    8        ;Fourth argument.
  31. ;
  32.     PAGE
  33. ;
  34. ; This function gets opcode number num from the opcode table.  The function
  35. ; returns 0 if the opcode was not found, 1 if it was.
  36. ;
  37. ; Function is called as follows:
  38. ;
  39. ;    getopc(num,opcode,value,attrib);
  40. ;
  41. ;    num    Character containing the number of the desired entry.
  42. ;            0 represents the first entry in the table.  The
  43. ;            table is in alphabetical order for the benefit
  44. ;            of the binary searching routine (written in C).
  45. ;    opcode    Pointer to a 5-character array which will receive the
  46. ;            opcode's name (null terminated).
  47. ;    value    Pointer to a character that will receive the opcode's
  48. ;            value.
  49. ;    attrib    Pointer to a character that will receive the opcode's
  50. ;            attibute byte.
  51. ;
  52. NUM    EQU    ARG0
  53. OPCODE    EQU    ARG1
  54. VALUE    EQU    ARG2
  55. ATTRIB    EQU    ARG3
  56. ;
  57.     FUNCTION GETOPC
  58. ;
  59.     LXI    H, NUM        ;Get entry number.
  60.     DAD    SP
  61.     MOV    A,M
  62.     CPI    OPTBLL        ;Entry in table?
  63.     LXI    H, 0        ;If not, return 0.
  64.     RNC
  65. ;
  66.     MOV    L,A        ;Find entry by computing
  67.     DAD    H        ;  (6 * num) + table base.
  68.     MOV    E,L
  69.     MOV    D,H
  70.     DAD    H
  71.     DAD    D
  72.     LXI    D,OPCTBL
  73.     DAD    D
  74.     MOV    E,L
  75.     MOV    D,H
  76. ;
  77.     LXI    H, OPCODE    ;Find opcode return area.
  78.     DAD    SP
  79.     MOV    A,M
  80.     INX    H
  81.     MOV    H,M
  82.     MOV    L,A
  83. ;
  84.     PUSH    B        ;Move opcode out to return area.
  85.     MVI    C, 4
  86. MOVOPC:    LDAX    D
  87.     INX    D
  88.     MOV    M,A
  89.     INX    H
  90.     DCR    C
  91.     JNZ    MOVOPC
  92.     POP    B
  93. ;
  94.     MVI    M, 0        ;Terminate opcode.
  95. ;
  96.     LXI    H, ATTRIB    ;Find attribute byte return area.
  97.     DAD    SP
  98.     MOV    A,M
  99.     INX    H
  100.     MOV    H,M
  101.     MOV    L,A
  102. ;
  103.     LDAX    D        ;Move attribute byte to return area.
  104.     INX    D
  105.     MOV    M,A
  106. ;
  107.     LXI    H, VALUE    ;Find value byte return area.
  108.     DAD    SP
  109.     MOV    A,M
  110.     INX    H
  111.     MOV    H,M
  112.     MOV    L,A
  113. ;
  114.     LDAX    D        ;Move value byte to return area.
  115.     MOV    M,A
  116. ;
  117.     LXI    H, 1        ;Return 1 for successful get.
  118.     RET
  119. ;
  120. ; The opcode table itself:
  121. ;
  122. ;    Each entry has a four-byte name, a one-byte attribute,
  123. ;    and a one-byte value.  The value is the lowest
  124. ;    numbered opcode having that name.
  125. ;
  126. ;    The attribute byte bits are allocated as follows:
  127. ;
  128. ;        7 = Pseudo-op.
  129. ;        6 = If pseudo-op, if group (no label allowed).
  130. ;        6 = If opcode, 68 group (two-byte opcode).
  131. ;        3-5 = Processor number (0 if pseudo-op).
  132. ;        0-2 = Number of bytes (0 if pseudo-op).
  133. ;
  134. OPTBLB    EQU    $
  135.  
  136. OPCTBL:    DB    'ADC', 0,    01H,    74H
  137.     DB    'ADCI',        12H,    7CH
  138.     DB    'ADD', 0,    01H,    0F4H
  139.     DB    'ADI', 0,    12H,    0FCH
  140.     DB    'AND', 0,    01H,    0F2H
  141.     DB    'ANI', 0,    12H,    0FAH
  142.     DB    'B1', 0, 0,    1AH,    34H
  143.     DB    'B2', 0, 0,    1AH,    35H
  144.     DB    'B3', 0, 0,    1AH,    36H
  145.     DB    'B4', 0, 0,    1AH,    37H
  146.     DB    'BCI', 0,    5BH,    3EH
  147.     DB    'BDF', 0,    1AH,    33H
  148.     DB    'BGE', 0,    1AH,    33H
  149.     DB    'BL', 0, 0,    1AH,    3BH
  150.     DB    'BLK', 0,    80H,    05H
  151.     DB    'BM', 0, 0,    1AH,    3BH
  152.     DB    'BN1', 0,    1AH,    3CH
  153.     DB    'BN2', 0,    1AH,    3DH
  154.     DB    'BN3', 0,    1AH,    3EH
  155.     DB    'BN4', 0,    1AH,    3FH
  156.     DB    'BNF', 0,    1AH,    3BH
  157.     DB    'BNQ', 0,    1AH,    39H
  158.     DB    'BNZ', 0,    1AH,    3AH
  159.     DB    'BPZ', 0,    1AH,    33H
  160.     DB    'BQ', 0, 0,    1AH,    31H
  161.     DB    'BR', 0, 0,    1AH,    30H
  162.     DB    'BXI', 0,    5BH,    3FH
  163.     DB    'BYTE',        80H,    02H
  164.     DB    'BZ', 0, 0,    1AH,    32H
  165.     DB    'CID', 0,    42H,    0DH
  166.     DB    'CIE', 0,    42H,    0CH
  167.     DB    'CPU', 0,    80H,    0DH
  168.     DB    'DACI',        53H,    7CH
  169.     DB    'DADC',        42H,    74H
  170.     DB    'DADD',        42H,    0F4H
  171.     DB    'DADI',        53H,    0FCH
  172.     DB    'DBNZ',        7CH,    20H
  173.     DB    'DEC', 0,    09H,    20H
  174.     DB    'DIS', 0,    01H,    71H
  175.     DB    'DSAV',        42H,    76H
  176.     DB    'DSBI',        53H,    7FH
  177.     DB    'DSM', 0,    42H,    0F7H
  178.     DB    'DSMB',        42H,    77H
  179.     DB    'DSMI',        53H,    0FFH
  180.     DB    'DTC', 0,    42H,    01H
  181.     DB    'ELSE',        0C0H,    07H
  182.     DB    'END', 0,    80H,    06H
  183.     DB    'ENDI',     0C0H,    08H
  184.     DB    'EQU', 0,    80H,    01H
  185.     DB    'ETQ', 0,    42H,    09H
  186.     DB    'GEC', 0,    42H,    08H
  187.     DB    'GHI', 0,    09H,    90H
  188.     DB    'GLO', 0,    09H,    80H
  189.     DB    'IDL', 0,    01H,    00H
  190.     DB    'IF', 0, 0,    0C0H,    09H
  191.     DB    'INC', 0,    09H,    10H
  192.     DB    'INP', 0,    29H,    68H
  193.     DB    'IRX', 0,    01H,    60H
  194.     DB    'LBDF',        23H,    0C3H
  195.     DB    'LBNF',        23H,    0CBH
  196.     DB    'LBNQ',        23H,    0C9H
  197.     DB    'LBNZ',        23H,    0CAH
  198.     DB    'LBQ', 0,    23H,    0C1H
  199.     DB    'LBR', 0,    23H,    0C0H
  200.     DB    'LBZ', 0,    23H,    0C2H
  201.     DB    'LDA', 0,    09H,    40H
  202.     DB    'LDC', 0,    42H,    06H
  203.     DB    'LDI', 0,    12H,    0F8H
  204.     DB    'LDN', 0,    09H,    00H
  205.     DB    'LDX', 0,    01H,    0F0H
  206.     DB    'LDXA',        01H,    72H
  207.     DB    'LOAD',        80H,    0CH
  208.     DB    'LSDF',        01H,    0CFH
  209.     DB    'LSIE',        01H,    0CCH
  210.     DB    'LSKP',        01H,    0C8H
  211.     DB    'LSNF',        01H,    0C7H
  212.     DB    'LSNQ',        01H,    0C5H
  213.     DB    'LSNZ',        01H,    0C6H
  214.     DB    'LSQ', 0,    01H,    0CDH
  215.     DB    'LSZ', 0,    01H,    0CEH
  216.     DB    'MARK',        01H,    79H
  217.     DB    'NBR', 0,    1AH,    38H
  218.     DB    'NLBR',        23H,    0C8H
  219.     DB    'NOP', 0,    01H,    0C4H
  220.     DB    'OR', 0, 0,    01H,    0F1H
  221.     DB    'ORG', 0,    80H,    00H
  222.     DB    'ORI', 0,    12H,    0F9H
  223.     DB    'OUT', 0,    29H,    60H
  224.     DB    'PAGE',        80H,    0BH
  225.     DB    'PHI', 0,    09H,    0B0H
  226.     DB    'PLO', 0,    09H,    0A0H
  227.     DB    'REQ', 0,    01H,    7AH
  228.     DB    'RET', 0,    01H,    70H
  229.     DB    'RLDI',        74H,    0C0H
  230.     DB    'RLXA',        4AH,    60H
  231.     DB    'RNX', 0,    4AH,    0B0H
  232.     DB    'RSHL',        01H,    7EH
  233.     DB    'RSHR',        01H,    76H
  234.     DB    'RSXD',        4AH,    0A0H
  235.     DB    'SAV', 0,    01H,    78H
  236.     DB    'SCAL',        74H,    80H
  237.     DB    'SCM1',        42H,    05H
  238.     DB    'SCM2',        42H,    03H
  239.     DB    'SD', 0, 0,    01H,    0F5H
  240.     DB    'SDB', 0,    01H,    75H
  241.     DB    'SDBI',        12H,    7DH
  242.     DB    'SDI', 0,    12H,    0FDH
  243.     DB    'SEP', 0,    09H,    0D0H
  244.     DB    'SEQ', 0,    01H,    7BH
  245.     DB    'SET', 0,    80H,    0AH
  246.     DB    'SEX', 0,    09H,    0E0H
  247.     DB    'SHL', 0,    01H,    0FEH
  248.     DB    'SHLC',        01H,    7EH
  249.     DB    'SHR', 0,    01H,    0F6H
  250.     DB    'SHRC',        01H,    76H
  251.     DB    'SKP', 0,    01H,    38H
  252.     DB    'SM', 0, 0,    01H,    0F7H
  253.     DB    'SMB', 0,    01H,    77H
  254.     DB    'SMBI',        12H,    7FH
  255.     DB    'SMI', 0,    12H,    0FFH
  256.     DB    'SPM1',        42H,    04H
  257.     DB    'SPM2',        42H,    02H
  258.     DB    'SRET',        4AH,    90H
  259.     DB    'STM', 0,    42H,    07H
  260.     DB    'STPC',        42H,    00H
  261.     DB    'STR', 0,    09H,    50H
  262.     DB    'STXD',        01H,    73H
  263.     DB    'TEXT',        80H,    04H
  264.     DB    'WORD',        80H,    03H
  265.     DB    'XID', 0,    42H,    0BH
  266.     DB    'XIE', 0,    42H,    0AH
  267.     DB    'XOR', 0,    01H,    0F3H
  268.     DB    'XRI', 0,    12H,    0FBH
  269. ;
  270. OPTBLL    EQU    ($ - OPTBLB) / 6    ;Calculate length of table.
  271. ;
  272.     ENDFUNCTION
  273. ;
  274.     PAGE
  275. ;
  276. ; This function returns the number of opcodes in the opcode table
  277. ; for the benefit of the binary searching routine (written in C).
  278. ;
  279. ; This function is called as follows:
  280. ;
  281. ;    numopcs();
  282. ;
  283.     FUNCTION NUMOPCS
  284. ;
  285.     LXI    H, OPTBLL    ;Return number of opcodes.
  286.     RET
  287. ;
  288.     ENDFUNCTION
  289. ;
  290. ; End of package:
  291. ;
  292.     END
  293. EP', 0,