page@swan.ulowell.edu (Bob Page) (03/16/89)
Submitted-by: gmg@hcx.uucp (Greg Garner) Posting-number: Volume 89, Issue 56 Archive-name: languages/moto-assem.2 # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # SYMTAB.C # TABLE0.H # TABLE1.H # TABLE11.H # TABLE4.H # TABLE5.H # TABLE9.H # assembler.doc # readme # This archive created: Wed Mar 15 13:34:09 1989 cat << \SHAR_EOF > SYMTAB.C /* * install --- add a symbol to the table */ install(str,val) char *str; int val; { struct link *lp; struct nlist *np,*p,*backp; struct nlist *lookup(); int i; if( !alpha(*str) ){ error("Illegal Symbol Name"); return(NO); } if( (np = lookup(str)) != NULL ){ if( Pass==2 ){ if( np->def == val ) return(YES); else{ error("Phasing Error"); return(NO); } } error("Symbol Redefined"); return(NO); } /* enter new symbol */ #ifdef DEBUG printf("Installing %s as %d\n",str,val); #endif np = (struct nlist *) alloc(sizeof(struct nlist)); if( np == (struct nlist *)ERR ){ error("Symbol table full"); return(NO); } np->name = alloc(strlen(str)+1); if( np->name == (char *)ERR ){ error("Symbol table full"); return(NO); } strcpy(np->name,str); np->def = val; np->Lnext = NULL; np->Rnext = NULL; lp = (struct link *) alloc(sizeof(struct link)); np->L_list = lp; lp->L_num = Line_num; lp->next = NULL; p = root; backp = NULL; while (p != NULL) { backp = p; i = strcmp (str,p->name); if (i<0) p=p->Lnext; else p=p->Rnext; } if (backp == NULL) root = np; else if (strcmp(str,backp->name)<0) backp->Lnext = np; else backp->Rnext = np; return (YES); } /* * lookup --- find string in symbol table */ struct nlist * lookup(name) char *name; { struct nlist *np; int i; np = root; while (np != NULL) { i = strcmp(name,np->name); if (i == 0) { Last_sym = np->def; return (np); } else if (i < 0) np = np->Lnext; else np = np->Rnext; } Last_sym = 0; if (Pass == 2) error ("symbol Undefined on pass 2"); return (NULL); } #define NMNE (sizeof(table)/ sizeof(struct oper)) #define NPSE (sizeof(pseudo)/ sizeof(struct oper)) /* * mne_look --- mnemonic lookup * * Return pointer to an oper structure if found. * Searches both the machine mnemonic table and the pseudo table. */ struct oper * mne_look(str) char *str; { struct oper *low,*high,*mid; int cond; /* Search machine mnemonics first */ low = &table[0]; high = &table[ NMNE-1 ]; while (low <= high){ mid = low + (high-low)/2; if( ( cond = strcmp(str,mid->mnemonic)) < 0) high = mid - 1; else if (cond > 0) low = mid + 1; else return(mid); } /* Check for pseudo ops */ low = &pseudo[0]; high = &pseudo[ NPSE-1 ]; while (low <= high){ mid = low + (high-low)/2; if( ( cond = strcmp(str,mid->mnemonic)) < 0) high = mid - 1; else if (cond > 0) low = mid + 1; else return(mid); } return(NULL); } SHAR_EOF cat << \SHAR_EOF > TABLE0.H struct oper table[] = { "aba", INH, 27, 2, "adca", GEN, 137, 2, "adcb", GEN, 201, 2, "adda", GEN, 139, 2, "addb", GEN, 203, 2, "anda", GEN, 132, 2, "andb", GEN, 196, 2, "asl", GRP2, 104, 6, "asla", INH, 72, 2, "aslb", INH, 88, 2, "asr", GRP2, 103, 6, "asra", INH, 71, 2, "asrb", INH, 87, 2, "bcc", REL, 36, 4, "bcs", REL, 37, 4, "beq", REL, 39, 4, "bge", REL, 44, 4, "bgt", REL, 46, 4, "bhi", REL, 34, 4, "bhs", REL, 36, 4, "bita", GEN, 133, 2, "bitb", GEN, 197, 2, "ble", REL, 47, 4, "blo", REL, 37, 4, "bls", REL, 35, 4, "blt", REL, 45, 4, "bmi", REL, 43, 4, "bne", REL, 38, 4, "bpl", REL, 42, 4, "bra", REL, 32, 4, "bsr", REL, 141, 8, "bvc", REL, 40, 4, "bvs", REL, 41, 4, "cba", INH, 17, 2, "clc", INH, 12, 2, "cli", INH, 14, 2, "clr", GRP2, 111, 6, "clra", INH, 79, 2, "clrb", INH, 95, 2, "clv", INH, 10, 2, "cmpa", GEN, 129, 2, "cmpb", GEN, 193, 2, "com", GRP2, 99, 6, "coma", INH, 67, 2, "comb", INH, 83, 2, "cpx", LONGIMM,140, 3, "daa", INH, 25, 2, "dec", GRP2, 106, 6, "deca", INH, 74, 2, "decb", INH, 90, 2, "des", INH, 52, 4, "dex", INH, 9, 4, "eora", GEN, 136, 2, "eorb", GEN, 200, 2, "inc", GRP2, 108, 6, "inca", INH, 76, 2, "incb", INH, 92, 2, "ins", INH, 49, 4, "inx", INH, 8, 4, "jmp", GRP2, 110, 3, "jsr", NOIMM, 0x8D, 7, "ldaa", GEN, 134, 2, "ldab", GEN, 198, 2, "lds", LONGIMM,142, 3, "ldx", LONGIMM,206, 3, "lsl", GRP2, 104, 6, "lsla", INH, 72, 2, "lslb", INH, 88, 2, "lsr", GRP2, 100, 6, "lsra", INH, 68, 2, "lsrb", INH, 84, 2, "neg", GRP2, 96, 6, "nega", INH, 64, 2, "negb", INH, 80, 2, "nop", INH, 1, 2, "oraa", GEN, 138, 2, "orab", GEN, 202, 2, "psha", INH, 54, 4, "pshb", INH, 55, 4, "pula", INH, 50, 4, "pulb", INH, 51, 4, "rol", GRP2, 105, 6, "rola", INH, 73, 2, "rolb", INH, 89, 2, "ror", GRP2, 102, 6, "rora", INH, 70, 2, "rorb", INH, 86, 2, "rti", INH, 59, 10, "rts", INH, 57, 5, "sba", INH, 16, 2, "sbca", GEN, 130, 2, "sbcb", GEN, 194, 2, "sec", INH, 13, 2, "sei", INH, 15, 2, "sev", INH, 11, 2, "staa", NOIMM, 135, 3, "stab", NOIMM, 199, 3, "sts", NOIMM, 143, 4, "stx", NOIMM, 207, 4, "suba", GEN, 128, 2, "subb", GEN, 192, 2, "subd", LONGIMM,131, 3, "swi", INH, 63, 12, "tab", INH, 22, 2, "tap", INH, 6, 2, "tba", INH, 23, 2, "tpa", INH, 7, 2, "tst", GRP2, 109, 6, "tsta", INH, 77, 2, "tstb", INH, 93, 2, "tsx", INH, 48, 4, "txs", INH, 53, 4, "wai", INH, 62, 9 }; SHAR_EOF cat << \SHAR_EOF > TABLE1.H struct oper table[] = { "aba", INH, 27, 2, "abx", INH, 58, 3, /* 6801 only */ "adca", GEN, 137, 2, "adcb", GEN, 201, 2, "adda", GEN, 139, 2, "addb", GEN, 203, 2, "addd", LONGIMM,195, 4, /* 6801 only */ "anda", GEN, 132, 2, "andb", GEN, 196, 2, "asl", GRP2, 104, 6, "asla", INH, 72, 2, "aslb", INH, 88, 2, "asld", INH, 5, 3, /* 6801 only */ "asr", GRP2, 103, 6, "asra", INH, 71, 2, "asrb", INH, 87, 2, "bcc", REL, 36, 3, "bcs", REL, 37, 3, "beq", REL, 39, 3, "bge", REL, 44, 3, "bgt", REL, 46, 3, "bhi", REL, 34, 3, "bhs", REL, 36, 3, "bita", GEN, 133, 2, "bitb", GEN, 197, 2, "ble", REL, 47, 3, "blo", REL, 37, 3, "bls", REL, 35, 3, "blt", REL, 45, 3, "bmi", REL, 43, 3, "bne", REL, 38, 3, "bpl", REL, 42, 3, "bra", REL, 32, 3, "brn", REL, 33, 3, /* for sharon 9/30/81 */ "bsr", REL, 141, 6, "bvc", REL, 40, 3, "bvs", REL, 41, 3, "cba", INH, 17, 2, "clc", INH, 12, 2, "cli", INH, 14, 2, "clr", GRP2, 111, 6, "clra", INH, 79, 2, "clrb", INH, 95, 2, "clv", INH, 10, 2, "cmpa", GEN, 129, 2, "cmpb", GEN, 193, 2, "com", GRP2, 99, 6, "coma", INH, 67, 2, "comb", INH, 83, 2, "cpx", LONGIMM,140, 4, "daa", INH, 25, 2, "dec", GRP2, 106, 6, "deca", INH, 74, 2, "decb", INH, 90, 2, "des", INH, 52, 3, "dex", INH, 9, 3, "eora", GEN, 136, 2, "eorb", GEN, 200, 2, "inc", GRP2, 108, 6, "inca", INH, 76, 2, "incb", INH, 92, 2, "ins", INH, 49, 3, "inx", INH, 8, 3, "jmp", GRP2, 110, 3, "jsr", NOIMM, 0x8D, 4, "ldaa", GEN, 134, 2, "ldab", GEN, 198, 2, "ldd", LONGIMM,204, 3, /* 6801 only */ "lds", LONGIMM,142, 3, "ldx", LONGIMM,206, 3, "lsl", GRP2, 104, 6, "lsla", INH, 72, 2, "lslb", INH, 88, 2, "lsld", INH, 5, 3, /* 6801 only */ "lsr", GRP2, 100, 6, "lsra", INH, 68, 2, "lsrb", INH, 84, 2, "lsrd", INH, 4, 3, /* 6801 only */ "mul", INH, 61, 10, /* 6801 only */ "neg", GRP2, 96, 6, "nega", INH, 64, 2, "negb", INH, 80, 2, "nop", INH, 1, 2, "oraa", GEN, 138, 2, "orab", GEN, 202, 2, "psha", INH, 54, 3, "pshb", INH, 55, 3, "pshx", INH, 60, 4, /* 6801 only */ "pula", INH, 50, 4, "pulb", INH, 51, 4, "pulx", INH, 56, 5, /* 6801 only */ "rol", GRP2, 105, 6, "rola", INH, 73, 2, "rolb", INH, 89, 2, "ror", GRP2, 102, 6, "rora", INH, 70, 2, "rorb", INH, 86, 2, "rti", INH, 59, 10, "rts", INH, 57, 5, "sba", INH, 16, 2, "sbca", GEN, 130, 2, "sbcb", GEN, 194, 2, "sec", INH, 13, 2, "sei", INH, 15, 2, "sev", INH, 11, 2, "staa", NOIMM, 135, 2, "stab", NOIMM, 199, 2, "std", NOIMM, 205, 3, /* 6801 only */ "sts", NOIMM, 143, 3, "stx", NOIMM, 207, 3, "suba", GEN, 128, 2, "subb", GEN, 192, 2, "subd", LONGIMM,131, 4, /* 6801 only */ "swi", INH, 63, 12, "tab", INH, 22, 2, "tap", INH, 6, 2, "tba", INH, 23, 2, "tpa", INH, 7, 2, "tst", GRP2, 109, 6, "tsta", INH, 77, 2, "tstb", INH, 93, 2, "tsx", INH, 48, 3, "txs", INH, 53, 3, "wai", INH, 62, 9 }; SHAR_EOF cat << \SHAR_EOF > TABLE11.H struct oper table[] = { "aba", INH, 0x1B, 2, "abx", INH, 0x3A, 3, /* 6801 */ "aby", P2INH, 0x3A, 4, /* 6811 */ "adca", GEN, 0x89, 2, "adcb", GEN, 0xC9, 2, "adda", GEN, 0x8B, 2, "addb", GEN, 0xCB, 2, "addd", LONGIMM,0xC3, 4, /* 6801 */ "anda", GEN, 0x84, 2, "andb", GEN, 0xC4, 2, "asl", GRP2, 0x68, 6, "asla", INH, 0x48, 2, "aslb", INH, 0x58, 2, "asld", INH, 0x05, 3, /* 6801 */ "asr", GRP2, 0x67, 6, "asra", INH, 0x47, 2, "asrb", INH, 0x57, 2, "bcc", REL, 0x24, 3, "bclr", SETCLR, 0x1D, 6, /* 6811 */ "bcs", REL, 0x25, 3, "beq", REL, 0x27, 3, "bge", REL, 0x2C, 3, "bgt", REL, 0x2E, 3, "bhi", REL, 0x22, 3, "bhs", REL, 0x24, 3, "bita", GEN, 0x85, 2, "bitb", GEN, 0xC5, 2, "ble", REL, 0x2F, 3, "blo", REL, 0x25, 3, "bls", REL, 0x23, 3, "blt", REL, 0x2D, 3, "bmi", REL, 0x2B, 3, "bne", REL, 0x26, 3, "bpl", REL, 0x2A, 3, "bra", REL, 0x20, 3, "brclr",BTB, 0x1F, 6, /* 6811 */ "brn", REL, 0x21, 3, /* for sharon 9/30/81 */ "brset",BTB, 0x1E, 6, /* 6811 */ "bset", SETCLR, 0x1C, 6, /* 6811 */ "bsr", REL, 0x8D, 6, "bvc", REL, 0x28, 3, "bvs", REL, 0x29, 3, "cba", INH, 0x11, 2, "clc", INH, 0x0C, 2, "cli", INH, 0x0E, 2, "clr", GRP2, 0x6F, 6, "clra", INH, 0x4F, 2, "clrb", INH, 0x5F, 2, "clv", INH, 0x0A, 2, "cmpa", GEN, 0x81, 2, "cmpb", GEN, 0xC1, 2, "cmpd", CPD, 0x83, 5, /* 6811 */ "cmpx", XLIMM, 0x8C, 4, /* 6811, LONGIMM for 6801 */ "cmpy", YLIMM, 0x8C, 5, /* 6811 */ "com", GRP2, 0x63, 6, "coma", INH, 0x43, 2, "comb", INH, 0x53, 2, "cpd", CPD, 0x83, 5, /* 6811 */ "cpx", XLIMM, 0x8C, 4, /* 6811, LONGIMM for 6801 */ "cpy", YLIMM, 0x8C, 5, /* 6811 */ "daa", INH, 0x19, 2, "dec", GRP2, 0x6A, 6, "deca", INH, 0x4A, 2, "decb", INH, 0x5A, 2, "des", INH, 0x34, 3, "dex", INH, 0x09, 3, "dey", P2INH, 0x09, 4, /* 6811 */ "eora", GEN, 0x88, 2, "eorb", GEN, 0xC8, 2, "fdiv", INH, 0x03, 41, /* 6811 */ "idiv", INH, 0x02, 41, /* 6811 */ "inc", GRP2, 0x6C, 6, "inca", INH, 0x4C, 2, "incb", INH, 0x5C, 2, "ins", INH, 0x31, 3, "inx", INH, 0x08, 3, "iny", P2INH, 0x08, 4, /* 6811 */ "jmp", GRP2, 0x6E, 3, "jsr", NOIMM, 0x8D, 4, "lda", GEN, 0x86, 2, "ldaa", GEN, 0x86, 2, "ldab", GEN, 0xC6, 2, "ldad", LONGIMM,0xCC, 3, /* 6801 */ "ldb", GEN, 0xC6, 2, "ldd", LONGIMM,0xCC, 3, /* 6801 */ "lds", LONGIMM,0x8E, 3, "ldx", XLIMM, 0xCE, 3, /* 6811, LONGIMM for 6801 */ "ldy", YLIMM, 0xCE, 4, /* 6811 */ "lsl", GRP2, 0x68, 6, "lsla", INH, 0x48, 2, "lslb", INH, 0x58, 2, "lsld", INH, 0x05, 3, /* 6801 */ "lsr", GRP2, 0x64, 6, "lsra", INH, 0x44, 2, "lsrb", INH, 0x54, 2, "lsrd", INH, 0x04, 3, /* 6801 */ "mul", INH, 0x3D, 10, /* 6801 */ "neg", GRP2, 0x60, 6, "nega", INH, 0x40, 2, "negb", INH, 0x50, 2, "nop", INH, 0x01, 2, "ora", GEN, 0x8A, 2, "oraa", GEN, 0x8A, 2, "orab", GEN, 0xCA, 2, "orb", GEN, 0xCA, 2, "psha", INH, 0x36, 3, "pshb", INH, 0x37, 3, "pshx", INH, 0x3C, 4, /* 6801 */ "pshy", P2INH, 0x3C, 5, /* 6811 */ "pula", INH, 0x32, 4, "pulb", INH, 0x33, 4, "pulx", INH, 0x38, 5, /* 6801 */ "puly", P2INH, 0x38, 6, /* 6811 */ "rol", GRP2, 0x69, 6, "rola", INH, 0x49, 2, "rolb", INH, 0x59, 2, "ror", GRP2, 0x66, 6, "rora", INH, 0x46, 2, "rorb", INH, 0x56, 2, "rti", INH, 0x3B, 12, "rts", INH, 0x39, 5, "sba", INH, 0x10, 2, "sbca", GEN, 0x82, 2, "sbcb", GEN, 0xC2, 2, "sec", INH, 0x0D, 2, "sei", INH, 0x0F, 2, "sev", INH, 0x0B, 2, "sta", NOIMM, 0x87, 2, "staa", NOIMM, 0x87, 2, "stab", NOIMM, 0xC7, 2, "stad", NOIMM, 0xCD, 3, /* 6801 */ "stb", NOIMM, 0xC7, 2, "std", NOIMM, 0xCD, 3, /* 6801 */ "stop", INH, 0xCF, 2, /* 6811 */ "sts", NOIMM, 0x8F, 3, "stx", XNOIMM, 0xCF, 3, /* 6811, LONGIMM for 6801 */ "sty", YNOIMM, 0xCF, 4, /* 6811 */ "suba", GEN, 0x80, 2, "subb", GEN, 0xC0, 2, "subd", LONGIMM,0x83, 4, /* 6801 */ "swi", INH, 0x3F, 14, "tab", INH, 0x16, 2, "tap", INH, 0x06, 2, "tba", INH, 0x17, 2, "tpa", INH, 0x07, 2, "tst", GRP2, 0x6D, 6, "tsta", INH, 0x4D, 2, "tstb", INH, 0x5D, 2, "tsx", INH, 0x30, 3, "tsy", P2INH, 0x30, 4, /* 6811 */ "txs", INH, 0x35, 3, "tys", P2INH, 0x35, 4, /* 6811 */ "wai", INH, 0x3E, 14, "xgdx", INH, 0x8F, 3, /* 6811 */ "xgdy", P2INH, 0x8F, 4 /* 6811 */ }; SHAR_EOF cat << \SHAR_EOF > TABLE4.H struct oper table[] = { "add", GEN, 0xE2, 0, "adda", GEN, 0xE2, 0, "and", GEN, 0xE5, 0, "anda", GEN, 0xE5, 0, "asla", APOST, 0xFA, 0, "bam", BPM, 0xCF, 0, "bap", BPM, 0xC7, 0, "bcc", REL, 0x40, 0, "bclr", SETCLR, 0xD0, 0, "bcs", REL, 0x60, 0, "beq", REL, 0x20, 0, "bhs", REL, 0x40, 0, "blo", REL, 0x60, 0, "bne", REL, 0x00, 0, "brclr",BTB, 0xC0, 0, "brset",BTB, 0xC8, 0, "bset", SETCLR, 0xD8, 0, "clra", APOST, 0xFB, 0, "clrx", CLRX, 0xB0, 0, "clry", CLRY, 0xB0, 0, "cmp", GEN, 0xE4, 0, "cmpa", GEN, 0xE4, 0, "coma", INH, 0xB4, 0, "dec", NOIMM, 0xE7, 0, "deca", APOST, 0xFF, 0, "decx", INH, 0xB8, 0, "decy", INH, 0xB9, 0, "dex", INH, 0xB8, 0, "dey", INH, 0xB9, 0, "inc", NOIMM, 0xE6, 0, "inca", APOST, 0xFE, 0, "incx", INH, 0xA8, 0, "incy", INH, 0xA9, 0, "inx", INH, 0xA8, 0, "iny", INH, 0xA9, 0, "jmp", EXT, 0x90, 0, "jsr", EXT, 0x80, 0, "lda", GEN, 0xE0, 0, "ldxi", LDX, 0xB0, 0, "ldyi", LDY, 0xB0, 0, "mvi", MVI, 0xB0, 0, "nop", INH, 0x20, 0, "rola", INH, 0xB5, 0, "rrb", INH, 0xB1, 0, "rti", INH, 0xB2, 0, "rts", INH, 0xB3, 0, "sta", NOIMM , 0xE1, 0, "stop", INH, 0xB6, 0, "sub", GEN, 0xE3, 0, "suba", GEN, 0xE3, 0, "tax", INH, 0xBC, 0, "tay", INH, 0xBD, 0, "txa", INH, 0xAC, 0, "tya", INH, 0xAD, 0, "wait", INH, 0xB7, 0 }; SHAR_EOF cat << \SHAR_EOF > TABLE5.H struct oper table[] = { "adc", GEN, 0xA9, 2, "add", GEN, 0xAB, 2, "and", GEN, 0xA4, 2, "asl", GRP2, 0x38, 4, "asla", INH, 0x48, 4, "aslx", INH, 0x58, 4, "asr", GRP2, 0x37, 4, "asra", INH, 0x47, 4, "asrx", INH, 0x57, 4, "bcc", REL, 0x24, 4, "bclr", SETCLR, 0x11, 7, "bcs", REL, 0x25, 4, "beq", REL, 0x27, 4, "bhcc", REL, 0x28, 4, "bhcs", REL, 0x29, 4, "bhi", REL, 0x22, 4, "bhs", REL, 0x24, 4, "bih", REL, 0x2F, 4, "bil", REL, 0x2E, 4, "bit", GEN, 0xA5, 2, "blo", REL, 0x25, 4, "bls", REL, 0x23, 4, "bmc", REL, 0x2C, 4, "bmi", REL, 0x2B, 4, "bms", REL, 0x2D, 4, "bne", REL, 0x26, 4, "bpl", REL, 0x2A, 4, "bra", REL, 0x20, 4, "brclr",BTB, 0x01, 10, "brn", REL, 0x21, 4, "brset",BTB, 0x00, 10, "bset", SETCLR, 0x10, 7, "bsr", REL, 0xAD, 8, "clc", INH, 0x98, 2, "cli", INH, 0x9A, 2, "clr", GRP2, 0x3F, 4, "clra", INH, 0x4F, 4, "clrx", INH, 0x5F, 4, "cmp", GEN, 0xA1, 2, "cmpx", GEN, 0xA3, 2, "com", GRP2, 0x33, 4, "coma", INH, 0x43, 4, "comx", INH, 0x53, 4, "cpx", GEN, 0xA3, 2, "dec", GRP2, 0x3A, 4, "deca", INH, 0x4A, 4, "decx", INH, 0x5A, 4, "eor", GEN, 0xA8, 2, "inc", GRP2, 0x3C, 4, "inca", INH, 0x4C, 4, "incx", INH, 0x5C, 4, "jmp", NOIMM, 0xAC, 1, "jsr", NOIMM, 0xAD, 5, "lda", GEN, 0xA6, 2, "ldx", GEN, 0xAE, 2, "lsl", GRP2, 0x38, 4, "lsla", INH, 0x48, 4, "lslx", INH, 0x58, 4, "lsr", GRP2, 0x34, 4, "lsra", INH, 0x44, 4, "lsrx", INH, 0x54, 4, "mul", INH, 0x42, 11, /* HC05C4 ONLY */ "neg", GRP2, 0x30, 4, "nega", INH, 0x40, 4, "negx", INH, 0x50, 4, "nop", INH, 0x9D, 2, "ora", GEN, 0xAA, 2, "rol", GRP2, 0x39, 4, "rola", INH, 0x49, 4, "rolx", INH, 0x59, 4, "ror", GRP2, 0x36, 4, "rora", INH, 0x46, 4, "rorx", INH, 0x56, 4, "rsp", INH, 0x9C, 2, "rti", INH, 0x80, 9, "rts", INH, 0x81, 6, "sbc", GEN, 0xA2, 2, "sec", INH, 0x99, 2, "sei", INH, 0x9B, 2, "sta", NOIMM, 0xA7, 3, "stop", INH, 0x8E, 2, /* CMOS only */ "stx", NOIMM, 0xAF, 3, "sub", GEN, 0xA0, 2, "swi", INH, 0x83, 11, "tax", INH, 0x97, 2, "tst", GRP2, 0x3D, 4, "tsta", INH, 0x4D, 4, "tstx", INH, 0x5D, 4, "txa", INH, 0x9F, 2, "wait", INH, 0x8F, 2 /* CMOS only */ }; SHAR_EOF cat << \SHAR_EOF > TABLE9.H struct oper table[] = { /* MNE CLASS BASE CYCLES */ "abx", INH, 58, 3, "adca", GEN, 137, 2, "adcb", GEN, 201, 2, "adda", GEN, 139, 2, "addb", GEN, 203, 2, "addd", LONGIMM,195, 4, "anda", GEN, 132, 2, "andb", GEN, 196, 2, "andcc",IMM, 28, 3, "asl", GRP2, 8, 4, "asla", INH, 72, 2, "aslb", INH, 88, 2, "asr", GRP2, 7, 4, "asra", INH, 71, 2, "asrb", INH, 87, 2, "bcc", REL, 36, 3, "bcs", REL, 37, 3, "beq", REL, 39, 3, "bge", REL, 44, 3, "bgt", REL, 46, 3, "bhi", REL, 34, 3, "bhs", REL, 36, 3, "bita", GEN, 133, 2, "bitb", GEN, 197, 2, "ble", REL, 47, 3, "blo", REL, 37, 3, "bls", REL, 35, 3, "blt", REL, 45, 3, "bmi", REL, 43, 3, "bne", REL, 38, 3, "bpl", REL, 42, 3, "bra", REL, 32, 3, "brn", REL, 33, 3, "bsr", REL, 141, 7, "bvc", REL, 40, 3, "bvs", REL, 41, 3, "clr", GRP2, 15, 4, "clra", INH, 79, 2, "clrb", INH, 95, 2, "cmpa", GEN, 129, 2, "cmpb", GEN, 193, 2, "cmpd", P2GEN, 131, 5, "cmps", P3GEN, 140, 5, "cmpu", P3GEN, 131, 5, "cmpx", LONGIMM,140, 4, "cmpy", P2GEN, 140, 5, "com", GRP2, 3, 4, "coma", INH, 67, 2, "comb", INH, 83, 2, "cpx", LONGIMM,140, 4, /* for compatibility with old code */ "cwai", IMM, 60, 20, "daa", INH, 25, 2, "dec", GRP2, 10, 4, "deca", INH, 74, 2, "decb", INH, 90, 2, "eora", GEN, 136, 2, "eorb", GEN, 200, 2, "exg", RTOR, 30, 8, "inc", GRP2, 12, 4, "inca", INH, 76, 2, "incb", INH, 92, 2, "jmp", GRP2, 14, 1, "jsr", NOIMM, 141, 5, "lbcc", P2REL, 36, 6, "lbcs", P2REL, 37, 6, "lbeq", P2REL, 39, 6, "lbge", P2REL, 44, 6, "lbgt", P2REL, 46, 6, "lbhi", P2REL, 34, 6, "lbhs", P2REL, 36, 6, "lble", P2REL, 47, 6, "lblo", P2REL, 37, 6, "lbls", P2REL, 35, 6, "lblt", P2REL, 45, 6, "lbmi", P2REL, 43, 6, "lbne", P2REL, 38, 6, "lbpl", P2REL, 42, 6, "lbra", P1REL, 22, 5, "lbrn", P2REL, 33, 5, "lbsr", P1REL, 23, 9, "lbvc", P2REL, 40, 6, "lbvs", P2REL, 41, 6, "lda", GEN, 134, 2, "ldb", GEN, 198, 2, "ldd", LONGIMM,204, 3, "lds", P2GEN, 206, 4, "ldu", LONGIMM,206, 3, "ldx", LONGIMM,142, 3, "ldy", P2GEN, 142, 4, "leas", INDEXED,50, 2, "leau", INDEXED,51, 2, "leax", INDEXED,48, 2, "leay", INDEXED,49, 2, "lsl", GRP2, 8, 4, "lsla", INH, 72, 2, "lslb", INH, 88, 2, "lsr", GRP2, 4, 4, "lsra", INH, 68, 2, "lsrb", INH, 84, 2, "mul", INH, 61, 11, "neg", GRP2, 0, 4, "nega", INH, 64, 2, "negb", INH, 80, 2, "nop", INH, 18, 2, "ora", GEN, 138, 2, "orb", GEN, 202, 2, "orcc", IMM, 26, 3, "pshs", RLIST, 52, 5, "pshu", RLIST, 54, 5, "puls", RLIST, 53, 5, "pulu", RLIST, 55, 5, "rol", GRP2, 9, 4, "rola", INH, 73, 2, "rolb", INH, 89, 2, "ror", GRP2, 6, 4, "rora", INH, 70, 2, "rorb", INH, 86, 2, "rti", INH, 59, 15, "rts", INH, 57, 5, "sbca", GEN, 130, 2, "sbcb", GEN, 194, 2, "sex", INH, 29, 2, "sta", NOIMM, 135, 2, "stb", NOIMM, 199, 2, "std", NOIMM, 205, 3, "sts", P2NOIMM,207, 4, "stu", NOIMM, 207, 3, "stx", NOIMM, 143, 3, "sty", P2NOIMM,143, 4, "suba", GEN, 128, 2, "subb", GEN, 192, 2, "subd", LONGIMM,131, 4, "swi", INH, 63, 19, "swi2", P2INH, 63, 20, "swi3", P3INH, 63, 20, "sync", INH, 19, 4, "sys", SYS, 0, 19, "tfr", RTOR, 31, 6, "tst", GRP2, 13, 4, "tsta", INH, 77, 2, "tstb", INH, 93, 2 }; SHAR_EOF cat << \SHAR_EOF > assembler.doc The IBM PC 6800/01/04/05/09/11 cross assemblers GENERAL The assemblers are named as*.exe where '*' is any of 0,1,h1,4,5,9 or 11 depending on which one you're using. Command line arguments specify the filenames to assemble. The assemblers accept options from the command line to be included in the assembly. These options are the following: l enable output listing. nol disable output listing (default). cre generate cross reference table. s generate a symbol table. c enable cycle count. noc disable cycle count. The command line looks like this : as* file1 file2 ... [ - option1 option2 ...] If this method of passing commands to the assembler is used rather than the OPT pseudo op code, a space should separate the minus sign from the last file name and the first option. Example: as5 program -l cre This command assembles file 'program' with an output listing and a cross reference table. The `S1' formatted object file is placed in file `filename.S19', the listing and error messages are written to the standard output. If multiple files are assembled, the 'S1' file will be placed under the first file's name.S19. The listing file contains the address and bytes assembled for each line of input followed by the original input line (unchanged, but moved over to the right some). If an input line causes more than 6 bytes to be output (e.g. a long FCC directive), additional bytes (up to 64) are listed on succeding lines with no address preceding them. Equates cause the value of the expression to replace the address field in the listing. Equates that have forward references cause Phasing Errors in Pass 2. Expressions may consist of symbols, constants or the character '*' (denoting the current value of the program counter) joined together by one of the operators: +-*/%&|^. The operators are the same as in C: + add - subtract * multiply / divide % remainder after division & bitwise and | bitwise or ^ bitwise exclusive-or Expressions are evaluated left to right and there is no provision for parenthesized expressions. Arithmetic is carried out in signed twos-complement integer precision (16 bits on the IBM PC) Constants are constructed with the same syntax as the Motorola MDOS assembler: ' followed by ASCII character $ followed by hexadecimal constant @ followed by octal constant % followed by binary constant digit decimal constant ERRORS Error diagnostics are placed in the listing file just before the line containing the error. Format of the error line is: Line_number: Description of error or Line_number: Warning --- Description of error Errors of the first type in pass one cause cancellation of pass two. Warnings do not cause cancellation of pass two but should cause you to wonder where they came from. Error messages are meant to be self-explanatory. If more than one file is being assembled, the file name precedes the error: File_name,Line_number: Description of error Finally, some errors are classed as fatal and cause an immediate termination of the assembly. Generally these errors occur when a temporary file cannot be created or is lost during the assembly. Consult your local guru if this happens. DIFFERENCES For indexed addressing, the comma is required before the register; `inc x' and `inc ,x' are not the same. Macros are not supported. (try M4 or M6) The force size operators ('>' and '<') are implemented for all assemblers. The only pseudo-ops supported are: ORG, FCC, FDB, FCB, EQU, RMB, BSZ, ZMB, FILL PAGE and OPT. The OPT pseudo-op allows the following operands: nol Turn off output listing l Turn on output listing (default) noc Disable cycle counts in listing (default) c Enable cycle counts in listing (clear total cycles) contc Re-enable cycle counts (don't clear total cycles) cre Enable printing of a cross reference table s generate a symbol table Some of the more common pseudo-ops are not present: SPC Use blank lines instead END The assembly ends when there is no more input TTL use `pr' to get headings and page numbers NAM[E] Did you ever use this one anyway? The above 4 pseudo-ops are recognized, but ignored. ZMB (Zero Memory Bytes) is equivalent to BSZ (Block Store Zeroes). FILL can be used to initialize memory to something other than zero: FILL val,nbytes. TARGET MACHINE SPECIFICS (as0) 6800: Use for 6802 and 6808 too. (as1) 6801: You could use this one for the 6800 and avoid LSRD, ASLD, PULX, ABX, PSHX, MUL, SUBD, ADDD, LDD and STD. (as4) 6804: The symbols 'a', 'x' and 'y' are predefined as $FF, $80 and $81 respectively. Also defined as 'A', 'X' and 'Y'. Because of the 6804 architecture, this means that 'clr x' will work since the x register is just a memory location. To use short-direct addressing, the symbol involved must not be a forward reference (i.e. undefined) and must be in the range $80-$83. Remember that bytes assembled in the range $10-$7F will go into the data space; There is no program space ROM for these locations. The syntax for Register indirect addressing is as follows: menmonic [<x>or<y>] an example is: lda [x] the comma ',' is not allowed. The MVI instruction (move immediate) has its own format : mvi address,#data where address is an 8-bit address in page zero, and data is the value to be written to specified location. (as5) 6805: There is no 'opt cmos' pseudo, so be careful not to use STOP or WAIT in a program that is destined for an NMOS version of the 6805. The MUL instruction should also be avoided on all versions of the 6805 except the C4. Cycle times are for the NMOS versions. (as9) 6809: The SETDP pseudo-op is not implemented. Use the '>' and '<` operators to force the size of operands. For compatibility, CPX is equal to CMPX. (as11) 68HC11: Bit manipulation operands are separated by blanks instead of commas since the 'HC11 has bit manipulation instructions that operate on indexed addresses. DETAILS Symbol: A string of characters with a non-initial digit. The string of characters may be from the set: [a-z][A-Z]_.[0-9]$ ( . and _ count as non-digits ). The `$' counts as a digit to avoid confusion with hexadecimal constants. All characters of a symbol are significant, with upper and lower case characters being distinct. The maximum number of characters in a symbol is currently set at 15. The symbol table has room for at least 2000 symbols of length 8 characters or less. Label: A symbol starting in the first column is a label and may optionally be ended with a ':'. A label may appear on a line by itself and is then interpreted as: Label EQU * Mnemonic: A symbol preceded by at least one whitespace character. Upper case characters in this field are converted to lower case before being checked as a legal mnemonic. Thus `nop', `NOP' and even `NoP' are recognized as the same mnemonic. Note that register names that sometimes appear at the end of a mnemonic (e.g. nega or stu) must not be separated by any whitespace characters. Thus `clra' means clear accumulator A, but that `clr a' means clear memory location `a'. Operand: Follows mnemonic, separated by at least one whitespace character. The contents of the operand field is interpreted by each instruction. Whitespace: A blank or a tab Comment: Any text after all operands for a given mnemonic have been processed or, a line beginning with '*' up to the end of line or, an empty line. Continuations: If a line ends with a backslash (\) then the next line is fetched and added to the end of the first line. This continues until a line is seen which doesn't end in \ or until MAXBUF characters have been collected (MAXBUF >= 256 ). FILES filename.S19 S-record output file STDOUT listing and errors (use redirection for listing file) Fwd_refs Temporary file for forward references. IMPLEMENTATION NOTES This is a classic 2-pass assembler. Pass 1 establishes the symbol table and pass 2 generates the code. 12/11/84 E.J.Rupp This version of the cross assemblers ported to the IBM PC 4/13/87 SHAR_EOF cat << \SHAR_EOF > readme These files came from the Motorola Freeware BBS. Their BBS now has an amiga upload/download section (YEA!). I obtained explicit permission to post these to comp.sources.amiga and also to give these files to Fred Dish for inclusion in one of his disks. (Fred, do you still work for motorola?) Msg # 257-641 (H)elp,S)ince,L)ast, T)o,F)rom,M)ine, text, [Q]uit)? s Msg #: 605 From: GREG GARNER Sent: 01-04-89 02:07 To: SYSOP Rcvd: 01-06-89 08:43 Re: WHAT DOES FREEWARE MEAN? I have also ported the cross assemblers and the small C compiler to the amiga. I am interested in Posting the executables and binaries to the USENET group comp.sources.amiga. I can find nowhere on this BBS or in the source code that explicitly states that it is OK for me to do this. Will you please give me permission in a message (to be included with the posting of the code). I would also like to send the code to Fred Fish (he works for Motorola and maintains a large library of amiga stuff). Thank you very much! Greg Garner 501-442-4847 More [Y]es,N)o,C)ontinuous,A)bort,R)eply,T)hread,=)reread,+,-,K)ill? Msg #: 607 From: SYSOP Sent: 01-04-89 08:39 To: GREG GARNER Rcvd: -NO- Re: (R)WHAT DOES FREEWARE MEA Greg, FREEWARE means the free xchange of 6800-68000 programs between us (MOT) and our users as well as between users. As the NEWUSER screens (the ones you see when you register) show, we welcome contributions from our users / customers. I don't know anything about USENET but your programs are welcome on this system. (Use [U] in the FILES menu to upload). I strongly suggest that, if at all possible, you upload source code in addition to executable. With the fear of Trojans/Viruses such as it is today, ***I*** would not want to use an unknown program for my professional work - home stuff, maybe.?.... I do not know Fred (Mot has 50,000+ employees). At what site does he work? We have just begun to get contributions for the Amiga, so I'll be happy to add any that you (or others) wish to donate...... John More [Y]es,N)o,C)ontinuous,A)bort,R)eply,T)hread,=)reread,+,-,K)ill? ---------------------------------------------------------------------------- The Motorola Freeware BBS can be reached at 1-512-440-3733. Their BBS has a notice saying that the phone number will change: New phone numbers for Motorola Oakhill Plant. On Dec 19,1988, Southwestern Bell will convert the Twinbrook Central Office, which currently serves the Motorola Oak Hill factory, to an Electronic (ESS) Central Office. Due to this conversion, the prefix on the Direct Inward Dialing (DID) numbers used at the Oak Hill facility will be changed from 440 to 891. The 891 numbers will be effective on Dec 19, 1988. Therefore, on Monday, Dec 19, you will want to call [512]-891-3733 to connect with this BBS. A voice recording will be in effect for 6 months to notify you of the change. (It's good to leave your modem speaker ON until a carrier is detected!) From Dec 19 1988 until Dec 31 1988, BOTH numbers will be in force. ---------------------------------------------------------------------------- I changed the assembler files very little to get them to work in my setup. In fact the code compiles unchanged, but my eprom programmer has fits if it sees a S19 file that doesn't have carriage returns, so I changed two lines to add them. Here is the dif output file showing what I changed in case anyone wants to change them back: -------- Line 81 of 'AS.C' ---- --- fprintf(Objfil,"S9030000FC\n"); /* at least give a decent ending */ ++++++++ Line 81 of 'dh1:assem/as.c' ++++ +++ fprintf(Objfil,"S9030000FC\r\n"); /* at least give a decent ending */ -------- Line 117 of 'UTIL.C' ---- --- fprintf(Objfil,"\n"); ++++++++ Line 117 of 'dh1:assem/util.c' ++++ +++ fprintf(Objfil,"\r\n"); /* Added \r for GMG eprom programmer. */ There is no makefile included, because each assembler is compiled by compiling the file as0.c, as05.c, or which ever one you wish to compile. These files are just a list of includes to get the code to compile. Example: To compile the 6811 assembler (With manx3.6) cc +L as11.c ln as11.o -lc32 I am not sure if the code works compiled with 16 bit ints, but I have used the assemblers extensively compiled with 32 bit ints with no bugs. Good luck! --------------------------------------------------------------------------- I am interested in hearing from anyone out there that is using the amiga (or other computers) for microcontroller developement, so send me some mail! I am working on a 68hc11 project at the moment, but it is a ways from completion. Enjoy! Greg Garner 501-442-4847 gmg@hcx.uucp USENET: ...!uunet!harris.cis.ksu.edu!hcx!gmg SHAR_EOF # End of shell archive exit 0 -- Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page Have five nice days.