Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions mach/mc6800/Action
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name "Motorola 6800 assembler"
dir as
end
name "Motorola 6800 backend"
dir cg
end
#name "Motorola 6800 download program(s)"
#dir dl
#end
name "Motorola 6800 EM library"
dir libem
end
name "Motorola 6800 etext,edata,end library"
dir libend
end
name "Motorola 6800 MON library"
dir libmon
end
name "Motorola 6800 system call library"
dir libsys
end
16 changes: 16 additions & 0 deletions mach/mc6800/as/mach0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define RCSID0 "$Id$"

/*
* Motorola 6800 options
*/

#define BYTES_REVERSED
#define WORDS_REVERSED
#define THREE_PASS
#define LISTING
#define RELOCATION
#define DEBUG 1
12 changes: 12 additions & 0 deletions mach/mc6800/as/mach1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define RCSID1 "$Id$"

/*
* Motorola 6800 C declarations
*/

void branch(int opc, expr_t exp);

20 changes: 20 additions & 0 deletions mach/mc6800/as/mach2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define RCSID2 "$Id$"

/*
* Motorola 6800 tokens
*/

%token <y_word> X
%token <y_word> EXTENSION
%token <y_word> NOARG
%token <y_word> BRANCH
%token <y_word> AOP
%token <y_word> XOP

%type <y_word> memref

%nonassoc EXTENSION
124 changes: 124 additions & 0 deletions mach/mc6800/as/mach3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define RCSID3 "$Id$"

/*
* Motorola 6800 keywords
*/
{0, EXTENSION, 0, ".l"},
{0, EXTENSION, 8, ".h"},
{0, X, 0, "x"},
{0, NOARG, 0x01, "nop"},
{0, NOARG, 0x06, "tap"},
{0, NOARG, 0x07, "tpa"},
{0, NOARG, 0x08, "inx"},
{0, NOARG, 0x09, "dex"},
{0, NOARG, 0x0A, "clv"},
{0, NOARG, 0x0B, "sev"},
{0, NOARG, 0x0C, "clc"},
{0, NOARG, 0x0D, "sec"},
{0, NOARG, 0x0E, "cli"},
{0, NOARG, 0x0F, "sei"},
{0, NOARG, 0x10, "sba"},
{0, NOARG, 0x11, "cba"},
{0, NOARG, 0x16, "tab"},
{0, NOARG, 0x17, "tba"},
{0, NOARG, 0x19, "daa"},
{0, NOARG, 0x1B, "aba"},
{0, BRANCH, 0x20, "bra"},
{0, BRANCH, 0x22, "bhi"},
{0, BRANCH, 0x23, "bls"},
{0, BRANCH, 0x24, "bcc"},
{0, BRANCH, 0x24, "bhs"}, /* bcc */
{0, BRANCH, 0x25, "bcs"},
{0, BRANCH, 0x25, "blo"}, /* bcs */
{0, BRANCH, 0x26, "bne"},
{0, BRANCH, 0x27, "beq"},
{0, BRANCH, 0x28, "bvc"},
{0, BRANCH, 0x29, "bvs"},
{0, BRANCH, 0x2A, "bpl"},
{0, BRANCH, 0x2B, "bmi"},
{0, BRANCH, 0x2C, "bge"},
{0, BRANCH, 0x2D, "blt"},
{0, BRANCH, 0x2E, "bgt"},
{0, BRANCH, 0x2F, "ble"},
{0, NOARG, 0x30, "tsx"},
{0, NOARG, 0x31, "ins"},
{0, NOARG, 0x32, "pula"},
{0, NOARG, 0x33, "pulb"},
{0, NOARG, 0x34, "des"},
{0, NOARG, 0x35, "txs"},
{0, NOARG, 0x36, "psha"},
{0, NOARG, 0x37, "pshb"},
{0, NOARG, 0x39, "rts"},
{0, NOARG, 0x3B, "rti"},
{0, NOARG, 0x3E, "wai"},
{0, NOARG, 0x3F, "swi"},
{0, NOARG, 0x40, "nega"},
{0, NOARG, 0x43, "coma"},
{0, NOARG, 0x44, "lsra"},
{0, NOARG, 0x46, "rora"},
{0, NOARG, 0x47, "asra"},
{0, NOARG, 0x48, "asla"},
{0, NOARG, 0x48, "lsla"},
{0, NOARG, 0x49, "rola"},
{0, NOARG, 0x4A, "deca"},
{0, NOARG, 0x4C, "inca"},
{0, NOARG, 0x4D, "tsta"},
{0, NOARG, 0x4F, "clra"},
{0, NOARG, 0x50, "negb"},
{0, NOARG, 0x53, "comb"},
{0, NOARG, 0x54, "lsrb"},
{0, NOARG, 0x56, "rorb"},
{0, NOARG, 0x57, "asrb"},
{0, NOARG, 0x58, "aslb"},
{0, NOARG, 0x58, "lslb"},
{0, NOARG, 0x59, "rolb"},
{0, NOARG, 0x5A, "decb"},
{0, NOARG, 0x5C, "incb"},
{0, NOARG, 0x5D, "tstb"},
{0, NOARG, 0x5F, "clrb"},
{0, AOP, 0x60, "neg"},
{0, AOP, 0x63, "com"},
{0, AOP, 0x64, "lsr"},
{0, AOP, 0x66, "ror"},
{0, AOP, 0x67, "asr"},
{0, AOP, 0x68, "asl"},
{0, AOP, 0x68, "lsl"},
{0, AOP, 0x69, "rol"},
{0, AOP, 0x6A, "dec"},
{0, AOP, 0x6C, "inc"},
{0, AOP, 0x6D, "tst"},
{0, XOP, 0x6E, "jmp"},
{0, AOP, 0x6F, "clr"},
{0, BRANCH, 0x8D, "bsr"},
{0, XOP, 0xA0, "suba"},
{0, XOP, 0xA1, "cmpa"},
{0, XOP, 0xA2, "sbca"},
{0, XOP, 0xA4, "anda"},
{0, XOP, 0xA5, "bita"},
{0, XOP, 0xA6, "ldaa"},
{0, XOP, 0xA7, "staa"},
{0, XOP, 0xA8, "eora"},
{0, XOP, 0xA9, "adca"},
{0, XOP, 0xAA, "oraa"},
{0, XOP, 0xAB, "adda"},
{0, XOP, 0xAC, "cpx"},
{0, XOP, 0xAD, "jsr"},
{0, XOP, 0xAE, "lds"},
{0, XOP, 0xAF, "sts"},
{0, XOP, 0xE0, "subb"},
{0, XOP, 0xE1, "cmpb"},
{0, XOP, 0xE2, "sbcb"},
{0, XOP, 0xE4, "andb"},
{0, XOP, 0xE5, "bitb"},
{0, XOP, 0xE6, "ldab"},
{0, XOP, 0xE7, "stab"},
{0, XOP, 0xE8, "eorb"},
{0, XOP, 0xE9, "adcb"},
{0, XOP, 0xEA, "orab"},
{0, XOP, 0xEB, "addb"},
{0, XOP, 0xEE, "ldx"},
{0, XOP, 0xEF, "stx"},
85 changes: 85 additions & 0 deletions mach/mc6800/as/mach4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#define RCSID4 "$Id$"

/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
*/

/*
* Motorola 6800 parsing rules
*/

expr
: expr EXTENSION
{ $$.val = ($1.val >> $2) & 0xFF;
#ifdef RELOCATION
$$.typ = combine($1.typ, S_ABS, '&');
/* This will generate an 'invalid operator' */
/* error if $1.typ is not absolute after pass 1. */
#else
$$.typ = $1.typ; /* Even if $1.typ is relocatable, it should be */
/* absolute by the final pass. */
#endif /* RELOCATION */
}
;
operation
:
NOARG
{ emit1($1);}
|
BRANCH expr
{ branch($1,$2);}
|
XOP '#' expr
{ emit1($1 - 0x20);
switch ($1 & 0x0F) {
case 0x03:
case 0x0C:
case 0x0E:
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($3.typ, RELO2|RELBR);
#endif
emit2($3.val);
break;
default:
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($3.typ, RELO1);
#endif
emit1($3.val);
}
}
|
XOP '<' expr
{ emit1($1 - 0x10);
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($3.typ, RELO1);
#endif
emit1($3.val);
}
|
memref expr
{ emit1($1 + 0x10);
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($2.typ, RELO2|RELBR);
#endif
emit2($2.val);
}
|
memref expr ',' X
{ emit1($1);
#ifdef RELOCATION
newrelo($2.typ, RELO1);
#endif
emit1($2.val);
}
;
memref :
AOP
|
XOP
;
47 changes: 47 additions & 0 deletions mach/mc6800/as/mach5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define RCSID5 "$Id$"

/*
* Motorola 6800 special routines
*/

void branch(int opc,expr_t exp)
{
int sm, dist;
int saving;

dist = exp.val - (DOTVAL + 2);
if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
dist -= DOTGAIN;
sm = fitb(dist);
if ((exp.typ & ~S_DOT) != DOTTYP)
sm = 0;
if (opc == 0x8D || opc == 0x20)
saving = 1;
else
saving = 3;
if (small(sm,saving)) {
emit1(opc);
emit1(dist);
} else {
if (opc == 0x8D) /* bsr */
emit1(0xBD); /* jsr */
else {
if (opc != 0x20) { /* bra */

/* reverse condition : */

emit1(opc ^ 1);
emit1(3);
}
emit1(0x7E); /* jmp */
}
#ifdef RELOCATION
newrelo(exp.typ, RELO2 | RELBR);
#endif
emit2(exp.val);
}
}
3 changes: 3 additions & 0 deletions mach/mc6800/cg/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from build.c import clibrary

clibrary(name="cg", hdrs={"mach.h": "./mach.h", "mach.c": "./mach.c"})
Loading
Loading