open Physical;; type ('a,'b) union2 = [ `U1 of 'a | `U2 of 'b ] type ('a,'b,'c) union3 = [ `U1 of 'a | `U2 of 'b | `U3 of 'c ] type ('a,'b,'c,'d,'e,'f) union6 = [ `U1 of 'a | `U2 of 'b | `U3 of 'c | `U4 of 'd | `U5 of 'e | `U6 of 'f ] type direct = [ `DIRECT of byte ] type indirect = [ `INDIRECT of bit ] type ext_indirect = [ `EXT_INDIRECT of bit ] type reg = [ `REG of bit * bit * bit ] type acc = [ `A ] type b = [ `B ] type dptr = [ `DPTR ] type data = [ `DATA of byte ] type data16 = [ `DATA16 of word ] type acc_dptr = [ `A_DPTR ] type acc_pc = [ `A_PC ] type indirect_dptr = [ `IND_DPTR ] type ext_indirect_dptr = [ `EXT_IND_DPTR ] type carry = [ `C ] type bit = [ `BIT of byte ] type nbit = [ `NBIT of byte ] type rel = [ `REL of byte ] type addr11 = [ `ADDR11 of word11 ] type addr16 = [ `ADDR16 of word ] type instruction = (* arithmetic operations *) ADD of acc * [ reg | direct | indirect | data ] | ADDC of acc * [ reg | direct | indirect | data ] | SUBB of acc * [ reg | direct | indirect | data ] | INC of [ acc | reg | direct | indirect | dptr ] | DEC of [ acc | reg | direct | indirect ] | MUL of acc * b | DIV of acc * b | DA of acc (* logical operations *) | ANL of (acc * [ reg | direct | indirect | data ], direct * [ acc | data ], carry * [ bit | nbit]) union3 | ORL of (acc * [ reg | data | direct | indirect ], direct * [ acc | data ], carry * [ bit | nbit]) union3 | XRL of (acc * [ data | reg | direct | indirect ], direct * [ acc | data ]) union2 | CLR of [ acc | carry | bit ] | CPL of [ acc | carry | bit ] | RL of acc | RLC of acc | RR of acc | RRC of acc | SWAP of acc (* data transfer *) | MOV of (acc * [ reg | direct | indirect | data ], [ reg | indirect ] * [ acc | direct | data ], direct * [ acc | reg | direct | indirect | data ], dptr * data16, carry * bit, bit * carry ) union6 | MOVC of acc * [ acc_dptr | acc_pc ] | MOVX of (acc * [ ext_indirect | ext_indirect_dptr ], [ ext_indirect | ext_indirect_dptr ] * acc) union2 | SETB of [ carry | bit ] | PUSH of direct | POP of direct | XCH of acc * [ reg | direct | indirect ] | XCHD of acc * indirect (* program branching *) | JC of rel | JNC of rel | JB of bit * rel | JNB of bit * rel | JBC of bit * rel | ACALL of addr11 | LCALL of addr16 | RET | RETI | AJMP of addr11 | LJMP of addr16 | SJMP of rel | JMP of indirect_dptr | JZ of rel | JNZ of rel | CJNE of (acc * [ direct | data ], [ reg | indirect ] * data) union2 * rel | DJNZ of [ reg | direct ] * rel | NOP