home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 113_01 / a15tbl2.csm < prev    next >
Text File  |  1985-03-10  |  6KB  |  246 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:    A15TBL2.CSM
  19. ;
  20. ; Machine Language Functions -- Module #2 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 removes the parity bit from its argument and looks it up in
  35. ; a table.  The table classifies the character into one of the following bins
  36. ; returning the appropriate code.
  37. ;
  38. ALPHA    EQU    0    ;Alphabetic.
  39. NUMERC    EQU    1    ;Numeric (0-9).
  40. ENDLIN    EQU    2    ;End of line markers (CR ;).
  41. COMMA    EQU    3    ;Field separators (,).
  42. OPERAT    EQU    4    ;Operators (* + / - > < = ( )).
  43. QUOTE    EQU    5    ;String delimiters (' ").
  44. BLANK    EQU    7    ;White space character (SPC TAB).
  45. TRASH    EQU    8    ;Other control characters.
  46. ;
  47. ; The function is called as follows:
  48. ;
  49. ;    getattr(byte);
  50. ;
  51. ;    byte    Character value to be looked up.
  52. ;
  53. BYTE    EQU    ARG0
  54. ;
  55.     FUNCTION GETATTR
  56. ;
  57.     LXI    H, BYTE        ;Get byte to look up.
  58.     DAD    SP
  59.     MOV    A,M
  60.     ANI    7FH        ;Strip parity bit.
  61. ;
  62.     LXI    H, ATTTBL    ;Index into table.
  63.     ADD    L
  64.     MOV    L,A
  65.     MVI    A, 0
  66.     ADC    H
  67.     MOV    H,A
  68. ;
  69.     MOV    L,M        ;Return result.
  70.     MVI    H, 0
  71.     RET
  72. ;
  73. ; Attribute table itself:
  74. ;
  75. ATTTBL:    DB     TRASH,  TRASH,  TRASH,  TRASH    ; ^@ thru ^C
  76.     DB     TRASH,  TRASH,  TRASH,  TRASH    ; ^D thru ^G
  77.     DB     TRASH,  BLANK, ENDLIN,  TRASH    ; ^H TAB LF ^K
  78.     DB     TRASH,  TRASH,  TRASH,  TRASH    ; FF CR ^N ^O
  79.     DB     TRASH,  TRASH,  TRASH,  TRASH    ; ^P thru ^S
  80.     DB     TRASH,  TRASH,  TRASH,  TRASH    ; ^T thru ^W
  81.     DB     TRASH,  TRASH,  TRASH,  TRASH    ; ^X ^Y ^Z ESC
  82.     DB     TRASH,  TRASH,  TRASH,  TRASH    ; ^\ ^] ^^ ^_
  83.     DB     BLANK,  ALPHA,  QUOTE,  ALPHA    ; SPC EPT " #
  84.     DB     ALPHA,  ALPHA,  ALPHA,  QUOTE    ; $ % & '
  85.     DB    OPERAT, OPERAT, OPERAT, OPERAT    ; ( ) * +
  86.     DB     COMMA, OPERAT,  ALPHA, OPERAT    ; , - . /
  87.     DB    NUMERC, NUMERC, NUMERC, NUMERC    ; 0 thru 3
  88.     DB    NUMERC, NUMERC, NUMERC, NUMERC    ; 4 thru 7
  89.     DB    NUMERC, NUMERC,  ALPHA, ENDLIN    ; 8 9 : ;
  90.     DB    OPERAT, OPERAT, OPERAT,  ALPHA    ; < = > ?
  91.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; @ thru C
  92.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; D thru G
  93.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; H thru K
  94.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; L thru O
  95.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; P thru S
  96.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; T thru W
  97.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; X Y Z [
  98.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; \ ] ^ _
  99.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; ` a b c
  100.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; d thru g
  101.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; h thru k
  102.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; l thru o
  103.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; p thru s
  104.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; t thru w
  105.     DB     ALPHA,  ALPHA,  ALPHA,  ALPHA    ; x y z {
  106.     DB     ALPHA,  ALPHA,  ALPHA,  TRASH    ; | } ~ RUB
  107. ;
  108.     ENDFUNCTION
  109. ;
  110.     PAGE
  111. ;
  112. ; This function gets operator number num from the operator table.  The function
  113. ; returns 0 if the operator was not found, 1 if it was.
  114. ;
  115. ; Function is called as follows:
  116. ;
  117. ;    getopr(num,opratr,bs,token);
  118. ;
  119. ;    num    Character containing the number of the desired entry.
  120. ;            0 represents the first entry in the table.  The
  121. ;            table is in alphabetical order for the benefit
  122. ;            of the binary searching routine (written in C).
  123. ;    opratr    Pointer to a 5-character array which will receive the
  124. ;            operator's name (null terminated).
  125. ;    bs    A dud argument to maintain compatibility with getopc.
  126. ;    token    A pointer to a character that will receive the operator's
  127. ;            token byte.
  128. ;
  129. NUM    EQU    ARG0
  130. OPRATR    EQU    ARG1
  131. BS    EQU    ARG2
  132. TOKEN    EQU    ARG3
  133. ;
  134.     FUNCTION GETOPR
  135. ;
  136.     LXI    H, NUM        ;Get entry number.
  137.     DAD    SP
  138.     MOV    A,M
  139.     CPI    OPRTLL        ;Entry in table?
  140.     LXI    H, 0        ;If not, return 0.
  141.     RNC
  142. ;
  143.     MOV    L,A        ;Find entry by computing
  144.     ADD    A        ;(5 * num) + table base.
  145.     ADD    A
  146.     ADD    L
  147.     MOV    L,A
  148.     LXI    D, OPRTBL
  149.     DAD    D
  150.     MOV    E,L
  151.     MOV    D,H
  152. ;
  153.     LXI    H, OPRATR    ;Find operator return area.
  154.     DAD    SP
  155.     MOV    A,M
  156.     INX    H
  157.     MOV    H,M
  158.     MOV    L,A
  159. ;
  160.     PUSH    B        ;Move operator name to return area.
  161.     MVI    C, 4
  162. MOVOPR:    LDAX    D
  163.     INX    D
  164.     MOV    M,A
  165.     INX    H
  166.     DCR    C
  167.     JNZ    MOVOPR
  168.     POP    B
  169. ;
  170.     MVI    M, 0        ;Terminate operator name.
  171. ;
  172.     LXI    H, TOKEN    ;Find token return area.
  173.     DAD    SP
  174.     MOV    A,M
  175.     INX    H
  176.     MOV    H,M
  177.     MOV    L,A
  178. ;
  179.     LDAX    D        ;Move token to return area.
  180.     MOV    M,A
  181. ;
  182.     LXI    H, 1        ;Return 1 for successful get.
  183.     RET
  184. ;
  185. ; The operator table itself:
  186. ;
  187. ;    The operator tokens are as follows:
  188. ;
  189. GETKN    EQU    1
  190. NETKN    EQU    2
  191. LETKN    EQU    3
  192. ANDTKN    EQU    4
  193. ORTKN    EQU    5
  194. XORTKN    EQU    6
  195. NOTTKN    EQU    7
  196. MODTKN    EQU    8
  197. SHLTKN    EQU    9
  198. SHRTKN    EQU    10
  199. HITKN    EQU    11
  200. LOWTKN    EQU    12
  201. GTTKN    EQU    '>'
  202. EQTKN    EQU    '='
  203. LTTKN    EQU    '<'
  204. ;
  205. OPRTLB    EQU    $
  206.  
  207. OPRTBL:    DB    'AND', 0,    ANDTKN
  208.     DB    'EQ', 0, 0,    EQTKN
  209.     DB    'GE', 0, 0,    GETKN
  210.     DB    'GT', 0, 0,    GTTKN
  211.     DB    'HIGH',        HITKN
  212.     DB    'LE', 0, 0,    LETKN
  213.     DB    'LOW', 0,    LOWTKN
  214.     DB    'LT', 0, 0,    LTTKN
  215.     DB    'MOD', 0,    MODTKN
  216.     DB    'NE', 0, 0,    NETKN
  217.     DB    'NOT', 0,    NOTTKN
  218.     DB    'OR', 0, 0,    ORTKN
  219.     DB    'SHL', 0,    SHLTKN
  220.     DB    'SHR', 0,    SHRTKN
  221.     DB    'XOR', 0,    XORTKN
  222. ;
  223. OPRTLL    EQU    ($ - OPRTLB) / 5    ;Calculate length of table.
  224. ;
  225.     ENDFUNCTION
  226. ;
  227.     PAGE
  228. ;
  229. ; This function returns the number of operators in the operator table
  230. ; for the benefit of the binary searching routine (written in C).
  231. ;
  232. ; This function is called as follows:
  233. ;
  234. ;    numoprs();
  235. ;
  236.     FUNCTION NUMOPRS
  237. ;
  238.     LXI    H, OPRTLL    ;Return number of opcodes.
  239.     RET
  240. ;
  241.     ENDFUNCTION
  242. ;
  243. ; End of package:
  244. ;
  245.     END
  246. ;    The o