// File: /workspace/github_c_makefile_star2_O1/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, 0xe402(%rip)     # 0x12660
movaps %xmm0, 0xe3eb(%rip)     # 0x12650
movaps %xmm0, 0xe3d4(%rip)     # 0x12640
movaps %xmm0, 0xe3bd(%rip)     # 0x12630
movaps %xmm0, 0xe3a6(%rip)     # 0x12620
movaps %xmm0, 0xe38f(%rip)     # 0x12610
movl $0x0, 0xe3e5(%rip)      # 0x12670
leaq 0x1ff2(%rip), %rcx      # 0x6284
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %ebx, %edi
callq 0x2a4d
leaq 0xe367(%rip), %rdi      # 0x12610
testq %rax, %rax
je 0x44e7
movq %rax, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2090
cmpl $0xff, %r14d
jle 0x45b0
cmpl $0x100, %r14d           # imm = 0x100
je 0x45d5
cmpl $0x200, %r14d           # imm = 0x200
je 0x45eb
cmpl $0x400, %r14d           # imm = 0x400
jne 0x4617
movb $0x0, 0xe317(%rip)      # 0x12614
movl $0x20697073, 0xe309(%rip) # imm = 0x20697073
jmp 0x46c2
leaq 0x2111(%rip), %rdx      # 0x6424
jmp 0x4502
leaq 0x20ed(%rip), %rdx      # 0x640c
jmp 0x4502
leaq 0x20dd(%rip), %rdx      # 0x6408
jmp 0x4502
leaq 0x20d9(%rip), %rdx      # 0x6410
jmp 0x4502
leaq 0x2115(%rip), %rdx      # 0x6458
jmp 0x4502
leaq 0x20e1(%rip), %rdx      # 0x6430
jmp 0x4502
leaq 0x20f9(%rip), %rdx      # 0x6454
jmp 0x4502
leaq 0x20b5(%rip), %rdx      # 0x641c
jmp 0x4502
leaq 0x20b5(%rip), %rdx      # 0x6428
jmp 0x4502
cmpl $0x1ff, %r14d           # imm = 0x1FF
jg 0x4573
cmpl $0x80, %r14d
je 0x4642
cmpl $0xc0, %r14d
je 0x469e
cmpl $0x100, %r14d           # imm = 0x100
jne 0x4668
movb $0x0, 0xe261(%rip)      # 0x12614
movl $0x20746c68, 0xe253(%rip) # imm = 0x20746C68
jmp 0x46c2
leaq 0x206f(%rip), %rdx      # 0x6438
jmp 0x4502
leaq 0x206f(%rip), %rdx      # 0x6444
jmp 0x4502
leaq 0x2067(%rip), %rdx      # 0x6448
jmp 0x4502
leaq 0x204f(%rip), %rdx      # 0x643c
jmp 0x4502
andl $0x1fff, %ebx           # imm = 0x1FFF
leaq 0xe211(%rip), %rdi      # 0x12610
leaq 0x209c(%rip), %rsi      # 0x64a2
jmp 0x44ee
leaq 0x1ff2(%rip), %rdx      # 0x6404
jmp 0x4502
btl $0xc, %ebx
leaq 0x1ff6(%rip), %rax      # 0x6418
leaq 0x1feb(%rip), %rdx      # 0x6414
cmovaeq %rax, %rdx
xorl %ebx, %ebx
jmp 0x4502
leaq 0x1fe5(%rip), %rdx      # 0x6420
jmp 0x4502
leaq 0x2005(%rip), %rdx      # 0x644c
jmp 0x4502
leaq 0x1fd9(%rip), %rdx      # 0x642c
jmp 0x4502
leaq 0x1fe1(%rip), %rdx      # 0x6440
jmp 0x4502
leaq 0x1fc9(%rip), %rdx      # 0x6434
jmp 0x4502
leaq 0x1fd9(%rip), %rdx      # 0x6450
jmp 0x4502
btl $0xb, %ebx
setae %al
xorb $0x73, %al
movb %al, 0xe185(%rip)       # 0x12610
leaq 0xe17e(%rip), %r14      # 0x12610
movl %ebx, %eax
shrl $0x9, %eax
andl $0x3, %eax
leaq 0x1ff0(%rip), %rcx      # 0x6491
movb (%rax,%rcx), %al
movb %al, 0xe167(%rip)       # 0x12611
movb $0x0, 0xe161(%rip)      # 0x12612
leaq 0xe15a(%rip), %rdi      # 0x12612
btl $0xc, %ebx
movl $0x6c, %eax
movl $0x72, %edx
cmovael %eax, %edx
leaq 0x1fc6(%rip), %rsi      # 0x6496
xorl %eax, %eax
callq 0x22e0
cltq
leaq (%rax,%r14), %rdi
addq $0x2, %rdi
andl $0x1ff, %ebx            # imm = 0x1FF
leaq 0x1fb8(%rip), %rsi      # 0x64a6
movl %ebx, %edx
jmp 0x455c
leaq 0x1fa1(%rip), %rdx      # 0x649a
jmp 0x4502
leaq 0x1f5a(%rip), %rdx      # 0x645c
leaq 0xe107(%rip), %r12      # 0x12610
leaq 0x1f8e(%rip), %rsi      # 0x649e
movq %r12, %rdi
xorl %eax, %eax
callq 0x22e0
movslq %eax, %r15
addq %r12, %r15
btl $0xc, %ebx
jae 0x4535
movb $0x0, 0x2(%r15)
movw $0x2069, (%r15)         # imm = 0x2069
addq $0x2, %r15
movl %r14d, %edi
callq 0x2a4d
testq %rax, %rax
je 0x454f
movq %r15, %rdi
movq %rax, %rsi
callq 0x2090
jmp 0x4563
leaq 0x1f50(%rip), %rsi      # 0x64a6
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x22e0
leaq 0xe0a6(%rip), %rax      # 0x12610
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x200, %r14d           # imm = 0x200
je 0x4655
cmpl $0x480, %r14d           # imm = 0x480
je 0x46b1
cmpl $0x800, %r14d           # imm = 0x800
jne 0x4668
movb $0x0, 0xe073(%rip)      # 0x12614
movl $0x20696c63, 0xe065(%rip) # imm = 0x20696C63
jmp 0x46c2
cmpl $0x40, %r14d
je 0x4601
cmpl $0x80, %r14d
jne 0x4617
movb $0x0, 0xe04e(%rip)      # 0x12614
movl $0x20617073, 0xe040(%rip) # imm = 0x20617073
jmp 0x46c2
movb $0x0, 0xe038(%rip)      # 0x12614
movl $0x20616d73, 0xe02a(%rip) # imm = 0x20616D73
jmp 0x46c2
movb $0x0, 0xe022(%rip)      # 0x12614
movl $0x206f7a73, 0xe014(%rip) # imm = 0x206F7A73
jmp 0x46c2
movb $0x0, 0xe00c(%rip)      # 0x12614
movl $0x20617a73, 0xdffe(%rip) # imm = 0x20617A73
jmp 0x46c2
testl $0xff8, %ebx            # imm = 0xFF8
je 0x46e1
testl $0xfc7, %ebx            # imm = 0xFC7
je 0x46fc
leaq 0xdfda(%rip), %r15      # 0x12610
leaq 0x1e4c(%rip), %rsi      # 0x6489
jmp 0x4755
movb $0x0, 0xdfcb(%rip)      # 0x12614
movl $0x20616c63, 0xdfbd(%rip) # imm = 0x20616C63
jmp 0x46c2
movb $0x0, 0xdfb8(%rip)      # 0x12614
movl $0x20616d63, 0xdfaa(%rip) # imm = 0x20616D63
jmp 0x46c2
movl %ebx, %eax
andl $0xff8, %eax            # imm = 0xFF8
cmpl $0x8, %eax
je 0x471c
testl %eax, %eax
jne 0x4742
movl %ebx, %edx
andl $0x7, %edx
je 0x4717
leaq 0xdf7e(%rip), %r14      # 0x12610
leaq 0x1e2e(%rip), %rsi      # 0x64c7
jmp 0x4731
movb $0x0, 0xdf6f(%rip)      # 0x12614
movl $0x2070616c, 0xdf61(%rip) # imm = 0x2070616C
jmp 0x46c2
movb $0x0, 0xdf5c(%rip)      # 0x12614
movl $0x2074616c, 0xdf4e(%rip) # imm = 0x2074616C
leaq 0xdf4b(%rip), %rax      # 0x12614
btl $0xc, %ebx
jae 0x4563
movb $0x0, 0x2(%rax)
movw $0x2069, (%rax)         # imm = 0x2069
jmp 0x4563
movl %ebx, %edx
andl $0x7, %edx
je 0x4623
leaq 0xdf1d(%rip), %r14      # 0x12610
leaq 0x1d7f(%rip), %rsi      # 0x6479
jmp 0x4731
movl %ebx, %edx
andl $0x38, %edx
je 0x462f
leaq 0xdf02(%rip), %r14      # 0x12610
leaq 0x1d6c(%rip), %rsi      # 0x6481
jmp 0x4731
cmpl $0x8, %eax
jne 0x4742
movl %ebx, %edx
andl $0x7, %edx
je 0x4742
leaq 0xdee6(%rip), %r14      # 0x12610
leaq 0x1d9e(%rip), %rsi      # 0x64cf
movq %r14, %rdi
xorl %eax, %eax
callq 0x22e0
cltq
addq %r14, %rax
jmp 0x46c9
testl %r14d, %r14d
je 0x476c
leaq 0xdec2(%rip), %r15      # 0x12610
leaq 0x1d87(%rip), %rsi      # 0x64dc
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x22e0
cltq
addq %r15, %rax
jmp 0x46c9
movb $0x0, 0xdea1(%rip)      # 0x12614
movl $0x20706f6e, 0xde93(%rip) # imm = 0x20706F6E
jmp 0x46c2