home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / appleii / apxa2.c / assm0.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  7KB  |  220 lines

  1. #include "stdio.h"
  2. #include "assm.d1"
  3.  
  4. /*  Assembler for the MOS Technology 650X series of microprocessors
  5.  *  Written by J. H. Van Ornum (201) 949-1781
  6.  *        AT&T Bell Laboratories
  7.  *         Holmdel, NJ
  8.  */
  9.  
  10. FILE    *optr;
  11. FILE    *iptr;
  12. int    dflag;            /* debug flag */
  13. int    errcnt;            /* error counter */
  14. int    hash_tbl[128];        /* pointers to starting links in symtab */
  15. char    hex[5];            /* hexadecimal character buffer */
  16. int    iflag;            /* ignore .nlst flag */
  17. int    lablptr;        /* label pointer into symbol table */
  18. int    lflag;            /* disable listing flag */
  19. int    loccnt;            /* location counter    */
  20. int    nflag;            /* normal/split address mode */
  21. int    nxt_free;        /* next free location in symtab */
  22. int    objcnt;            /* object byte counter */
  23. int    oflag;            /* object output flag */
  24. int    opflg;            /* operation code flags */
  25. int    opval;            /* operation code value */
  26. int    pass;            /* pass counter        */
  27. char    prlnbuf[LAST_CH_POS+1]; /* print line buffer    */
  28. int    sflag;            /* symbol table output flag */
  29. int    slnum;            /* source line number counter */
  30. char    symtab[STABSZ];        /* symbol table        */
  31.                 /* struct sym_tab        */
  32.                 /* {    char    size;        */
  33.                 /*    char    chars[size];    */
  34.                 /*    char    flag;        */
  35.                 /*    int    value;        */
  36.                 /*    int    next_pointer    */
  37.                 /* }                */
  38. char    symbol[SBOLSZ];        /* temporary symbol storage    */
  39. int    udtype;            /* undefined symbol type    */
  40. int    undef;            /* undefined symbol in expression flg  */
  41. int    value;            /* operand field value */
  42. char    zpref;            /* zero page reference flag    */
  43. int    msb    = 0x80 ;        /* hibit for bytes */
  44.  
  45.  
  46. #define A    0x20)+('A'&0x1f))
  47. #define B    0x20)+('B'&0x1f))
  48. #define C    0x20)+('C'&0x1f))
  49. #define D    0x20)+('D'&0x1f))
  50. #define E    0x20)+('E'&0x1f))
  51. #define F    0x20)+('F'&0x1f))
  52. #define G    0x20)+('G'&0x1f))
  53. #define H    0x20)+('H'&0x1f))
  54. #define I    0x20)+('I'&0x1f))
  55. #define J    0x20)+('J'&0x1f))
  56. #define K    0x20)+('K'&0x1f))
  57. #define L    0x20)+('L'&0x1f))
  58. #define M    0x20)+('M'&0x1f))
  59. #define N    0x20)+('N'&0x1f))
  60. #define O    0x20)+('O'&0x1f))
  61. #define P    0x20)+('P'&0x1f))
  62. #define Q    0x20)+('Q'&0x1f))
  63. #define R    0x20)+('R'&0x1f))
  64. #define S    0x20)+('S'&0x1f))
  65. #define T    0x20)+('T'&0x1f))
  66. #define U    0x20)+('U'&0x1f))
  67. #define V    0x20)+('V'&0x1f))
  68. #define W    0x20)+('W'&0x1f))
  69. #define X    0x20)+('X'&0x1f))
  70. #define Y    0x20)+('Y'&0x1f))
  71. #define Z    0x20)+('Z'&0x1f))
  72.  
  73. #define OPSIZE    127
  74.  
  75. int    optab[]    =        /* nmemonic  operation code table    */
  76. {                /* '.' = 31, '*' = 30, '=' = 29        */
  77.     ((0*0x20)+(29)),PSEUDO,1,
  78.     ((0*0x20)+(29)),PSEUDO,1,
  79.     ((((0*D*S,PSEUDO,7,
  80.     ((((0*D*S,PSEUDO,7,
  81.     ((((0*D*W,PSEUDO,2,
  82.     ((((0*D*W,PSEUDO,2,
  83.     ((((0*0x20)+(30))*0x20)+(29)),PSEUDO,3,
  84.     ((((0*0x20)+(30))*0x20)+(29)),PSEUDO,3,
  85.     ((((((0*A*D*C,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x61,
  86.     ((((((0*A*D*C,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x61,
  87.     ((((((0*A*N*D,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x21,
  88.     ((((((0*A*N*D,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x21,
  89.     ((((((0*A*S*C,PSEUDO,8,
  90.     ((((((0*A*S*C,PSEUDO,8,
  91.     ((((((0*A*S*L,ABS|ZER|ZERX|ABSX|ACC,0x02,
  92.     ((((((0*A*S*L,ABS|ZER|ZERX|ABSX|ACC,0x02,
  93.     ((((((0*B*C*C,CLASS2,0x90,
  94.     ((((((0*B*C*C,CLASS2,0x90,
  95.     ((((((0*B*C*S,CLASS2,0xb0,
  96.     ((((((0*B*C*S,CLASS2,0xb0,
  97.     ((((((0*B*E*Q,CLASS2,0xf0,
  98.     ((((((0*B*E*Q,CLASS2,0xf0,
  99.     ((((((0*B*I*T,ABS|ZER,0x20,
  100.     ((((((0*B*I*T,ABS|ZER,0x20,
  101.     ((((((0*B*M*I,CLASS2,0x30,
  102.     ((((((0*B*M*I,CLASS2,0x30,
  103.     ((((((0*B*N*E,CLASS2,0xd0,
  104.     ((((((0*B*N*E,CLASS2,0xd0,
  105.     ((((((0*B*P*L,CLASS2,0x10,
  106.     ((((((0*B*P*L,CLASS2,0x10,
  107.     ((((((0*B*R*K,CLASS1,0x00,
  108.     ((((((0*B*R*K,CLASS1,0x00,
  109.     ((((((0*B*V*C,CLASS2,0x50,
  110.     ((((((0*B*V*C,CLASS2,0x50,
  111.     ((((((0*B*V*S,CLASS2,0x70,
  112.     ((((((0*B*V*S,CLASS2,0x70,
  113.     ((((((0*C*L*C,CLASS1,0x18,
  114.     ((((((0*C*L*C,CLASS1,0x18,
  115.     ((((((0*C*L*D,CLASS1,0xd8,
  116.     ((((((0*C*L*D,CLASS1,0xd8,
  117.     ((((((0*C*L*I,CLASS1,0x58,
  118.     ((((((0*C*L*I,CLASS1,0x58,
  119.     ((((((0*C*L*V,CLASS1,0xb8,
  120.     ((((((0*C*L*V,CLASS1,0xb8,
  121.     ((((((0*C*M*P,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xc1,
  122.     ((((((0*C*M*P,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xc1,
  123.     ((((((0*C*P*X,IMM1|ABS|ZER,0xe0,
  124.     ((((((0*C*P*X,IMM1|ABS|ZER,0xe0,
  125.     ((((((0*C*P*Y,IMM1|ABS|ZER,0xc0,
  126.     ((((((0*C*P*Y,IMM1|ABS|ZER,0xc0,
  127.     ((((((0*D*E*C,ABS|ZER|ZERX|ABSX,0xc2,
  128.     ((((((0*D*E*C,ABS|ZER|ZERX|ABSX,0xc2,
  129.     ((((((0*D*E*X,CLASS1,0xca,
  130.     ((((((0*D*E*X,CLASS1,0xca,
  131.     ((((((0*D*E*Y,CLASS1,0x88,
  132.     ((((((0*D*E*Y,CLASS1,0x88,
  133.     ((((((0*D*F*B,PSEUDO,0,
  134.     ((((((0*D*F*B,PSEUDO,0,
  135.     ((((((0*E*O*R,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x41,
  136.     ((((((0*E*O*R,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x41,
  137.     ((((((0*E*Q*U,PSEUDO,1,
  138.     ((((((0*E*Q*U,PSEUDO,1,
  139.     ((((((0*I*N*C,ABS|ZER|ZERX|ABSX,0xe2,
  140.     ((((((0*I*N*X,CLASS1,0xe8,
  141.     ((((((0*I*N*X,CLASS1,0xe8,
  142.     ((((((0*I*N*Y,CLASS1,0xc8,
  143.     ((((((0*I*N*Y,CLASS1,0xc8,
  144.     ((((((0*J*M*P,ABS|IND,0x40,
  145.     ((((((0*J*M*P,ABS|IND,0x40,
  146.     ((((((0*J*S*R,ABS,0x14,
  147.     ((((((0*L*D*A,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xa1,
  148.     ((((((0*L*D*A,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xa1,
  149.     ((((((0*L*D*X,IMM1|ABS|ZER|ABSY2|ZERY,0xa2,
  150.     ((((((0*L*D*X,IMM1|ABS|ZER|ABSY2|ZERY,0xa2,
  151.     ((((((0*L*D*Y,IMM1|ABS|ZER|ABSX|ZERX,0xa0,
  152.     ((((((0*L*D*Y,IMM1|ABS|ZER|ABSX|ZERX,0xa0,
  153.     ((((((0*L*S*R,ABS|ZER|ZERX|ABSX|ACC,0x42,
  154.     ((((((0*M*S*B,PSEUDO,13,
  155.     ((((((0*N*O*P,CLASS1,0xea,
  156.     ((((((0*O*R*A,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x01,
  157.     ((((((0*O*R*G,PSEUDO,3,
  158.     ((((((0*O*R*G,PSEUDO,3,
  159.     ((((((0*P*H*A,CLASS1,0x48,
  160.     ((((((0*P*H*A,CLASS1,0x48,
  161.     ((((((0*P*H*P,CLASS1,0x08,
  162.     ((((((0*P*L*A,CLASS1,0x68,
  163.     ((((((0*P*L*A,CLASS1,0x68,
  164.     ((((((0*P*L*P,CLASS1,0x28,
  165.     ((((((0*P*L*P,CLASS1,0x28,
  166.     ((((((0*R*O*L,ABS|ZER|ZERX|ABSX|ACC,0x22,
  167.     ((((((0*R*O*L,ABS|ZER|ZERX|ABSX|ACC,0x22,
  168.     ((((((0*R*O*R,ABS|ZER|ZERX|ABSX|ACC,0x62,
  169.     ((((((0*R*O*R,ABS|ZER|ZERX|ABSX|ACC,0x62,
  170.     ((((((0*R*T*I,CLASS1,0x40,
  171.     ((((((0*R*T*S,CLASS1,0x60,
  172.     ((((((0*R*T*S,CLASS1,0x60,
  173.     ((((((0*S*B*C,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xe1,
  174.     ((((((0*S*B*C,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xe1,
  175.     ((((((0*S*E*C,CLASS1,0x38,
  176.     ((((((0*S*E*D,CLASS1,0xf8,
  177.     ((((((0*S*E*D,CLASS1,0xf8,
  178.     ((((((0*S*E*I,CLASS1,0x78,
  179.     ((((((0*S*E*I,CLASS1,0x78,
  180.     ((((((0*S*T*A,ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x81,
  181.     ((((((0*S*T*X,ABS|ZER|ZERY,0x82,
  182.     ((((((0*S*T*X,ABS|ZER|ZERY,0x82,
  183.     ((((((0*S*T*Y,ABS|ZER|ZERX,0x80,
  184.     ((((((0*T*A*X,CLASS1,0xaa,
  185.     ((((((0*T*A*X,CLASS1,0xaa,
  186.     ((((((0*T*A*Y,CLASS1,0xa8,
  187.     ((((((0*T*S*X,CLASS1,0xba,
  188.     ((((((0*T*S*X,CLASS1,0xba,
  189.     ((((((0*T*X*A,CLASS1,0x8a,
  190.     ((((((0*T*X*A,CLASS1,0x8a,
  191.     ((((((0*T*X*S,CLASS1,0x9a,
  192.     ((((((0*T*X*S,CLASS1,0x9a,
  193.     ((((((0*T*Y*A,CLASS1,0x98,
  194.     ((((((0*T*Y*A,CLASS1,0x98,
  195.     ((((((0*0x20)+(31))*W*O^((((0*R*D,PSEUDO,2,    /* 0x7cab */
  196.     ((((((0*0x20)+(31))*W*O^((((0*R*D,PSEUDO,2,    /* 0x7cab */
  197.     ((((((0*0x20)+(31))*B*Y^((((0*T*E,PSEUDO,0,    /* 0x7edc */
  198.     ((((((0*0x20)+(31))*B*Y^((((0*T*E,PSEUDO,0,    /* 0x7edc */
  199.     ((((((0*0x20)+(31))*D*B^((((0*Y*T,PSEUDO,6,    /* 0x7fb6 */
  200.     ((((((0*0x20)+(31))*N*L^((((0*S*T,PSEUDO,5,    /* 0x7fb8 */
  201.     ((((((0*0x20)+(31))*L*I^((((0*S*T,PSEUDO,4,    /* 0x7ffd */
  202.     0x7fff,0,0,
  203.     0x7fff,0,0,
  204.     0x7fff,0,0,
  205.     0x7fff,0,0
  206. };
  207.  
  208. int    step[] =
  209. {
  210.     3*((OPSIZE+1)/2),
  211.     3*((((OPSIZE+1)/2)+1)/2),
  212.     3*((((((OPSIZE+1)/2)+1)/2)+1)/2),
  213.     3*((((((((OPSIZE+1)/2)+1)/2)+1)/2)+1)/2),
  214.     3*(4),
  215.     3*(3),
  216.     3*(2),
  217.     3*(1),
  218.     0
  219. };
  220.