*** empty log message ***
This commit is contained in:
parent
8749fb1da8
commit
eea5656df7
10
mach/6500/as/mach0.c
Normal file
10
mach/6500/as/mach0.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
#define DUK
|
||||
#define RCSID0 "$Header$"
|
||||
|
||||
/*
|
||||
* Mostek 6500 options.
|
||||
*/
|
||||
#define THREE_PASS /* Distinguish short and long branches. */
|
||||
#define LISTING /* Enable listing facilities. */
|
||||
#define RELOCATION /* Produce relocation information. */
|
||||
#define NOLD /* Output must be fed into separate linker. */
|
7
mach/6500/as/mach1.c
Normal file
7
mach/6500/as/mach1.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#define RCSID1 "$Header$"
|
||||
|
||||
/*
|
||||
* Mostek 6500 dependent C declarations.
|
||||
*/
|
||||
|
||||
#define fits_zeropage(x) (lowb(x) == (int)(x))
|
28
mach/6500/as/mach2.c
Normal file
28
mach/6500/as/mach2.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#define RCSID2 "$Header$"
|
||||
|
||||
/*
|
||||
* Mostek 6500 tokens.
|
||||
*/
|
||||
|
||||
%token <y_word> A
|
||||
%token <y_word> X
|
||||
%token <y_word> Y
|
||||
%token <y_word> EXTENSION
|
||||
%token <y_word> ADDOP
|
||||
%token <y_word> ROLOP
|
||||
%token <y_word> BRAOP
|
||||
%token <y_word> BITOP
|
||||
%token <y_word> NOPOP
|
||||
%token <y_word> CPXOP
|
||||
%token <y_word> INCOP
|
||||
%token <y_word> JMPOP
|
||||
%token <y_word> JSROP
|
||||
%token <y_word> LDXOP
|
||||
%token <y_word> LDYOP
|
||||
%token <y_word> STXOP
|
||||
%token <y_word> STYOP
|
||||
%token <y_word> PSEU
|
||||
|
||||
%type <y_word> addop
|
||||
|
||||
%nonassoc EXTENSION
|
69
mach/6500/as/mach3.c
Normal file
69
mach/6500/as/mach3.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
#define RCSID3 "$Header$"
|
||||
|
||||
/*
|
||||
* Mostek 6500 keywords
|
||||
*/
|
||||
|
||||
0, EXTENSION, 0, ".l",
|
||||
0, EXTENSION, 8, ".h",
|
||||
0, A, 0, "a",
|
||||
0, X, 0, "x",
|
||||
0, Y, 0, "y",
|
||||
0, ADDOP, 0x60, "adc",
|
||||
0, ADDOP, 0x20, "and",
|
||||
0, ADDOP, 0xC0, "cmp",
|
||||
0, ADDOP, 0x40, "eor",
|
||||
0, ADDOP, 0xA0, "lda",
|
||||
0, ADDOP, 0x00, "ora",
|
||||
0, ADDOP, 0xE0, "sbc",
|
||||
0, ADDOP, 0x80, "sta",
|
||||
0, ROLOP, 0x00, "asl",
|
||||
0, ROLOP, 0x40, "lsr",
|
||||
0, ROLOP, 0x20, "rol",
|
||||
0, ROLOP, 0x60, "ror",
|
||||
0, BRAOP, 0x90, "bcc",
|
||||
0, BRAOP, 0xB0, "bcs",
|
||||
0, BRAOP, 0xF0, "beq",
|
||||
0, BRAOP, 0x30, "bmi",
|
||||
0, BRAOP, 0xD0, "bne",
|
||||
0, BRAOP, 0x10, "bpl",
|
||||
0, BRAOP, 0x50, "bvc",
|
||||
0, BRAOP, 0x70, "bvs",
|
||||
0, BITOP, 0x24, "bit",
|
||||
0, NOPOP, 0x00, "brk",
|
||||
0, NOPOP, 0x18, "clc",
|
||||
0, NOPOP, 0xD8, "cld",
|
||||
0, NOPOP, 0x58, "cli",
|
||||
0, NOPOP, 0xB8, "clv",
|
||||
0, NOPOP, 0xCA, "dex",
|
||||
0, NOPOP, 0x88, "dey",
|
||||
0, NOPOP, 0xE8, "inx",
|
||||
0, NOPOP, 0xC8, "iny",
|
||||
0, NOPOP, 0xEA, "nop",
|
||||
0, NOPOP, 0x48, "pha",
|
||||
0, NOPOP, 0x08, "php",
|
||||
0, NOPOP, 0x68, "pla",
|
||||
0, NOPOP, 0x28, "plp",
|
||||
0, NOPOP, 0x40, "rti",
|
||||
0, NOPOP, 0x60, "rts",
|
||||
0, NOPOP, 0x38, "sec",
|
||||
0, NOPOP, 0xF8, "sed",
|
||||
0, NOPOP, 0x78, "sei",
|
||||
0, NOPOP, 0xAA, "tax",
|
||||
0, NOPOP, 0xA8, "tay",
|
||||
0, NOPOP, 0x98, "tya",
|
||||
0, NOPOP, 0xBA, "tsx",
|
||||
0, NOPOP, 0x8A, "txa",
|
||||
0, NOPOP, 0x9A, "txs",
|
||||
0, CPXOP, 0xE0, "cpx",
|
||||
0, CPXOP, 0xC0, "cpy",
|
||||
0, INCOP, 0xC0, "dec",
|
||||
0, INCOP, 0xE0, "inc",
|
||||
0, JMPOP, 0x4C, "jmp",
|
||||
0, JSROP, 0x20, "jsr",
|
||||
0, LDXOP, 0xA0, "ldx",
|
||||
0, LDYOP, 0xA0, "ldy",
|
||||
0, STXOP, 0x80, "stx",
|
||||
0, STYOP, 0x80, "sty",
|
||||
0, PSEU, 0x1860, "add",
|
||||
0, PSEU, 0x38E0, "sub",
|
157
mach/6500/as/mach4.c
Normal file
157
mach/6500/as/mach4.c
Normal file
|
@ -0,0 +1,157 @@
|
|||
#define RCSID4 "$Header$"
|
||||
|
||||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mostek 6500 parsing tables.
|
||||
*/
|
||||
|
||||
expr
|
||||
: expr EXTENSION
|
||||
{ $$.val = ($1.val >> $2) & 0xFF;
|
||||
$$.typ = combine($1.typ, S_ABS, '&');
|
||||
}
|
||||
;
|
||||
operation
|
||||
: NOPOP
|
||||
{ emit1($1); }
|
||||
| BITOP expr
|
||||
{ code($2,$1,$1+8); }
|
||||
| JMPOP expr
|
||||
{ emit1($1);
|
||||
#ifdef RELOCATION
|
||||
newrelo($2.typ, RELO2);
|
||||
#endif
|
||||
emit2($2.val);
|
||||
}
|
||||
| JMPOP '(' expr ')'
|
||||
{ emit1($1+0x20);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO2);
|
||||
#endif
|
||||
emit2($3.val);
|
||||
}
|
||||
| JSROP expr
|
||||
{ emit1($1);
|
||||
#ifdef RELOCATION
|
||||
newrelo($2.typ, RELO2);
|
||||
#endif
|
||||
emit2($2.val);
|
||||
}
|
||||
| LDXOP '#' expr
|
||||
{ emit1(0xA2);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO1);
|
||||
#endif
|
||||
emit1($3);
|
||||
}
|
||||
| LDXOP expr
|
||||
{ code($2,0xA6,0xAE); }
|
||||
| LDXOP expr ',' Y
|
||||
{ code($2,0xB6,0xBE); }
|
||||
| LDYOP '#' expr
|
||||
{ emit1(0xA0);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO1);
|
||||
#endif
|
||||
emit1($3);
|
||||
}
|
||||
| LDYOP expr
|
||||
{ code($2,0xA4,0xAC); }
|
||||
| LDYOP expr ',' X
|
||||
{ code($2,0xB4,0xBC); }
|
||||
| STXOP expr
|
||||
{ code($2,$1+0x06,$1+0x0E); }
|
||||
| STXOP expr ',' Y
|
||||
{ emit1($1+0x16);
|
||||
#ifdef RELOCATION
|
||||
newrelo($2.typ, RELO1);
|
||||
#endif
|
||||
emit1(lowb($2.val));
|
||||
}
|
||||
| STYOP expr
|
||||
{ code($2,$1+0x04,$1+0x0C); }
|
||||
| STYOP expr ',' X
|
||||
{ emit1($1+0x14);
|
||||
#ifdef RELOCATION
|
||||
newrelo($2.typ, RELO1);
|
||||
#endif
|
||||
emit1(lowb($2.val));
|
||||
}
|
||||
| addop '#' expr
|
||||
{ if ($1==0x80) serror("no store immediate");
|
||||
emit1($1+0x09);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO1);
|
||||
#endif
|
||||
emit1($3);
|
||||
}
|
||||
| addop expr
|
||||
{ code($2,$1+0x05,$1+0x0D); }
|
||||
| addop expr ',' X
|
||||
{ code($2,$1+0x15,$1+0x1D); }
|
||||
| addop expr ',' Y
|
||||
{ emit1($1+0x19);
|
||||
#ifdef RELOCATION
|
||||
newrelo($2.typ, RELO2);
|
||||
#endif
|
||||
emit2($2.val);
|
||||
}
|
||||
| addop '(' expr ',' X ')'
|
||||
{ emit1($1+0x01);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO1);
|
||||
#endif
|
||||
emit1(lowb($3.val));
|
||||
}
|
||||
| addop '(' expr ')' ',' Y
|
||||
{ emit1($1+0x11);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO1);
|
||||
#endif
|
||||
emit1(lowb($3.val));
|
||||
}
|
||||
| ROLOP /* Default is A. */
|
||||
{ emit1($1+0x0A); }
|
||||
| ROLOP A
|
||||
{ emit1($1+0x0A); }
|
||||
| ROLOP expr
|
||||
{ code($2,$1+0x06,$1+0x0E); }
|
||||
| ROLOP expr ',' X
|
||||
{ code($2,$1+0x16,$1+0x1E); }
|
||||
| BRAOP expr
|
||||
{ branch($1,$2); }
|
||||
| CPXOP '#' expr
|
||||
{ emit1($1+0x00);
|
||||
#ifdef RELOCATION
|
||||
newrelo($3.typ, RELO1);
|
||||
#endif
|
||||
emit1($3);
|
||||
}
|
||||
| CPXOP expr
|
||||
{ code($2,$1+0x04,$1+0x0C); }
|
||||
| INCOP expr
|
||||
{ code($2,$1+0x06,$1+0x0E); }
|
||||
| INCOP expr ',' X
|
||||
{ code($2,$1+0x16,$1+0x1E); }
|
||||
;
|
||||
addop
|
||||
: ADDOP
|
||||
| PSEU
|
||||
{ emit1($1>>8); $$ = $1 & 0xFF; }
|
||||
;
|
41
mach/6500/as/mach5.c
Normal file
41
mach/6500/as/mach5.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#define RCSID5 "$Header$"
|
||||
|
||||
/*
|
||||
* Mostek 6500 special routines.
|
||||
*/
|
||||
|
||||
branch(opc, exp)
|
||||
register int opc;
|
||||
expr_t exp;
|
||||
{
|
||||
register int dist;
|
||||
|
||||
dist = exp.val - (DOTVAL + 2);
|
||||
if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
|
||||
dist -= DOTGAIN;
|
||||
if (small(fitb(dist) && (exp.typ & ~S_DOT) == DOTTYP, 3)) {
|
||||
emit1(opc); emit1(dist);
|
||||
} else {
|
||||
emit1(opc^0x20); emit1(0x03); /* Skip over ... */
|
||||
emit1(0x4C); /* ... far jump. */
|
||||
#ifdef RELOCATION
|
||||
newrelo(exp.typ, RELO2);
|
||||
#endif
|
||||
emit2(exp.val);
|
||||
}
|
||||
}
|
||||
|
||||
code(exp, opc1, opc2)
|
||||
expr_t exp;
|
||||
register int opc1, opc2;
|
||||
{
|
||||
if (small((exp.typ & S_TYP) == S_ABS && fits_zeropage(exp.val), 1)) {
|
||||
emit1(opc1); emit1(exp.val);
|
||||
} else {
|
||||
emit1(opc2);
|
||||
#ifdef RELOCATION
|
||||
newrelo(exp.typ, RELO2);
|
||||
#endif
|
||||
emit2(exp.val);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue