$title('instruction table for 8086 disassembler')
$date(10/5/80)

instr86: do;

declare
	qq$in literally '0',
	alt1 literally '0',
	alt2 literally '1',
	alt3 literally '2',
	alt4 literally '3',
	alt5 literally '4',
	alt6 literally '5',
	alt7 literally '6',
	alt8 literally '7';

$include(optab.lit)

declare
	type$0 literally '0',
	type$1 literally '1',
	type$2 literally '2',
	type$3 literally '3',
	type$4 literally '4',
	type$5 literally '5',
	type$6 literally '6',
	type$7 literally '7',
	type$8 literally '7',
	type$9 literally '7',
	type$10 literally '8',
	type$11 literally '9',
	type$12 literally '10',
	type$13 literally '11',
	type$14 literally '12',
	type$15 literally '12',
	type$16 literally '12',
	type$17 literally '12',
	type$18 literally '13',
	type$19 literally '13',
	type$20 literally '13',
	type$21 literally '13',
	type$22 literally '14',
	type$23 literally '15',
	type$24 literally '15',
	type$25 literally '16',
	type$26 literally '16',
	type$27 literally '17',
	type$28 literally '17',
	type$29 literally '17',
	type$30 literally '17',
	type$31 literally '18',
	type$32 literally '18',
	type$33 literally '19',
	type$34 literally '20',
	type$35 literally '20',
	type$36 literally '21',
	type$37 literally '21',
	type$38 literally '22',
	type$39 literally '23',
	type$40 literally '24',
	type$41 literally '24',
	type$42 literally '25',
	type$43 literally '26',
	type$44 literally '27',
	type$45 literally '28';

declare
	prefix$type literally '0ffh';

declare alt$table$ptrs (8) address public data (
	.alt$1$tab,
	.alt$2$tab,
	.alt$3$tab,
	.alt$4$tab,
	.alt$5$tab,
	.alt$6$tab,
	.alt$7$tab,
	.alt$8$tab);

declare alt$1$tab (*) byte data (
	add$in,	type$44,
	or$in,	type$34,
	adc$in,	type$44,
	sbb$in,	type$44,
	and$in,	type$34,
	sub$in,	type$44,
	xor$in,	type$34,
	cmp$in,	type$44);

declare alt$2$tab (*) byte data (
	add$in,	type$44,
	qq$in,	type$0,
	adc$in,	type$44,
	sbb$in,	type$44,
	qq$in,	type$0,
	sub$in,	type$44,
	qq$in,	type$0,
	cmp$in,	type$44);

declare alt$3$tab (*) byte data (
	add$in,	type$38,
	qq$in,	type$0,
	adc$in,	type$38,
	sbb$in,	type$38,
	qq$in,	type$0,
	sub$in,	type$38,
	qq$in,	type$0,
	cmp$in,	type$38);

declare alt$4$tab (*) byte data (
	rol$in,	type$29,
	ror$in,	type$29,
	rcl$in,	type$29,
	rcr$in,	type$29,
	shl$in,	type$29,
	shr$in,	type$29,
	qq$in,	type$0,
	sar$in,	type$29);

declare alt$5$tab (*) byte data (
	rol$in,	type$27,
	ror$in,	type$27,
	rcl$in,	type$27,
	rcr$in,	type$27,
	shl$in,	type$27,
	shr$in,	type$27,
	qq$in,	type$0,
	sar$in,	type$27);

declare alt$6$tab (*) byte data (
	test$in,	type$34,
	qq$in,	type$0,
	not$in,	type$45,
	neg$in,	type$45,
	mul$in,	type$45,
	imul$in,	type$45,
	div$in,	type$45,
	idiv$in,	type$45);

declare alt$7$tab (*) byte data (
	inc$in,	type$45,
	dec$in,	type$45,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0);

declare alt$8$tab (*) byte data (
	inc$in,	type$45,
	dec$in,	type$45,
	call$in,	type$9,
	callf$in,	type$7,
	jmp$in,	type$9,
	jmpf$in,	type$7,
	push$in,	type$7,
	qq$in,	type$0);

/*
	instruction table for 8086 disassembler
	instruction is index into table
	there are 2 bytes per instruction:
		1.  index into ascii opcode table
		2.  instruction type (how many operands of what type, etc.)
*/

declare instr$table (512) byte public data (
	add$in,	type$14,    /* 0 */
	add$in,	type$15,
	add$in,	type$16,
	add$in,	type$17,
	add$in,	type$23,
	add$in,	type$24,
	push$in,	type$4,
	pop$in,	type$4,
	or$in,	type$14,
	or$in,	type$15,
	or$in,	type$16,
	or$in,	type$17,
	or$in,	type$23,
	or$in,	type$24,
	push$in,	type$4,
	qq$in,	type$0,
	adc$in,	type$14,    /* 10 */
	adc$in,	type$15,
	adc$in,	type$16,
	adc$in,	type$17,
	adc$in,	type$23,
	adc$in,	type$24,
	push$in,	type$4,
	pop$in,	type$4,
	sbb$in,	type$14,
	sbb$in,	type$15,
	sbb$in,	type$16,
	sbb$in,	type$17,
	sbb$in,	type$23,
	sbb$in,	type$24,
	push$in,	type$4,
	pop$in,	type$4,
	and$in,	type$14,    /* 20 */
	and$in,	type$15,
	and$in,	type$16,
	and$in,	type$17,
	and$in,	type$23,
	and$in,	type$24,
	es$in,	prefix$type,
	daa$in,	type$1,
	sub$in,	type$14,
	sub$in,	type$15,
	sub$in,	type$16,
	sub$in,	type$17,
	sub$in,	type$23,
	sub$in,	type$24,
	cs$in,	prefix$type,
	das$in,	type$1,
	xor$in,	type$14,    /* 30 */
	xor$in,	type$15,
	xor$in,	type$16,
	xor$in,	type$17,
	xor$in,	type$23,
	xor$in,	type$24,
	ss$in,	prefix$type,
	aaa$in,	type$1,
	cmp$in,	type$14,
	cmp$in,	type$15,
	cmp$in,	type$16,
	cmp$in,	type$17,
	cmp$in,	type$23,
	cmp$in,	type$24,
	ds$in,	prefix$type,
	aas$in,	type$1,
	inc$in,	type$3,    /* 40 */
	inc$in,	type$3,
	inc$in,	type$3,
	inc$in,	type$3,
	inc$in,	type$3,
	inc$in,	type$3,
	inc$in,	type$3,
	inc$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	dec$in,	type$3,
	push$in,	type$3,    /* 50 */
	push$in,	type$3,
	push$in,	type$3,
	push$in,	type$3,
	push$in,	type$3,
	push$in,	type$3,
	push$in,	type$3,
	push$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	pop$in,	type$3,
	qq$in,	type$0,    /* 60 */
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	qq$in,	type$0,
	jo$in,	type$5,    /* 70 */
	jno$in,	type$5,
	jb$in,	type$5,
	jnb$in,	type$5,
	jz$in,	type$5,
	jnz$in,	type$5,
	jbe$in,	type$5,
	ja$in,	type$5,
	js$in,	type$5,
	jns$in,	type$5,
	jp$in,	type$5,
	jnp$in,	type$5,
	jl$in,	type$5,
	jnl$in,	type$5,
	jle$in,	type$5,
	jg$in,	type$5,
	alt1,	type$43,    /* 80 */
	alt1,	type$43,
	alt2,	type$43,
	alt2,	type$43,
	test$in,	type$14,
	test$in,	type$15,
	xchg$in,	type$16,
	xchg$in,	type$17,
	mov$in,	type$14,
	mov$in,	type$15,
	mov$in,	type$16,
	mov$in,	type$17,
	mov$in,	type$36,
	lea$in,	type$39,
	mov$in,	type$37,
	pop$in,	type$9,
	nop$in,	type$1,    /* 90 */
	xchg$in,	type$33,
	xchg$in,	type$33,
	xchg$in,	type$33,
	xchg$in,	type$33,
	xchg$in,	type$33,
	xchg$in,	type$33,
	xchg$in,	type$33,
	cbw$in,	type$1,
	cwd$in,	type$1,
	callf$in,	type$13,
	wait$in,	type$1,
	pushf$in,	type$1,
	popf$in,	type$1,
	sahf$in,	type$1,
	lahf$in,	type$1,
	mov$in,	type$18,    /* A0 */
	mov$in,	type$19,
	mov$in,	type$20,
	mov$in,	type$21,
	movsb$in,	type$1,
	movsw$in,	type$1,
	cmpsb$in,	type$1,
	cmpsw$in,	type$1,
	test$in,	type$23,
	test$in,	type$24,
	stosb$in,	type$1,
	stosw$in,	type$1,
	lodsb$in,	type$1,
	lodsw$in,	type$1,
	scasb$in,	type$1,
	scasw$in,	type$1,
	mov$in,	type$31,    /* B0 */
	mov$in,	type$31,
	mov$in,	type$31,
	mov$in,	type$31,
	mov$in,	type$31,
	mov$in,	type$31,
	mov$in,	type$31,
	mov$in,	type$31,
	mov$in,	type$32,
	mov$in,	type$32,
	mov$in,	type$32,
	mov$in,	type$32,
	mov$in,	type$32,
	mov$in,	type$32,
	mov$in,	type$32,
	mov$in,	type$32,
	qq$in,	type$0,    /* C0 */
	qq$in,	type$0,
	ret$in,	type$11,
	ret$in,	type$1,
	les$in,	type$39,
	lds$in,	type$39,
	mov$in,	type$40,
	mov$in,	type$41,
	qq$in,	type$0,
	qq$in,	type$0,
	retf$in,	type$11,
	retf$in,	type$1,
	int$in,	type$12,
	int$in,	type$10,
	into$in,	type$1,
	iret$in,	type$1,
	alt4,	type$43,    /* D0 */
	alt4,	type$43,
	alt5,	type$43,
	alt5,	type$43,
	aam$in,	type$2,
	aad$in,	type$2,
	qq$in,	type$0,
	xlat$in,	type$1,
	esc$in,	type$42,
	esc$in,	type$42,
	esc$in,	type$42,
	esc$in,	type$42,
	esc$in,	type$42,
	esc$in,	type$42,
	esc$in,	type$42,
	esc$in,	type$42,
	loopne$in,	type$5,    /* E0 */
	loope$in,	type$5,
	loop$in,	type$5,
	jcxz$in,	type$5,
	in$in,	type$22,
	in$in,	type$22,
	out$in,	type$22,
	out$in,	type$22,
	call$in,	type$6,
	jmp$in,	type$6,
	jmpf$in,	type$13,
	jmps$in,	type$5,
	in$in,	type$25,
	in$in,	type$26,
	out$in,	type$25,
	out$in,	type$26,
	lock$in,	prefix$type,    /* F0 */
	qq$in,	type$0,
	repne$in,	prefix$type,
	rep$in,	prefix$type,
	hlt$in,	type$1,
	cmc$in,	type$1,
	alt6,	type$43,
	alt6,	type$43,
	clc$in,	type$1,
	stc$in,	type$1,
	cli$in,	type$1,
	sti$in,	type$1,
	cld$in,	type$1,
	std$in,	type$1,
	alt7,	type$43,
	alt8,	type$43);

end instr86;
