english
version "1.0"
identify "xyz"

#: This module implements the 8051 micrcontroller instruction codes.

module code_types

define code					#: Executable code
    variant type code_type
	acall code_address			#: ACALL address
	add_a_rn rn				#: ADD A, Rn
	add_a_direct direct			#: ADD A, direct
	add_a_ri ri				#: ADD A, @Ri
	add_a_data immediate			#: ADD A, #data
	addc_a_rn rn				#: ADDC A, Rn
	addc_a_direct direct			#: ADDC A, direct
	addc_a_ri ri				#: ADDC A, @Ri
	addc_a_data immediate			#: ADDC A, #data
	ajmp code_address			#: AJMP address
	anl_a_rn rn				#: ANL A, Rn
	anl_a_direct direct			#: ANL A, direct
	anl_a_ri ri				#: ANL A, @Ri
	anl_a_data immediate			#: ANL A, #data
	anl_direct_a direct			#: ANL direct, A
	anl_direct_data direct_immediate	#: ANL direct, #data
	anl_c_bit bit_address			#: ANL C, bit
	anl_c_nbit bit_address			#: ANL C, /bit
	cjne_a_direct_rel direct_relative	#: CJNE A, direct, rel
	cjne_a_data_rel immediate_relative	#: CJNE A, #data, rel
	cjne_rn_data_rel rn_immediate_relative	#: CJNE Rn, #data, rel
	cjne_ri_data_rel ri_immediate_relative	#: CJNE @Ri, #data, rel
	clr_a bogus				#: CLR A
	clr_c bogus				#: CLR C
	clr_bit bit_address			#: CLR bit
	cpl_a bogus				#: CPL A
	cpl_c bogus				#: CPL C
	cpl_bit bit_address			#: CPL bit
	da bogus				#: DA
	dec_a bogus				#: DEC A
	dec_rn rn				#: DEC Rn
	dec_direct direct			#: DEC direct
	dec_ri ri				#: DEC Rn
	div bogus				#: DIV AB
	djnz_rn_rel rn_relative			#: DJNZ Rn, rel
	djnz_direct_rel direct_relative		#: DJNZ direct, rel
	inc_a bogus				#: INC A
	inc_rn rn				#: INC Rn
	inc_direct direct			#: INC direct
	inc_ri ri				#: INC Rn
	inc_dptr bogus				#: INC dptr
	jb_bit_rel bit_relative			#: JB bit, rel
	jbc_bit_rel bit_relative		#: JBC bit, rel
	jc_rel relative				#: JC relative
	jmp_a_dptr bogus			#: JMP @A+DPTR
	jnb_bit_rel bit_relative		#: JNP bit, rel
	jnc_rel relative			#: JNC relative
	jnz_rel relative			#: JNZ relative
	jz_rel relative				#: JZ relative
	lcall code_address			#: LCALL address
	ljmp code_address			#: LJMP address
	mov_a_rn rn				#: MOV A, Rn
	mov_a_direct direct			#: MOV A, direct
	mov_a_ri ri				#: MOV A, @Ri
	mov_a_data immediate			#: MOV A, #data
	mov_rn_a rn				#: MOV Rn, A
	mov_rn_direct rn_direct			#: MOV Rn, direct
	mov_rn_data rn_immediate		#: MOV Rn, #data
	mov_direct_a direct			#: MOV direct, A
	mov_direct_rn direct_rn			#: MOV direct, Rn
	mov_direct_direct direct_direct		#: MOV direct, direct
	mov_direct_ri direct_ri			#: MOV direct, @Ri
	mov_direct_data direct_immediate	#: MOV direct, #data
	mov_ri_a ri				#: MOV @Ri, A
	mov_ri_direct ri_direct			#: MOV @Ri, direct
	mov_ri_data ri_immediate		#: MOV @Ri, #data
	mov_c_bit bit_address			#: MOV C, bit
	mov_bit_c bit_address			#: MOV bit, C
	mov_dptr_data16 immediate16		#: MOV DPTR, data16
	movc_a_dptr bogus			#: MOVC A, @A+DPTR
	movc_a_pc bogus				#: MOVC A, @A+PC
	movx_a_ri ri				#: MOVX A, @Ri
	movx_a_dptr bogus			#: MOVX A, @DPTR
	movx_ri_a ri				#: MOVX @Ri, A
	movx_dptr_a bogus			#: MOVX @DPTR, A
	mul_ab bogus				#: MUL AB
	nop bogus				#: NOP
	orl_a_rn rn				#: ORL A, Rn
	orl_a_direct direct			#: ORL A, direct
	orl_a_ri ri				#: ORL A, @Ri
	orl_a_data immediate			#: ORL A, #data
	orl_direct_a direct			#: ORL direct, A
	orl_direct_data direct_immediate	#: ORL direct, #data
	orl_c_bit bit_address			#: ORL C, bit
	orl_c_nbit bit_address			#: ORL C, /bit
	pop_direct direct			#: POP direct
	push_direct direct			#: PUSH direct
	ret bogus				#: RET
	reti bogus				#: RETI
	rl_a bogus				#: RL A
	rlc_a bogus				#: RLC A
	rr_a bogus				#: RR A
	rrc_a bogus				#: RRC A
	setb_c bogus				#: SETB C
	setb_bit bit_address			#: SETB bit
	sjmp_rel relative			#: SJMP rel
	sbbc_a_rn rn				#: SBBC A, Rn
	sbbc_a_direct direct			#: SBBC A, direct
	sbbc_a_ri ri				#: SBBC A, @Ri
	sbbc_a_data immediate			#: SBBC A, #data
	swap_a bogus				#: SWAP A
	xch_a_rn rn				#: XCH A, Rn
	xch_a_direct direct			#: XCH A, direct
	xch_a_ri ri				#: XCH A, @Ri
	xchd_a_ri ri 				#: XCHD A, Ri
	xrl_a_rn rn				#: XRL A, Rn
	xrl_a_direct direct			#: XRL A, direct
	xrl_a_ri ri				#: XRL A, @Ri
	xrl_a_data immediate			#: XRL A, #data
	xrl_direct_a direct			#: XRL direct, A
	xrl_direct_data direct_immediate	#: XRL direct, #data
    generate allocate, erase, print

define bit_relative			#: Bit and relative operands
    record
	bit_address bit_address		#: Bit address
	relative relative		#: Relative address
    generate allocate, erase, print

define code_address			#: Absolute code address opperand
    record
	address unsigned		#: Actual code address (no masking)
	instruction instruction		#: Target instruction
    generate allocate, erase, print

define direct				#: 8-bit direct operand
    record
	address unsigned		#: The actual address value
    generate allocate, erase, print

define direct_direct			#: Two direct operands
    record
	source direct			#: Source address
	destination direct		#: Destination address
    generate allocate, erase, print

define direct_immediate			#: Direct and immediate operands
    record
	direct direct			#: 8-bit direct address
	immediate immediate		#: 8-bit immediate data
    generate allocate, erase, print

define direct_relative			#: Direct and relative operands
    record
	direct direct			#: 8-bit direct address
	relative relative		#: 8-bit relative address
    generate allocate, erase, print

define direct_ri			#: Direct and @Ri operands
    record
	direct direct			#: 8-bit direct address
	ri ri				#: Register indirect
    generate allocate, erase, print

define direct_rn			#: Direct and register operands
    record
	direct direct			#: 8-bit direct address
	rn rn				#: Register
    generate allocate, erase, print

define immediate			#: 8-bit immediate data
    record
	value unsigned			#: 8-bit value (0-255)
    generate allocate, erase, print

define immediate16			#: 16-bit immediate data operand
    record
	value unsigned			#: 16-bit data value (0-0xffff)
    generate allocate, erase, print
	
define immediate_relative		#: Immediate and relative operands
    record
	immediate immediate		#: 8-bit immediate value
	relative relative		#: 8-bit relative address
    generate allocate, erase, print

define instruction			#: One executable instruction
    record
	address unsigned		#: Address of instruction
	code code			#: Code for instruction
	next instruction
    generate allocate, erase, print

define relative				#: Relative address operands
    record
	address unsigned		#: Actual code address (no masking)
	instruction instruction		#: Target instruction
	offset unsigned			#: 8-bit offset from instruction end
    generate allocate, erase, print

define ri				#: Register indirect operand
    record
	number unsigned			#: Register number
    generate allocate, erase, print

define ri_immediate_relative		#: Reg. indir., immediate, & rel. ops
    record
	ri ri				#: Register indirect
	immediate unsigned		#: 8-bit immediate value
	relative relative		#: 8-bit relative address
    generate allocate, erase, print

define ri_direct			#: Reg. indirect and direct operands
    record
	ri ri				#: Register indirect
	direct direct			#: 8-bit direct address
    generate allocate, erase, print

define ri_immediate			#: Reg. indirect and immediate operands
    record
	ri ri				#: Register indirect
	immediate immediate		#: 8-bit immeiate value
    generate allocate, erase, print

define rn
    record
	number unsigned			#: Register number (0-7)
    generate allocate, erase, print

define rn_immediate_relative		#: Register, immediate, & rel. operands
    record
	rn rn				#: Register
	immediate immediate		#: 8-bit immediate data
	relative relative		#: 8-bit relative address
    generate allocate, erase, print	

define rn_direct			#: Register & direct operands
    record
	rn rn				#: Register
	direct direct			#: 8-bit direct address
    generate allocate, erase, print

define rn_immediate
    record
	rn rn				#: Register
	immediate immediate		#: 8-bit immediate data
    generate allocate, erase, print

define rn_relative
    record
	rn rn				#: Register
	relative relative		#: 8-bit relative address
    generate allocate, erase, print