// File: /workspace/github_c_makefile_star2_O2/aap[P]rx-0/pdp1/mach.c
// Function: disasm
char*
disasm(Word w)
{
	static char s[100];
	char *p;
	int op, y;
	char *opstr, *sym;;

	op = w>>12 & 076;
	y = w & ADDRMASK;
	p = s;
	memset(s, 0, 100);
	switch(op){
	case 000:
	case 012: // jfd
	case 014:
	case 036:
	case 074:
		// no instruction
		sym = findsym(w);
		if(sym)
			p += sprintf(p, "%s", sym);
		else
			p += sprintf(p, "%o", w);
		break;
	case 002: opstr = "and"; goto memop;
	case 004: opstr = "ior"; goto memop;
	case 006: opstr = "xor"; goto memop;
	case 010: opstr = "xct"; goto memop;
	case 016: opstr = w & 010000 ? "jda" : "cal"; w &= ~010000; goto memop;
	case 020: opstr = "lac"; goto memop;
	case 022: opstr = "lio"; goto memop;
	case 024: opstr = "dac"; goto memop;
	case 026: opstr = "dap"; goto memop;
	case 030: opstr = "dip"; goto memop;
	case 032: opstr = "dio"; goto memop;
	case 034: opstr = "dzm"; goto memop;
	case 040: opstr = "add"; goto memop;
	case 042: opstr = "sub"; goto memop;
	case 044: opstr = "idx"; goto memop;
	case 046: opstr = "isp"; goto memop;
	case 050: opstr = "sad"; goto memop;
	case 052: opstr = "sas"; goto memop;
	case 054: opstr = "mus"; goto memop;
	case 056: opstr = "dis"; goto memop;
	case 060: opstr = "jmp"; goto memop;
	case 062: opstr = "jsp"; goto memop;
	case 064:	// skip
		if(y == 02000)
			p += sprintf(p, "spi ");
		else if(y == 01000)
			p += sprintf(p, "szo ");
		else if(y == 0400)
			p += sprintf(p, "sma ");
		else if(y == 0200)
			p += sprintf(p, "spa ");
		else if(y == 0100)
			p += sprintf(p, "sza ");
		else if((y&07770) == 0 && (y&7))
			p += sprintf(p, "szf %o ", y&7);
		else if((y&07707) == 0 && (y&070))
			p += sprintf(p, "szs %o ", y&070);
		else
			p += sprintf(p, "skp %o ", y);
		if(w & 010000)
			p += sprintf(p, "i ");
		break;
	case 066:	// shift
		p += sprintf(p, "%c", w&04000 ? 's' : 'r');
		p += sprintf(p, "%c", "xaic"[y>>9 & 3]);
		p += sprintf(p, "%c ", w&010000 ? 'r' : 'l');
		p += sprintf(p, "%o", y & 0777);
		break;
	case 070: opstr = "law";
	memop:
		p += sprintf(p, "%s ", opstr);
		if(w & 010000)
			p += sprintf(p, "i ");
		sym = findsym(y);
		if(sym)
			p += sprintf(p, "%s", sym);
		else
			p += sprintf(p, "%o", y);
		break;
	case 072:	// iot
		p += sprintf(p, "iot %o", w &017777);
		break;
	case 076:	// opr
		if(y == 04000)
			p += sprintf(p, "cli ");
		else if(y == 02200)
			p += sprintf(p, "lat ");
		else if(y == 01000)
			p += sprintf(p, "cma ");
		else if(y == 0400)
			p += sprintf(p, "hlt ");
		else if(y == 00200)
			p += sprintf(p, "cla ");
		else if(y == 00300)
			p += sprintf(p, "lap ");
		else if((y&07770) == 0 && (y&7))
			p += sprintf(p, "clf %o ", y&7);
		else if((y&07770) == 00010 && (y&7))
			p += sprintf(p, "stf %o ", y&7);
		else if(y == 0)
			p += sprintf(p, "nop ");
		else
			p += sprintf(p, "opr %o ", y);
		if(w & 010000)
			p += sprintf(p, "i ");
		break;
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %ebx
movl %edi, %eax
shrl $0xc, %eax
andl $0x3e, %eax
movl %edi, %r14d
andl $0xfff, %r14d           # imm = 0xFFF
xorps %xmm0, %xmm0
movaps %xmm0, 0xe87e(%rip)     # 0x12660
movaps %xmm0, 0xe867(%rip)     # 0x12650
movaps %xmm0, 0xe850(%rip)     # 0x12640
movaps %xmm0, 0xe839(%rip)     # 0x12630
movaps %xmm0, 0xe822(%rip)     # 0x12620
andl $0x0, 0xe86b(%rip)      # 0x12670
movaps %xmm0, 0xe804(%rip)     # 0x12610
leaq 0x246d(%rip), %rcx      # 0x6280
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %ebx, %edi
callq 0x28ce
leaq 0xe7e6(%rip), %rdi      # 0x12610
testq %rax, %rax
je 0x4088
movq %rax, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2090
cmpl $0x40, %r14d
je 0x417f
cmpl $0x80, %r14d
je 0x4114
cmpl $0x100, %r14d           # imm = 0x100
je 0x4140
cmpl $0x200, %r14d           # imm = 0x200
je 0x412a
cmpl $0x400, %r14d           # imm = 0x400
jne 0x4156
movb $0x0, 0xe78c(%rip)      # 0x12614
movl $0x20697073, 0xe77e(%rip) # imm = 0x20697073
jmp 0x422b
leaq 0x25f6(%rip), %rdx      # 0x6494
jmp 0x40a3
leaq 0x25d2(%rip), %rdx      # 0x647c
jmp 0x40a3
leaq 0x25c2(%rip), %rdx      # 0x6478
jmp 0x40a3
leaq 0x25be(%rip), %rdx      # 0x6480
jmp 0x40a3
leaq 0x25fa(%rip), %rdx      # 0x64c8
jmp 0x40a3
leaq 0x25c6(%rip), %rdx      # 0x64a0
jmp 0x40a3
leaq 0x25de(%rip), %rdx      # 0x64c4
jmp 0x40a3
leaq 0x259a(%rip), %rdx      # 0x648c
jmp 0x40a3
leaq 0x259a(%rip), %rdx      # 0x6498
jmp 0x40a3
cmpl $0x80, %r14d
je 0x421a
cmpl $0xc0, %r14d
je 0x4207
cmpl $0x100, %r14d           # imm = 0x100
je 0x4195
cmpl $0x200, %r14d           # imm = 0x200
je 0x41be
cmpl $0x480, %r14d           # imm = 0x480
je 0x41ab
cmpl $0x800, %r14d           # imm = 0x800
jne 0x41d1
movb $0x0, 0xe6bc(%rip)      # 0x12614
movl $0x20696c63, 0xe6ae(%rip) # imm = 0x20696C63
jmp 0x422b
leaq 0x253a(%rip), %rdx      # 0x64a8
jmp 0x40a3
leaq 0x253a(%rip), %rdx      # 0x64b4
jmp 0x40a3
leaq 0x2532(%rip), %rdx      # 0x64b8
jmp 0x40a3
leaq 0x251a(%rip), %rdx      # 0x64ac
jmp 0x40a3
andl $0x1fff, %ebx           # imm = 0x1FFF
leaq 0xe66c(%rip), %rdi      # 0x12610
leaq 0x2567(%rip), %rsi      # 0x6512
jmp 0x408f
leaq 0x24bd(%rip), %rdx      # 0x6474
jmp 0x40a3
btl $0xc, %ebx
leaq 0x24c1(%rip), %rax      # 0x6488
leaq 0x24b6(%rip), %rdx      # 0x6484
cmovaeq %rax, %rdx
xorl %ebx, %ebx
jmp 0x40a3
leaq 0x24b0(%rip), %rdx      # 0x6490
jmp 0x40a3
leaq 0x24d0(%rip), %rdx      # 0x64bc
jmp 0x40a3
leaq 0x24a4(%rip), %rdx      # 0x649c
jmp 0x40a3
leaq 0x24ac(%rip), %rdx      # 0x64b0
jmp 0x40a3
leaq 0x2494(%rip), %rdx      # 0x64a4
jmp 0x40a3
leaq 0x24a4(%rip), %rdx      # 0x64c0
jmp 0x40a3
btl $0xb, %ebx
setae %al
xorb $0x73, %al
movb %al, 0xe5e0(%rip)       # 0x12610
leaq 0xe5d9(%rip), %r14      # 0x12610
movl %ebx, %eax
shrl $0x9, %eax
andl $0x3, %eax
leaq 0x24bb(%rip), %rcx      # 0x6501
movb (%rax,%rcx), %al
movb %al, 0xe5c2(%rip)       # 0x12611
movb $0x0, 0xe5bc(%rip)      # 0x12612
leaq 0xe5b5(%rip), %rdi      # 0x12612
btl $0xc, %ebx
pushq $0x6c
popq %rax
pushq $0x72
popq %rdx
cmovael %eax, %edx
leaq 0x2495(%rip), %rsi      # 0x6506
xorl %eax, %eax
callq 0x22d0
cltq
leaq (%rax,%r14), %rdi
addq $0x2, %rdi
andl $0x1ff, %ebx            # imm = 0x1FF
leaq 0x2487(%rip), %rsi      # 0x6516
movl %ebx, %edx
jmp 0x40fd
leaq 0x2470(%rip), %rdx      # 0x650a
jmp 0x40a3
leaq 0x2429(%rip), %rdx      # 0x64cc
leaq 0xe566(%rip), %r12      # 0x12610
leaq 0x245d(%rip), %rsi      # 0x650e
movq %r12, %rdi
xorl %eax, %eax
callq 0x22d0
movslq %eax, %r15
addq %r12, %r15
btl $0xc, %ebx
jae 0x40d6
movb $0x0, 0x2(%r15)
movw $0x2069, (%r15)         # imm = 0x2069
addq $0x2, %r15
movl %r14d, %edi
callq 0x28ce
testq %rax, %rax
je 0x40f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x2090
jmp 0x4104
leaq 0x241f(%rip), %rsi      # 0x6516
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x22d0
leaq 0xe505(%rip), %rax      # 0x12610
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, 0xe4f9(%rip)      # 0x12614
movl $0x20617073, 0xe4eb(%rip) # imm = 0x20617073
jmp 0x422b
movb $0x0, 0xe4e3(%rip)      # 0x12614
movl $0x206f7a73, 0xe4d5(%rip) # imm = 0x206F7A73
jmp 0x422b
movb $0x0, 0xe4cd(%rip)      # 0x12614
movl $0x20616d73, 0xe4bf(%rip) # imm = 0x20616D73
jmp 0x422b
testw $0xff8, %bx             # imm = 0xFF8
je 0x424a
testw $0xfc7, %bx             # imm = 0xFC7
je 0x4265
leaq 0xe49d(%rip), %r15      # 0x12610
leaq 0x237f(%rip), %rsi      # 0x64f9
jmp 0x42b9
movb $0x0, 0xe48e(%rip)      # 0x12614
movl $0x20617a73, 0xe480(%rip) # imm = 0x20617A73
jmp 0x422b
movb $0x0, 0xe478(%rip)      # 0x12614
movl $0x20746c68, 0xe46a(%rip) # imm = 0x20746C68
jmp 0x422b
movb $0x0, 0xe462(%rip)      # 0x12614
movl $0x2074616c, 0xe454(%rip) # imm = 0x2074616C
jmp 0x422b
movb $0x0, 0xe44f(%rip)      # 0x12614
movl $0x20616d63, 0xe441(%rip) # imm = 0x20616D63
jmp 0x422b
movl %ebx, %eax
andl $0xff8, %eax            # imm = 0xFF8
cmpl $0x8, %eax
je 0x4280
testl %eax, %eax
jne 0x42a6
movl %ebx, %edx
andl $0x7, %edx
je 0x42a6
leaq 0xe415(%rip), %r14      # 0x12610
leaq 0x2335(%rip), %rsi      # 0x6537
jmp 0x4295
movb $0x0, 0xe406(%rip)      # 0x12614
movl $0x2070616c, 0xe3f8(%rip) # imm = 0x2070616C
jmp 0x422b
movb $0x0, 0xe3f3(%rip)      # 0x12614
movl $0x20616c63, 0xe3e5(%rip) # imm = 0x20616C63
leaq 0xe3e2(%rip), %rax      # 0x12614
btl $0xc, %ebx
jae 0x4104
movb $0x0, 0x2(%rax)
movw $0x2069, (%rax)         # imm = 0x2069
jmp 0x4104
movl %ebx, %edx
andl $0x7, %edx
je 0x4161
leaq 0xe3b4(%rip), %r14      # 0x12610
leaq 0x2286(%rip), %rsi      # 0x64e9
jmp 0x4295
movl %ebx, %edx
andl $0x38, %edx
je 0x416c
leaq 0xe399(%rip), %r14      # 0x12610
leaq 0x2273(%rip), %rsi      # 0x64f1
jmp 0x4295
movl %ebx, %edx
andl $0x7, %edx
je 0x42a6
leaq 0xe382(%rip), %r14      # 0x12610
leaq 0x22aa(%rip), %rsi      # 0x653f
movq %r14, %rdi
xorl %eax, %eax
callq 0x22d0
cltq
addq %r14, %rax
jmp 0x4232
testl %r14d, %r14d
je 0x42d0
leaq 0xe35e(%rip), %r15      # 0x12610
leaq 0x2293(%rip), %rsi      # 0x654c
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x22d0
cltq
addq %r15, %rax
jmp 0x4232
movb $0x0, 0xe33d(%rip)      # 0x12614
movl $0x20706f6e, 0xe32f(%rip) # imm = 0x20706F6E
jmp 0x422b