??? 10/23/06 14:03 Read: times |
#126905 - Maybe this will help??? Responding to: ???'s previous message |
Hi Mike, This isn't in exactly the format you requested, but it might help anyway. It's a table of information about the 8051 instruction set that I lifted from the bowels of an assembler that I wrote a long time ago. The first column of the table in particular might be interesting to you. It contains what I called an "extended op code", which includes the instruction mnemonic, along with information about the operands types allowed for each instruction. There are also some assembler directives thrown in the mix. The single-character operand type codes are explained in the comments that describe the 'optab' structure. In addition to the documented operand types, I see that the table also includes an 'i' type for some of the instructions. I apparently failed to note its meaning in the comments, but it looks like it's supposed to represent branch targets that would have been looked up in a symbol table during a second pass of the assembler, rather than being available directly from the source code during pass 1. -- Russ /***************************************************************************** * ASM51.H * ***************************************************************************** * DESCRIPTION: This file is a header file to be shared by the various * * modules of Russ's 8051 assembler. * * * * REVISIONS: 17 NOV 86 - RAC - Original code * *****************************************************************************/ struct optab { /* Operation table entry format */ char op[9]; /* The "extended operation", defined as follows: */ /* ------------------------------------------------- */ /* Bytes 0-4: Mnemonic, blank padded on right. */ /* Bytes 5-7: Expected operand types, coded thus: */ /* n = number # = immediate */ /* a = accumulator c = carry bit */ /* r = register @ = Indirect reg. */ /* b = bit / = Inverse bit */ /* d = DPTR 1 = @A+DPTR */ /* 2 = @A+PC 3 = @DPTR */ /* blank = No operand expected */ /* Byte 8: Terminating NULL */ char (*asmbl)(); /* Pointer to routine to handle this operation */ char opcode; /* Actual opcode value */ char bytes; /* # of bytes occupied by instruction */ char cycles; /* # of cycles to execute instruction */ char lrules; /* Label info. 'O' = optional, 'P' = prohibited, */ /* 'R' = required. */ char (*ab1)(); /* Pointer to routine to assemble instruction byte 1 */ char (*ab2)(); /* Pointer to routine to assemble instruction byte 2 */ char (*ab3)(); /* Pointer to routine to assemble instruction byte 3 */ }; /***************************************************************************** * OPTAB.C * ***************************************************************************** * DESCRIPTION: This file contains the big operation table, which gives all * * kinds of good information for each of the op's recognized by * * the assembler. * * * * REVISIONS: 19 NOV 86 - RAC - Original code * *****************************************************************************/ #include "asm51.h" struct optab ot[] = { /* Xtndd Opcd Optyp Opcd #b #c Lbl (*ab1)() (*ab2)() (*ab3)() */ /* FOR COMMENT LINES AND BLANK LINES */ " ", &anop, 0x00, 0, 0, 'o', 0, 0, 0, /* 44 */ /* ARITHMETIC OPS */ "ADD ar ", &inst, 0x28, 1, 1, 'o', &opor2, 0, 0, "ADD an ", &inst, 0x25, 2, 1, 'o', ©op, &lo_2, 0, "ADD a@ ", &inst, 0x26, 1, 1, 'o', &opor2, 0, 0, "ADD a# ", &inst, 0x24, 2, 1, 'o', ©op, &lo_2, 0, "ADDC ar ", &inst, 0x38, 1, 1, 'o', &opor2, 0, 0, "ADDC an ", &inst, 0x35, 2, 1, 'o', ©op, &lo_2, 0, "ADDC a@ ", &inst, 0x36, 1, 1, 'o', &opor2, 0, 0, "ADDC a# ", &inst, 0x34, 2, 1, 'o', ©op, &lo_2, 0, "SUBB ar ", &inst, 0x98, 1, 1, 'o', &opor2, 0, 0, "SUBB an ", &inst, 0x95, 2, 1, 'o', ©op, &lo_2, 0, "SUBB a@ ", &inst, 0x96, 1, 1, 'o', &opor2, 0, 0, "SUBB a# ", &inst, 0x94, 2, 1, 'o', ©op, &lo_2, 0, "INC a ", &inst, 0x04, 1, 1, 'o', ©op, 0, 0, "INC r ", &inst, 0x08, 1, 1, 'o', &opor1, 0, 0, "INC n ", &inst, 0x05, 2, 1, 'o', ©op, &lo_1, 0, "INC @ ", &inst, 0x06, 1, 1, 'o', &opor1, 0, 0, "DEC a ", &inst, 0x14, 1, 1, 'o', ©op, 0, 0, "DEC r ", &inst, 0x18, 1, 1, 'o', &opor1, 0, 0, "DEC n ", &inst, 0x15, 2, 1, 'o', ©op, &lo_1, 0, "DEC @ ", &inst, 0x16, 1, 1, 'o', &opor1, 0, 0, "INC d ", &inst, 0xA3, 1, 2, 'o', ©op, 0, 0, "MUL a ", &inst, 0xA4, 1, 4, 'o', ©op, 0, 0, "DIV a ", &inst, 0x84, 1, 4, 'o', ©op, 0, 0, "DA a ", &inst, 0xD4, 1, 1, 'o', ©op, 0, 0, /* LOGICAL OPS */ "ANL ar ", &inst, 0x58, 1, 1, 'o', &opor2, 0, 0, "ANL an ", &inst, 0x55, 2, 1, 'o', ©op, &lo_2, 0, "ANL a@ ", &inst, 0x56, 1, 1, 'o', &opor2, 0, 0, "ANL a# ", &inst, 0x54, 2, 1, 'o', ©op, &lo_2, 0, "ANL na ", &inst, 0x52, 2, 1, 'o', ©op, &lo_1, 0, "ANL n# ", &inst, 0x53, 3, 2, 'o', ©op, &lo_1, &lo_2, "ORL ar ", &inst, 0x48, 1, 1, 'o', &opor2, 0, 0, "ORL an ", &inst, 0x45, 2, 1, 'o', ©op, &lo_2, 0, "ORL a@ ", &inst, 0x46, 1, 1, 'o', &opor2, 0, 0, "ORL a# ", &inst, 0x44, 2, 1, 'o', ©op, &lo_2, 0, "ORL na ", &inst, 0x42, 2, 1, 'o', ©op, &lo_1, 0, "ORL n# ", &inst, 0x43, 3, 2, 'o', ©op, &lo_1, &lo_2, "XRL ar ", &inst, 0x68, 1, 1, 'o', &opor2, 0, 0, "XRL an ", &inst, 0x65, 2, 1, 'o', ©op, &lo_2, 0, "XRL a@ ", &inst, 0x66, 1, 1, 'o', &opor2, 0, 0, "XRL a# ", &inst, 0x64, 2, 1, 'o', ©op, &lo_2, 0, "XRL na ", &inst, 0x62, 2, 1, 'o', ©op, &lo_1, 0, "XRL n# ", &inst, 0x63, 3, 2, 'o', ©op, &lo_1, &lo_2, "CLR a ", &inst, 0xE4, 1, 1, 'o', ©op, 0, 0, "CPL a ", &inst, 0xF4, 1, 1, 'o', ©op, 0, 0, "RL a ", &inst, 0x23, 1, 1, 'o', ©op, 0, 0, "RLC a ", &inst, 0x33, 1, 1, 'o', ©op, 0, 0, "RR a ", &inst, 0x03, 1, 1, 'o', ©op, 0, 0, "RRC a ", &inst, 0x13, 1, 1, 'o', ©op, 0, 0, "SWAP a ", &inst, 0xC4, 1, 1, 'o', ©op, 0, 0, /* DATA TRANSFER OPS */ "MOV ar ", &inst, 0xE8, 1, 1, 'o', &opor2, 0, 0, "MOV an ", &inst, 0xE5, 2, 1, 'o', ©op, &lo_2, 0, "MOV a@ ", &inst, 0xE6, 1, 1, 'o', &opor2, 0, 0, "MOV a# ", &inst, 0x74, 2, 1, 'o', ©op, &lo_2, 0, "MOV ra ", &inst, 0xF8, 1, 1, 'o', &opor1, 0, 0, "MOV rn ", &inst, 0xA8, 2, 2, 'o', &opor1, &lo_2, 0, "MOV r# ", &inst, 0x78, 2, 1, 'o', &opor1, &lo_2, 0, "MOV na ", &inst, 0xF5, 2, 1, 'o', ©op, &lo_1, 0, "MOV nr ", &inst, 0x88, 2, 2, 'o', &opor2, &lo_1, 0, "MOV nn ", &inst, 0x85, 3, 2, 'o', ©op, &lo_2, &lo_1, "MOV n@ ", &inst, 0x86, 2, 2, 'o', &opor2, &lo_1, 0, "MOV n# ", &inst, 0x75, 3, 2, 'o', ©op, &lo_1, &lo_2, "MOV @a ", &inst, 0xF6, 1, 1, 'o', &opor1, 0, 0, "MOV @n ", &inst, 0xA6, 2, 2, 'o', &opor1, &lo_2, 0, "MOV @# ", &inst, 0x76, 2, 1, 'o', &opor1, &lo_2, 0, "MOV d# ", &inst, 0x90, 3, 2, 'o', ©op, &hi_2, &lo_2, "MOVC a1 ", &inst, 0x93, 1, 2, 'o', ©op, 0, 0, "MOVC a2 ", &inst, 0x83, 1, 2, 'o', ©op, 0, 0, "MOVX a@ ", &inst, 0xE2, 1, 2, 'o', &opor2, 0, 0, "MOVX a3 ", &inst, 0xE0, 1, 2, 'o', ©op, 0, 0, "MOVX @a ", &inst, 0xF2, 1, 2, 'o', &opor1, 0, 0, "MOVX 3a ", &inst, 0xF0, 1, 2, 'o', ©op, 0, 0, "PUSH n ", &inst, 0xC0, 2, 2, 'o', ©op, &lo_1, 0, "POP n ", &inst, 0xD0, 2, 2, 'o', ©op, &lo_1, 0, "XCH ar ", &inst, 0xC8, 1, 1, 'o', &opor2, 0, 0, "XCH an ", &inst, 0xC5, 2, 1, 'o', ©op, &lo_2, 0, "XCH a@ ", &inst, 0xC6, 1, 1, 'o', &opor2, 0, 0, "XCHD a@ ", &inst, 0xD6, 1, 1, 'o', &opor2, 0, 0, /* BOOLEAN VARIABLE MANIPULATION OPS */ "CLR c ", &inst, 0xC3, 1, 1, 'o', ©op, 0, 0, "CLR b ", &inst, 0xC2, 2, 1, 'o', ©op, &lo_1, 0, "SETB c ", &inst, 0xD3, 1, 1, 'o', ©op, 0, 0, "SETB b ", &inst, 0xD2, 2, 1, 'o', ©op, &lo_1, 0, "CPL c ", &inst, 0xB3, 1, 1, 'o', ©op, 0, 0, "CPL b ", &inst, 0xB2, 2, 1, 'o', ©op, &lo_1, 0, "ANL cb ", &inst, 0x82, 2, 2, 'o', ©op, &lo_2, 0, "ANL c/ ", &inst, 0xB0, 2, 2, 'o', ©op, &lo_2, 0, "ORL cb ", &inst, 0x72, 2, 2, 'o', ©op, &lo_2, 0, "ORL c/ ", &inst, 0xA0, 2, 2, 'o', ©op, &lo_2, 0, "MOV cb ", &inst, 0xA2, 2, 1, 'o', ©op, &lo_2, 0, "MOV bc ", &inst, 0x92, 2, 2, 'o', ©op, &lo_1, 0, /* PROGRAM AND MACHINE CONTROL OPS */ "ACALLi ", &inst, 0x11, 2, 2, 'o', &absjmp, &lo_1, 0, "LCALLi ", &inst, 0x12, 3, 2, 'o', ©op, &hi_1, &lo_1, "RET ", &inst, 0x22, 1, 2, 'o', ©op, 0, 0, "RETI ", &inst, 0x32, 1, 2, 'o', ©op, 0, 0, "AJMP i ", &inst, 0x01, 2, 2, 'o', &absjmp, &lo_1, 0, "LJMP i ", &inst, 0x02, 3, 2, 'o', ©op, &hi_1, &lo_1, "SJMP i ", &inst, 0x80, 2, 2, 'o', ©op, &rel_1, 0, "JMP 1 ", &inst, 0x73, 1, 2, 'o', ©op, 0, 0, "JZ i ", &inst, 0x60, 2, 2, 'o', ©op, &rel_1, 0, "JNZ i ", &inst, 0x70, 2, 2, 'o', ©op, &rel_1, 0, "JC i ", &inst, 0x40, 2, 2, 'o', ©op, &rel_1, 0, "JNC i ", &inst, 0x50, 2, 2, 'o', ©op, &rel_1, 0, "JB bi ", &inst, 0x20, 3, 2, 'o', ©op, &lo_1, &rel_2, "JNB bi ", &inst, 0x30, 3, 2, 'o', ©op, &lo_1, &rel_2, "JBC bi ", &inst, 0x10, 3, 2, 'o', ©op, &lo_1, &rel_2, "CJNE ani", &inst, 0xB5, 3, 2, 'o', ©op, &lo_2, &rel_3, "CJNE a#i", &inst, 0xB4, 3, 2, 'o', ©op, &lo_2, &rel_3, "CJNE r#i", &inst, 0xB8, 3, 2, 'o', &opor1, &lo_2, &rel_3, "CJNE @#i", &inst, 0xB6, 3, 2, 'o', &opor1, &lo_2, &rel_3, "DJNZ ri ", &inst, 0xD8, 2, 2, 'o', &opor1, &rel_2, 0, "DJNZ ni ", &inst, 0xD5, 3, 2, 'o', ©op, &lo_1, &rel_2, "NOP ", &inst, 0x00, 1, 1, 'o', ©op, 0, 0, /* ASSEMBLER DIRECTIVES */ "ORG t ", &orgr, 0x00, 0, 0, 'p', 0, 0, 0, "CSEG ", &cseg, 0x00, 0, 0, 'p', 0, 0, 0, "DSEG ", &dseg, 0x00, 0, 0, 'p', 0, 0, 0, "XSEG ", &xseg, 0x00, 0, 0, 'p', 0, 0, 0, "BSEG ", &bseg, 0x00, 0, 0, 'p', 0, 0, 0, "ISEG ", &iseg, 0x00, 0, 0, 'p', 0, 0, 0, "EQU r ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "EQU b ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "EQU x ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "EQU n ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "EQU j ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "EQU i ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "EQU t ", &equr, 0x00, 0, 0, 'r', 0, 0, 0, "DS t ", &dods, 0x00, 0, 0, 'o', 0, 0, 0, "DBIT t ", &dbit, 0x00, 0, 0, 'o', 0, 0, 0, "END ", &endr, 0x00, 0, 0, 'p', 0, 0, 0, /* A sentinel record. This guy is filled in before searching with a copy */ /* of the extended op being searched for. If we get this far, that means */ /* it wasn't really in the table and we have an "unknown op" error. */ "--------", &uncl, 0x00, 0, 0, 'o', 0, 0, 0 }; |
Topic | Author | Date |
my own 8051 compiler... | 01/01/70 00:00 | |
Take it from here | 01/01/70 00:00 | |
Compiler, or Assembler? | 01/01/70 00:00 | |
How does it help? | 01/01/70 00:00 | |
opcodes | 01/01/70 00:00 | |
Language translators | 01/01/70 00:00 | |
well its always good to be ambitious | 01/01/70 00:00 | |
do it yourself compiler | 01/01/70 00:00 | |
SDCC | 01/01/70 00:00 | |
A simple alternative | 01/01/70 00:00 | |
There's a small-c compiler, too | 01/01/70 00:00 | |
update | 01/01/70 00:00 | |
why \'small\' when \'full\' is available for free | 01/01/70 00:00 | |
Mike, what are you doing? | 01/01/70 00:00 | |
Benefits | 01/01/70 00:00 | |
Jez, please READ the context | 01/01/70 00:00 | |
Point taken | 01/01/70 00:00 | |
That inspired me, I am starting a thread in the ch | 01/01/70 00:00 | |
Maybe this will help??? | 01/01/70 00:00 | |
he's gone | 01/01/70 00:00 | |
He probably figured out how much work it was | 01/01/70 00:00 | |
done! | 01/01/70 00:00 | |
So ... which language does it compile? | 01/01/70 00:00 | |
Sure![]() | 01/01/70 00:00 |