OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zopcodes.cpp] - Rev 69

Go to most recent revision | Compare with Previous | Blame | View Log

////////////////////////////////////////////////////////////////////////////////
//
// Filename: 	zopcodes.cpp
//
// Project:	Zip CPU -- a small, lightweight, RISC CPU core
//
// Purpose:	A simple program to handle the disassembly and definition
//		of the various Zip Assembly opcodes.  The primary function
//		of this file is the zipi_to_string, or Zip Instruction to
//		string (disassemble) conversion.
//
// Creator:	Dan Gisselquist, Ph.D.
//		Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015, Gisselquist Technology, LLC
//
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
//
// License:	GPL, v3, as defined and found on www.gnu.org,
//		http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
 
#include <stdio.h>
#include <strings.h>
#include <string.h>
#include <assert.h>
 
#include "twoc.h"
#include "zopcodes.h"
 
const	char	*zop_regstr[] = {
	"R0", "R1", "R2", "R3",
	"R4", "R5", "R6", "R7",
	"R8", "R9", "R10","R11",
	"R12","SP", "CC", "PC",
	"uR0", "uR1", "uR2", "uR3",
	"uR4", "uR5", "uR6", "uR7",
	"uR8", "uR9", "uR10", "uR11",
	"uR12", "uSP", "uCC", "uPC",
	"sR0", "sR1", "sR2", "sR3",
	"sR4", "sR5", "sR6", "sR7",
	"sR8", "sR9", "sR10","sR11",
	"sR12","sSP", "sCC", "sPC"
};
 
const	char	*zop_ccstr[] = {
	"", ".LT", ".Z", ".NZ", ".GT", ".GE", ".C", ".V"
};
 
const ZOPCODE	zoplist[] = {
	// Special case instructions.  These are general instructions, but with
	// special opcodes
	// Conditional branches
	//	0.1111.0111.ccc.0.111.10iiiii--
	//	0111 1011 11cc c011 110i iiii iiii iiii
	"BUSY", 0xffc7ffff, 0x7bc3dfff, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"BRA",  0xffffe000, 0x7bc3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BLT",  0xffffe000, 0x7bcbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BRZ",  0xffffe000, 0x7bd3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BNZ",  0xffffe000, 0x7bdbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BGE",  0xffffe000, 0x7be3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BGT",  0xffffe000, 0x7bebc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BRC",  0xffffe000, 0x7bf3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	"BRV",  0xffffe000, 0x7bfbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// CLRF ... an XOR w/ self instruction
	//	0.rrrr.00100.ccc.1.rrrr.iiiii---
	//	0rrr r001 00cc c1rr rr00 0000 0000 0000
	"CLRF",	0xffc7cfff, 0x01040000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x09044000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x11048000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x1904c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x21050000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x29054000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x31058000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x3905c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x41060000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x49064000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x51068000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x5906c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x61070000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x69074000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x71078000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	"CLRF",	0xffc7cfff, 0x7907c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// CLR -- a LDI of zero
	//	0.rrrr.1011.iiiiiii--
	//	0rrr r101 1...
	"CLR",  0x878fffff, 0x05800000, REGFIELD(27),OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	// HALT
	//	0.1110.00011.ccc.0.0000000000010
	//	0111.0000.11cc.c000.0000.0000.0000.0010
	"HALT",	0xffc7ffff, 0x70c00010, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// The "wait" instruction is identical, with the only difference being
	// the interrrupt context of the processor.  Well, almost.  To
	// facilitate waits from supervisor mode, the wait instruction
	// explicitly forces the CPU into user mode.
	"WAIT",	0xffc7ffff, 0x70c00030, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	//
	// "INT",	0xff10007f, 0x9e00005f, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// Return to user space
	"RTU",	0xffc7ffff, 0x70c00020, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// JMP (possibly a conditional jump, if not covered by branches above)
	// 0.1111.01111.ccc.a.rrrr.biiiiiiiiiiiiiiii
	// 0111.1011.11cc.c0rr.rrbi.iiii.iiii.iiii
	"JMP",  0xffc42000, 0x7bc00000, OPUNUSED,OPUNUSED, REGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
	"JMP",  0xffc42000, 0x7bc02000, OPUNUSED,OPUNUSED, URGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
	// 0.1111.1001.ii.iiii.iiii.iiii.iiii.iiii.iiii
	// 0111.1100.1iii.iiii.iiii.iiii.iiii.iiii
	"JMP",  0xff800000, 0x7c800000, REGFIELD(27),OPUNUSED, OPUNUSED, IMMFIELD(23,0), OPUNUSED,
	// 0.1111.00010.ccc0.iiiii.iiii.iiii.iiii.iiii
	// 0111.1000.10cc.c0ii.iiii.iiii.iiii.iiii
	"LJMP",	0xffc40000, 0x78800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	// 0.1111.10010.000.1.1111.000000000000000
	// 0111.1100.10cc.c111.11ii.iiii.iiii.iiii
	"FJMP",	0xffc7ffff, 0x7c87c000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// NOT : XOR w/ -1
	//	0.rrrr.00100.ccc.0111.11111111111
	//	0rrr.r001.00cc.c011.f.f.f.f
	"NOT",	0x87c7ffff, 0x0103ffff, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// General instructions
	// 0rrr.rooo.oocc.cxrr.rrii.iiii.iiii.iiii
	"SUB",	0x87c40000, 0x00000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"SUB",	0x87c40000, 0x00040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"AND",	0x87c40000, 0x00400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"AND",	0x87c40000, 0x00440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"ADD",	0x87c40000, 0x00800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"ADD",	0x87c40000, 0x00840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"OR",	0x87c40000, 0x00c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"OR",	0x87c40000, 0x00c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"XOR",	0x87c40000, 0x01000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"XOR",	0x87c40000, 0x01040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"LSR",	0x87c40000, 0x01400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"LSR",	0x87c40000, 0x01440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"LSL",	0x87c40000, 0x01800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"LSL",	0x87c40000, 0x01840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"ASR",	0x87c40000, 0x01c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"ASR",	0x87c40000, 0x01c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"LDIHI",0x87c40000, 0x02000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"LDIHI",0x87c40000, 0x02040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"LDILO",0x87c40000, 0x02400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"LDILO",0x87c40000, 0x02440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"MPYU",	0x87c40000, 0x02800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"MPYU",	0x87c40000, 0x02840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"MPYS",	0x87c40000, 0x02c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"MPYS",	0x87c40000, 0x02c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"BREV",	0x87c40000, 0x03000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"BREV",	0x87c40000, 0x03040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"POPC",	0x87c40000, 0x03400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"POPC",	0x87c40000, 0x03440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"ROL",	0x87c40000, 0x03800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"ROL",	0x87c40000, 0x03840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	// map bit = 1 (interrupts enabled) specifies user reg
	// 0rrr.rooo.oocc.cxrr.rrxi.iiii.iiii.iiii
	"MOV",  0x87c42000, 0x03c00000, REGFIELD(27),OPUNUSED, REGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
	"MOV",  0x87c42000, 0x03c40000, URGFIELD(27),OPUNUSED, REGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
	"MOV",  0x87c42000, 0x03c02000, REGFIELD(27),OPUNUSED, URGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
	"MOV",  0x87c42000, 0x03c42000, URGFIELD(27),OPUNUSED, URGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
	//
	"CMP",	0x87c40000, 0x04000000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"CMP",	0x87c40000, 0x04040000, OPUNUSED, REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	"TST",	0x87c40000, 0x04400000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"TST",	0x87c40000, 0x04440000, OPUNUSED, REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	// 0rrr.r101.1
	"LDI",  0x87800000, 0x05800000, REGFIELD(27),OPUNUSED, OPUNUSED, IMMFIELD(23,0), OPUNUSED,
	//
	"NOOP",  0xffffffff, 0x76000000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	"BRK",   0xffffffff, 0x76400000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	"LOCK",  0xffffffff, 0x76800000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	//
	//
	// LOD: 0rrr.r100.10cc.cxrr.rrii.iiii.iiii.iiii
	"LOD",	0x87c40000, 0x04800000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"LOD",	0x87c40000, 0x04840000, REGFIELD(27), OPUNUSED, REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	"STO",	0x87c40000, 0x04c00000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"STO",	0x87c40000, 0x04c40000, OPUNUSED, REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	// 0rrr.r101.1dcc.cxrr.rrii.iiii.iiii.iiii
	"DIVU",	0x87c40000, 0x05000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"DIVU",	0x87c40000, 0x05040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	"DIVS",	0x87c40000, 0x05400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"DIVS",	0x87c40000, 0x05440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	// 0rrr.r11f.ffcc.cxrr.rrii.iiii.iiii.iiii
	"FPADD",0x87c43fff, 0x06040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
	"FPSUB",0x87c43fff, 0x06440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
	"FPMPY",0x87c43fff, 0x06840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
	"FPDIV",0x87c43fff, 0x06c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
	"FPCVT",0x87c40000, 0x07000000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
	"FPCVT",0x87c40000, 0x07040000, REGFIELD(27), OPUNUSED, REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	"FPINT",0x87c40000, 0x07440000, REGFIELD(27), OPUNUSED, REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
	//
	//
	//
	//
	//
	//	16-bit instructions, high side
	//
	// LDI	1.rrrr.1001x.ccc.iiiii	-> 1rrr r100 1xcc ciii ii
	"CLR",  0x87c7c000, 0x84800000, REGFIELD(27),OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	// JMP	1.1111.01111.ccc.1rrrr	-> 1111 1011 11cc c1rr rr
	"JMP",  0xffc40000, 0xfbc40000, REGFIELD(27),OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	// XOR	1.rrrr.00100.ccc.01111	-> 1rrr r001 00cc c011 11
	"NOT",	0x87c7c000, 0x8103c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(2,19),
	// General instructions, top half
	// 1rrr.rooo.oocc.cxrr.rr
	"SUB",	0x87c40000, 0x80000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"SUB",	0x87c40000, 0x80040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"AND",	0x87c40000, 0x80400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"AND",	0x87c40000, 0x80440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"ADD",	0x87c40000, 0x80800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"ADD",	0x87c40000, 0x80840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"OR",	0x87c40000, 0x80c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"OR",	0x87c40000, 0x80c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"XOR",	0x87c40000, 0x81000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"XOR",	0x87c40000, 0x81040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"LSR",	0x87c40000, 0x81400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"LSR",	0x87c40000, 0x81440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"LSL",	0x87c40000, 0x81800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"LSL",	0x87c40000, 0x81840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"ASR",	0x87c40000, 0x81c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"ASR",	0x87c40000, 0x81c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"LDIHI",0x87c40000, 0x82000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(5,14), BITFIELD(2,19),
	"LDILO",0x87c40000, 0x82400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(5,14), BITFIELD(2,19),
	//
	"MPYU",	0x87c40000, 0x82800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"MPYU",	0x87c40000, 0x82840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"MPYS",	0x87c40000, 0x82c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"MPYS",	0x87c40000, 0x82c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"BREV",	0x87c40000, 0x83000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"BREV",	0x87c40000, 0x83040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"POPC",	0x87c40000, 0x83400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"POPC",	0x87c40000, 0x83440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"ROL",	0x87c40000, 0x83800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"ROL",	0x87c40000, 0x83840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"MOV",	0x87c40000, 0x83c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"CMP",	0x87c40000, 0x84000000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"CMP",	0x87c40000, 0x84040000, OPUNUSED, REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"TST",	0x87c40000, 0x84400000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"TST",	0x87c40000, 0x84440000, OPUNUSED, REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"LOD",	0x87c40000, 0x84840000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"STO",	0x87c40000, 0x84c40000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"DIVU",	0x87c40000, 0x85000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"DIVU",	0x87c40000, 0x85040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"DIVS",	0x87c40000, 0x85400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"DIVS",	0x87c40000, 0x85440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"LDI",	0x87c40000, 0x85800000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(5,14), BITFIELD(2,19),
	//
	"NOOP",	0xf7c00000, 0xf6000000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	//
	"BRK",	0xf7c00000, 0xf6400000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	//
	"LOCK",	0xf7c00000, 0xf6800000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	//
	//
	"FPADD",0x87c40000, 0x86040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"FPSUB",0x87c40000, 0x86440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"FPMUL",0x87c40000, 0x86840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"FPDIV",0x87c40000, 0x86c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"FPCVT",0x87c40000, 0x87000000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
	"FPCVT",0x87c40000, 0x87040000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	"FPINT",0x87c40000, 0x87440000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
	//
	//
	// Illegal instruction !!
	"ILL",	0x00000000, 0x00000000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(32,0), OPUNUSED
};
 
const ZOPCODE	zbottomlist[] = {
	//
	//
	//
	//	16-bit instructions, low side ... treat these as special
	//
	//
	// Special case instructions.  These are general instructions, but with
	// special opcodes
	// Conditional branches
	//	0.1111.0111.ccc.0.111.10iiiii--
	//	0111 1011 11cc c011 110i iiii iiii iiii
	// "BRA",  0xffffe000, 0x7bc3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BLT",  0xffffe000, 0x7bcbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BRZ",  0xffffe000, 0x7bd3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BNZ",  0xffffe000, 0x7bdbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BGE",  0xffffe000, 0x7be3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BGT",  0xffffe000, 0x7bebc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BRC",  0xffffe000, 0x7bf3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	// "BRV",  0xffffe000, 0x7bfbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
	//
	//
	// CLRF ... an XOR w/ self instruction
	//	0.rrrr.00100.ccc.1.rrrr.iiiii---
	//	0rrr r001 00cc c1rr rr00 0000 0000 0000
	// "CLRF",	0xffc7cfff, 0x7907c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
	// CLR -- a LDI of zero
	// LDI	1xxx.xxxx.xxxx.xxxx.xxrr.rroo.ooo.iiiii	-> 1rrr r100 1xcc ciii ii
	"CLR",  0x800003ff, 0x80000000, REGFIELD(12),OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	// JMP	1xxx -- xx11.1101.1111.rrrr
	"JMP",  0x80203ff0, 0x80003df0, REGFIELD(12),OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
	"JMP",  0x80203ff0, 0x80203df0, REGFIELD(12),OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	//
	// XOR	1xxx -- xx00.1000.1111	-> 1rrr r001 00cc c011 11
	"NOT",	0x802003ff, 0x80000080, REGFIELD(12), OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
	"NOT",	0x802003ff, 0x80200080, REGFIELD(12), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(2,19),
	// General instructions, bottom half
	// 1xxx -- xxrr.rroo.ooox.rrrr
	"SUB",	0x800003f0, 0x80000000, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"SUB",	0x802003f0, 0x80200000, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"SUB",	0x800003f0, 0x80000010, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"SUB",	0x802003f0, 0x80200010, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"AND",	0x800003f0, 0x80000020, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"AND",	0x802003f0, 0x80200020, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"AND",	0x800003f0, 0x80000030, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"AND",	0x802003f0, 0x80200030, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"ADD",	0x800003f0, 0x80000040, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"ADD",	0x802003f0, 0x80200040, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"ADD",	0x800003f0, 0x80000050, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"ADD",	0x802003f0, 0x80200050, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"OR",	0x800003f0, 0x80000060, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"OR",	0x802003f0, 0x80200060, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"OR",	0x800003f0, 0x80000070, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"OR",	0x802003f0, 0x80200070, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"XOR",	0x800003f0, 0x80000080, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"XOR",	0x802003f0, 0x80200080, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"XOR",	0x800003f0, 0x80000090, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"XOR",	0x802003f0, 0x80200090, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"LSR",	0x800003f0, 0x800000a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"LSR",	0x802003f0, 0x802000a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"LSR",	0x800003f0, 0x800000b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"LSR",	0x802003f0, 0x802000b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"LSL",	0x800003f0, 0x800000c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"LSL",	0x802003f0, 0x802000c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"LSL",	0x800003f0, 0x800000d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"LSL",	0x802003f0, 0x802000d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"ASR",	0x800003f0, 0x800000e0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"ASR",	0x802003f0, 0x802000e0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"ASR",	0x800003f0, 0x800000f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"ASR",	0x802003f0, 0x802000f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"LDIHI",0x800003e0, 0x80000100, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), BITFIELD(2,19),
	"LDIHI",0x802003e0, 0x80200100, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), OPUNUSED,
	//
	"LDILO",0x800003e0, 0x80000120, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), BITFIELD(2,19),
	"LDILO",0x802003e0, 0x80200120, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), OPUNUSED,
	//
	//
	"MPYU",	0x800003f0, 0x80000140, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"MPYU",	0x802003f0, 0x80200140, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"MPYU",	0x800003f0, 0x80000150, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"MPYU",	0x802003f0, 0x80200150, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"MPYS",	0x800003f0, 0x80000160, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"MPYS",	0x802003f0, 0x80200160, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"MPYS",	0x800003f0, 0x80000170, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"MPYS",	0x802003f0, 0x80200170, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"BREV",	0x800003f0, 0x80000180, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"BREV",	0x802003f0, 0x80200180, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"BREV",	0x800003f0, 0x80000190, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"BREV",	0x802003f0, 0x80200190, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"POPC",	0x800003f0, 0x800001a0, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"POPC",	0x802003f0, 0x802001a0, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"POPC",	0x800003f0, 0x800001b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"POPC",	0x802003f0, 0x802001b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"ROL",	0x800003f0, 0x800001c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"ROL",	0x802003f0, 0x802001c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"ROL",	0x800003f0, 0x800001d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"ROL",	0x802003f0, 0x802001d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"MOV",	0x800003f0, 0x800001f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"MOV",	0x802003f0, 0x802001f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"CMP",	0x800003f0, 0x80000200, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"CMP",	0x802003f0, 0x80200200, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"CMP",	0x800003f0, 0x80000210, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"CMP",	0x802003f0, 0x80200210, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"TST",	0x800003f0, 0x80000220, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"TST",	0x802003f0, 0x80200220, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"TST",	0x800003f0, 0x80000230, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"TST",	0x802003f0, 0x80200230, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"LOD",	0x800003f0, 0x80000250, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"LOD",	0x802003f0, 0x80200250, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"STO",	0x800003f0, 0x80000270, OPUNUSED, REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"STO",	0x802003f0, 0x80200270, OPUNUSED, REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"DIVU",	0x800003f0, 0x80000280, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"DIVU",	0x802003f0, 0x80200280, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"DIVU",	0x800003f0, 0x80000290, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"DIVU",	0x802003f0, 0x80200290, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"DIVS",	0x800003f0, 0x800002a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"DIVS",	0x802003f0, 0x802002a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"DIVS",	0x800003f0, 0x800002b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	"DIVS",	0x802003f0, 0x802002b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	//
	"LDI",	0x802003d0, 0x800002c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	//
	"NOOP",	0x80003bf0, 0x80003b00, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	//
	"BRK",	0x80003bf0, 0x80003b20, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	//
	"LOCK",	0x80003bf0, 0x80003b40, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	//
	// FPU instructions
	//
	"FPADD",0x802003f0, 0x80000310, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	"FPADD",0x802003f0, 0x80200310, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	//
	"FPSUB",0x802003f0, 0x80000330, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	"FPSUB",0x802003f0, 0x80200330, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	//
	"FPMUL",0x802003f0, 0x80000350, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	"FPMUL",0x802003f0, 0x80200350, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	//
	"FPDIV",0x802003f0, 0x80000370, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
	"FPDIV",0x802003f0, 0x80200370, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	// Convert to floating point
	"FPCVT",0x802003f0, 0x80000380, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), OPUNUSED,
	"FPCVT",0x802003f0, 0x80200380, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
	"FPCVT",0x802003f0, 0x80000390, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
	"FPCVT",0x802003f0, 0x80200390, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	// Convert to integer
	"FPINT",0x802003f0, 0x800003b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
	"FPINT",0x802003f0, 0x802003b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
	//
	//
	// Illegal instruction !!
	"ILL",	0x00000000, 0x00000000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(32,0), OPUNUSED
};
 
 
const int	nzoplist = (sizeof(zoplist)/sizeof(ZOPCODE));
const int	nzopbottom = (sizeof(zbottomlist)/sizeof(ZOPCODE));
 
static	int	getbits(const ZIPI ins, const int which) {
	if (which & 0x40000000) {
		// printf("SBITS: %08x, %08x = %08lx\n", ins, which,
			// sbits(ins>>(which & 0x03f), (which>>8)&0x03f));
		return sbits(ins>>(which & 0x03f), (which>>8)&0x03f);
	} else if (which &0x03f) {
		return ubits(ins>>(which & 0x03f), (which>>8)&0x03f)
			+ ((which>>16)&0x0ff);
	} else
		return which;
}
 
void	zipi_to_string(const ZIPI ins, char *line) {
	for(int i=0; i<nzoplist; i++) {
		if (((~zoplist[i].s_mask)&zoplist[i].s_val)!=0) {
			printf("Instruction %d, %s, fails consistency check\n",
				i, zoplist[i].s_opstr);
			assert(((~zoplist[i].s_mask)&zoplist[i].s_val)==0);
		}
	}
	for(int i=0; i<nzoplist; i++) {
		// printf("%2d: %6s %08x & %08x == %08x\n",
			// i, zoplist[i].s_opstr, ins,
			// zoplist[i].s_mask, zoplist[i].s_val);
		if ((ins & zoplist[i].s_mask) == zoplist[i].s_val) {
			sprintf(line, "  %s", zoplist[i].s_opstr);
			if (zoplist[i].s_cf != OPUNUSED) {
				int bv = getbits(ins, zoplist[i].s_cf);
				strcat(line, zop_ccstr[bv]);
			} sprintf(line, "%-13s", line);
 
			// Treat stores special
			if (strncasecmp("STO",zoplist[i].s_opstr, 3)==0) {
				int ra = getbits(ins, zoplist[i].s_ra);
				strcat(line, zop_regstr[ra]);
				strcat(line, ",");
 
				if (zoplist[i].s_i != OPUNUSED) {
					int	imv = 0;
					imv = getbits(ins, zoplist[i].s_i);
					if ((imv != 0)&&(zoplist[i].s_rb != OPUNUSED))
						sprintf(&line[strlen(line)],
							"$%d", imv);
					else if (imv != 0)
						sprintf(&line[strlen(line)],
							"($%d)", imv);
				} if (zoplist[i].s_rb != OPUNUSED) {
					int rb = getbits(ins, zoplist[i].s_rb);
					sprintf(&line[strlen(line)],
						"(%s)", zop_regstr[rb]);
				}
 
			} else {
				bool memop = (strncasecmp("LOD",
						zoplist[i].s_opstr, 3)==0);
				if (zoplist[i].s_i != OPUNUSED) {
					int	imv = 0;
					imv = getbits(ins, zoplist[i].s_i);
					if ((imv != 0)||(zoplist[i].s_rb == OPUNUSED))
						sprintf(&line[strlen(line)],
							"$%d%s", imv,
							((!memop)&&(zoplist[i].s_rb!=OPUNUSED))?"+":"");
				} if (zoplist[i].s_rb != OPUNUSED) {
					int rb = getbits(ins, zoplist[i].s_rb);
					if (memop)
						sprintf(&line[strlen(line)],
							"(%s)", zop_regstr[rb]);
					else
						strcat(line, zop_regstr[rb]);
				} if(((zoplist[i].s_i != OPUNUSED)||(zoplist[i].s_rb != OPUNUSED))
					&&((zoplist[i].s_ra != OPUNUSED)||(zoplist[i].s_result != OPUNUSED)))
					strcat(line, ",");
 
				if (zoplist[i].s_ra != OPUNUSED) {
					int ra = getbits(ins, zoplist[i].s_ra);
					strcat(line, zop_regstr[ra]);
				} else if (zoplist[i].s_result != OPUNUSED) {
					int ra = getbits(ins, zoplist[i].s_result);
					strcat(line, zop_regstr[ra]);
				}
 
			}
			break;
		}
	}
}
 
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.