Motorola 6809 cross-assembler (part 1 of 2)
Jack Jansen
jack at vu44.UUCP
Tue Feb 19 20:44:51 AEST 1985
: 'This is a shell archive. Run with the real shell,'
: 'not the seashell. It should extract the following:'
: ' Read_Me Makefile a6809 mkmnem.p mneminput '
echo x - Read_Me
sed 's/^X//' <<'EndOfFile' >Read_Me
XThis directory contains the source to the htsa 6809 assembler.
XIt is written in ISO standard pascal, and has been tested on a
XPDP 11/34 running unix v7m, using the VU pascal compiler.
X
XIt can also be used on a PRIME, if you have the Sheffield compiler,
Xthat is, PASCAL-S. The Prime standard pascal compiler won't compile it.
XIf a version for the prime is to be made, a "#define PRIME" statement
Xshould be added near the beginning of a6809.p.
X
XIf your pascal compiler does not call the C preprocessor, you
Xshould feed the 'a6809.p' source through cpp yourself.
XIf you don't have cpp, you should either obtain one (there was
Xa public domain cpp in net.sources and mod.sources recently),
Xor massage the files by hand. The only thing that #defined identifiers
Xare used for is for conditional compilation using #ifdef, so this
Xshouldn't be too hard.
XIf you are baffled by this, I can send you a tiny tiny cpp I wrote
Xin pascal for the prime if you send me a mail. I didn't include it
Xhere, however, since I'm not very proud of the code (this was an
Xunderstatement).
X
XThe assembler accepts standard Motorola 6809 assembly language, with
Xone known exception, nl. that the words PC and PCR can be used
Xinterchangeably, where Motorola only accepts PCR for PC Relative, and
XPC on PSH and PUL instructions.
XThe object file is in 'S1 format', as accepted by the ExorMacs systems,
Xand most other 680? based systems.
X
XThe assembler does not have any of the nifty features like
Xmacros, conditional assembly, relocatable binaries, etc.
XIf anyone feels like hacking it in, I would be *very* happy
Xif you sent us a copy. Especially relocatable output is something
Xthat would be very handy, and the only reason it isn't implemented
Xyet is lack of time.
X
XI'm planning to setup a mailing list for bugs, extensions, etc.
Xso I would be very happy if everyone who is planning to use the
Xassembler would mail his electronic address to mcvax!vu44!htsa!a6809-list.
XIf you find any bugs, also mail them there, and I'll try to fix them,
Xor distribute any fixes that I have received.
X
XOne more apology is probably in place here: Most of the comment
Xis in Dutch( :-) for me, :-( for you). Sorry, but I'm short on
Xtime these days, so I didn't have time to wade through the
Xsources (I already had to write a manual, so.....).
X
XThe following files are in this directory :
X
XMakefile make input file, if you have the VU pascal compiler.
Xa6809 shell file to run the assembler.
Xa6809.1 Manual page in -man format.
Xa6809.man Manual page, ready for displaying.
Xa6809.p Main program. Includes all the '.inc' files.
Xaserr Shell file to get erronuous lines from a listing.
Xexec.inc Code generator source file.
Xinpt.inc Input routines source file.
Xmkmnem.p Separate program to make a mnemonics file.
Xmneminput Input file for mkmnem.p
Xoutp.inc Output routines source file.
Xpars.inc Parser source file.
Xsymb.inc Symbol table handling source file.
X
X Jack Jansen Hans Pronk
X Hogere Technische School "Amsterdam"
X Europaboulevard 23
X Amsterdam
X Holland
X Tel: +31 20 429333
X uucp: {decvax|seismo|philabs}!mcvax!vu44!htsa!jack
X ..!htsa!haper
X arpa: "decvax!mcvax!vu44!htsa!jack"@Berkeley.ARPA
X "decvax!mcvax!vu44!htsa!haper"@Berkeley.ARPA
X
XPS: Since Hans is still working full time at the HTS, and I'm only
Xhere one day in the week, it is probably wiser to mail problems,
Xetc to htsa!haper.
EndOfFile
echo x - Makefile
sed 's/^X//' <<'EndOfFile' >Makefile
X#
X# Makefile for a6809 assembler.
X#
XASSRC = a6809.p symb.inc inpt.inc outp.inc pars.inc exec.inc
XASOTHER = Read_Me Makefile a6809 mkmnem.p mneminput
Xall: mnemtab a6809prg
X
Xinstall: all a6809 aserr
X cp a6809 /usr/bin/a6809
X cp a6809prg /usr/lib/a6809prg
X cp mnemtab /usr/etc/a6809:mnemtab
X cp aserr /usr/bin/aserr
X
Xmnemtab: mneminput mkmnem
X mkmnem mneminput mnemtab
X
Xmkmnem: mkmnem.p
X pc -C mkmnem.p -o mkmnem
X
Xa6809prg: $(ASSRC)
X pc -C -I a6809.p -o a6809prg
X
Xa6809int: $(ASSRC)
X pc -I a6809.p -o a6809int
X
Xa6809lst: $(ASSRC)
X pc -C -E -I a6809.p -o a6809prg >a6809lst
X
XDistr: Distr.1 Distr.2
X
XDistr.1: $(ASOTHER)
X shar $(ASOTHER) >Distr.1
X
XDistr.2: $(ASSRC)
X shar $(ASSRC) >Distr.2
EndOfFile
echo x - a6809
sed 's/^X//' <<'EndOfFile' >a6809
X: a6809 interlude.
Xcase $# in
X0) echo "Usage * $0 [-nl] [-nh] source "
X echo " Hex op 'source.hex', listing op 'source.list'."
X echo " -nl: geen listing; -nh: geen hexfile."
X exit
X ;;
Xesac
X
Xasm=/usr/lib/a6809prg
Xtable=/usr/etc/a6809:mnemtab
Xdodbg=0
Xdolst=1
Xdohex=1
Xdosmbl=0
X
Xwhile expr "X$1" : "X-" != 0 >/dev/null; do
X case $1 in
X -s) dosmbl=1 ; shift ;;
X -d) dodbg=1 ; shift ;;
X -nl) dolst=0 ; shift ;;
X -nh) dohex=0 ; shift ;;
X -*) echo Onbekende optie $1 ; exit ;;
X esac
Xdone
X
Xcase $# in
X0) echo Geen sourcefile gegeven.
X exit
Xesac
X
Xsource=$1.src
Xif test ! -r $source
Xthen
X source=$1
X if test ! -r $source
X then
X echo "Non-existent sourcefile"
X exit
X fi
Xfi
X
Xobj=`basename $source .src`.hex
Xlst=`basename $source .src`.list
X
Xcase $dolst in
X0) lst=/dev/tty ;;
Xesac
Xcase $dohex in
X0) obj=/tmp/ast$$ ;;
Xesac
Xecho $dohex $dolst $dodbg $dosmbl >$obj
X$asm $source $obj $table >$lst
X
Xcase $dolst in
X1) aserr $lst
Xesac
EndOfFile
echo x - mkmnem.p
sed 's/^X//' <<'EndOfFile' >mkmnem.p
X#
XPROGRAM MKMNEM(INPUT,OUTPUT,INFILE,OUTFILE);
X(* Make mnemonic file for A6809 *)
X
X(* #define PRIME (* For the PRIME, or *)
X#define UNIX (* For UNIX *)
X
XCONST
X MAXMNEM = 160;
X STRSIZE = 6;
X
XTYPE
X STRING = PACKED ARRAY [1..STRSIZE] OF CHAR;
X OPTYPE = ( OPNAM, OPFCB, OPFCC, OPRMB, OPEQU, OPSDP, OPEND,
X OPOPT, OP0, OP1B, OP1W, OPEMT, OPREL, OPREG, OPSTK );
X
X MNEMRECORD = RECORD
X NAME : STRING;
X OPT : OPTYPE;
X OPC : INTEGER;
X END;
X
XVAR
X CONV : ARRAY [ 0 .. 14 ] OF OPTYPE;
X INFILE : TEXT;
X OUTFILE : FILE OF MNEMRECORD;
X TABLE : ARRAY[1..MAXMNEM] OF MNEMRECORD;
X NROFELEM , I , J : INTEGER;
X#ifdef PRIME
X FNAME : PACKED ARRAY [1..32] OF CHAR;
X#endif
X
X#ifdef PRIME
XVALUE
X CONV = ( OPNAM,OPFCB,OPFCC,OPRMB,OPEQU,OPSDP,OPEND,
X OPOPT,OP0,OP1B,OP1W,OPEMT,OPREL,OPREG,OPSTK );
X
XPROCEDURE GETFNAM;
XVAR I : INTEGER;
XBEGIN
X WHILE INPUT^ = ' ' DO GET(INPUT);
X FOR I := 1 TO 32 DO
X IF EOLN(INPUT) THEN FNAME[I] := ' ' ELSE READ(FNAME[I]);
XEND(*GETFNAM*);
X#endif
X
XPROCEDURE INSTR( VAR S : STRING);
XVAR I : INTEGER;
XBEGIN
X WHILE INFILE^ = ' ' DO GET(INFILE);
X FOR I := 1 TO STRSIZE DO
X IF INFILE^ = ' ' THEN S[I] := ' ' ELSE READ(INFILE,S[I]);
XEND(* INSTR *);
X
XPROCEDURE INHEX(VAR N : INTEGER);
XVAR D : INTEGER;
XBEGIN
X N := 0;
X WHILE INFILE^ = ' ' DO GET(INFILE);
X WHILE INFILE^ IN ['A'..'F','0'..'9'] DO BEGIN
X IF INFILE^ IN ['A'..'F']
X THEN D := ORD(INFILE^)-ORD('A')+10
X ELSE D := ORD(INFILE^)-ORD('0');
X N := N*16+D;
X GET(INFILE);
X END;
XEND (* INHEX *);
X
XPROCEDURE SORT;
XVAR I,J : INTEGER;
X DUMMY : MNEMRECORD;
XBEGIN
X FOR I := 1 TO NROFELEM DO
X FOR J := 2 TO NROFELEM DO
X IF TABLE[J].NAME < TABLE[J-1].NAME THEN BEGIN
X DUMMY := TABLE[J];
X TABLE[J] := TABLE[J-1];
X TABLE[J-1] := DUMMY;
X END;
XEND (* SORT *);
X
XBEGIN
X#ifdef PRIME
X WRITE('Input filename - ');
X GETFNAM;
X RESET(INFILE,FNAME);
X WRITE('Output filename - ');
X GETFNAM;
X REWRITE(OUTFILE,FNAME);
X#else
X RESET(INFILE);
X REWRITE(OUTFILE);
X
X CONV[ 0] := OPNAM;
X CONV[ 1] := OPFCB;
X CONV[ 2] := OPFCC;
X CONV[ 3] := OPRMB;
X CONV[ 4] := OPEQU;
X CONV[ 5] := OPSDP;
X CONV[ 6] := OPEND;
X CONV[ 7] := OPOPT;
X CONV[ 8] := OP0 ;
X CONV[ 9] := OP1B ;
X CONV[10] := OP1W ;
X CONV[11] := OPEMT;
X CONV[12] := OPREL;
X CONV[13] := OPREG;
X CONV[14] := OPSTK;
X#endif
X WRITE('Reading...');
X I := 0;
X WHILE NOT EOF(INFILE) DO BEGIN
X I := I+1;
X REPEAT
X INSTR(TABLE[I].NAME);
X IF TABLE[I].NAME[1] = '*' THEN
X READLN(INFILE);
X UNTIL TABLE[I].NAME[1] <> '*';
X READ(INFILE,J);
X TABLE[I].OPT := CONV[J];
X INHEX(TABLE[I].OPC);
X WRITE(OUTPUT,'.');
X WHILE (INFILE^ = ' ') AND NOT EOF(INFILE) DO GET(INFILE);
X END;
X NROFELEM := I;
X WRITELN;
X WRITE('Sorting...');
X SORT;
X WRITELN;
X WRITELN('Writing...');
X FOR I := 1 TO NROFELEM DO BEGIN
X OUTFILE^ := TABLE[I];
X PUT(OUTFILE);
X END;
X WRITELN;
XEND .
EndOfFile
echo x - mneminput
sed 's/^X//' <<'EndOfFile' >mneminput
XABX 8 3A
XADCA 9 89
XADCB 9 C9
XADDA 9 8B
XADDB 9 CB
XADDD 10 C3
XANDA 9 84
XANDB 9 C4
XANDCC 9 1C
X* !! ANDC is identiek aan ANDCC om compatibel te blijven met RT-11 a6809
XANDC 9 1C
XASL 9 48
XASLA 8 48
XASLB 8 58
XASR 9 47
XASRA 8 47
XASRB 8 57
XBCC 12 24
XBCS 12 25
XBEQ 12 27
XBGE 12 2C
XBGT 12 2E
XBHI 12 22
XBHS 12 24
XBITA 9 85
XBITB 9 C5
XBLE 12 2F
XBLO 12 25
XBLS 12 23
XBLT 12 2D
XBMI 12 2B
XBNE 12 26
XBPL 12 2A
XBRA 12 20
XBRN 12 21
XBSR 12 8D
XBVC 12 28
XBVS 12 29
XCLR 9 4F
XCLRA 8 4F
XCLRB 8 5F
XCMPA 9 81
XCMPB 9 C1
XCMPD 10 1083
XCMPU 10 1183
XCMPX 10 8C
XCMPS 10 118C
XCMPY 10 108C
XCOM 9 43
XCOMA 8 43
XCOMB 8 53
XCWAI 9 3C
XDAA 8 19
XDEC 9 4A
XDECA 8 4A
XDECB 8 5A
XEMT 11 3F
XEORA 9 88
XEORB 9 C8
XEXG 13 1E
XFCB 1 01
XFCC 2 00
XFDB 1 02
XINC 9 4C
XINCA 8 4C
XINCB 8 5C
XJMP 10 4E
XJSR 10 8D
XLBCC 12 1024
XLBCS 12 1025
XLBEQ 12 1027
XLBGE 12 102C
XLBGT 12 102E
XLBHI 12 1022
XLBHS 12 1024
XLBLE 12 102F
XLBLO 12 1025
XLBLS 12 1023
XLBLT 12 102D
XLBMI 12 102B
XLBNE 12 1026
XLBPL 12 102A
XLBRA 12 16
XLBRN 12 1021
XLBSR 12 17
XLBVC 12 1028
XLBVS 12 1029
XLDA 9 86
XLDAA 9 86
XLDB 9 C6
XLDAB 9 C6
XLDD 10 CC
XLDS 10 10CE
XLDU 10 CE
XLDX 10 8E
XLDY 10 108E
XLEAS 10 12
XLEAU 10 13
XLEAX 10 10
XLEAY 10 11
XLSL 9 48
XLSLA 8 48
XLSLB 8 58
XLSR 9 44
XLSRA 8 44
XLSRB 8 54
XMUL 8 3D
XNAM 0 00
XNEG 9 40
XNEGA 8 40
XNEGB 8 50
XNOP 8 12
XOPT 7 00
XORA 9 8A
XORAA 9 8A
XORB 9 CA
XORAB 9 CA
XORCC 9 1A
XORG 3 02
XPSHS 14 34
XPSHU 14 36
XPULS 14 35
XPULU 14 37
XRMB 3 01
XROL 9 49
XROLA 8 49
XROLB 8 59
XROR 9 46
XRORA 8 46
XRORB 8 56
XRTI 8 3B
XRTS 8 39
XSBCA 9 82
XSBCB 9 C2
XSEX 8 1D
XSTA 9 87
XSTAA 9 87
XSTB 9 C7
XSTAB 9 C7
XSTD 10 CD
XSTS 10 10CF
XSTU 10 CF
XSTX 10 8F
XSTY 10 108F
XSUBA 9 80
XSUBB 9 C0
XSUBD 10 83
XSWI 8 3F
XSWI2 8 103F
XSWI3 8 113F
XSYNC 8 13
XTFR 13 1F
XTST 9 4D
XTSTA 8 4D
XTSTB 8 5D
XZZZZZZ 8 FE
XEND 6 00
XEQU 4 00
XSETDP 5 00
X* SETD == SETDP, FOR RT-11 COMPATABILITY
XSETD 5 00
EndOfFile
exit
--
Jack Jansen, {seismo|philabs|decvax}!mcvax!jack
Notice new, improved, shorter and faster address ^^^^^
--
Jack Jansen, {seismo|philabs|decvax}!mcvax!jack
Notice new, improved, shorter and faster address ^^^^^
More information about the Comp.sources.unix
mailing list