home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- // $Id: decode.cxx,v 1.1 1994/02/18 20:04:02 bmott Exp $
- ///////////////////////////////////////////////////////////////////////////////
- // decode.hxx
- //
- // The Motorola 68000 instruction decoding stuff
- //
- // Sim68000 "Motorola 68000 Simulator"
- // Copyright (c) 1993
- // By: Bradford W. Mott
- // November 3,1993
- //
- ///////////////////////////////////////////////////////////////////////////////
- // $Log: decode.cxx,v $
- // Revision 1.1 1994/02/18 20:04:02 bmott
- // Initial revision
- //
- ///////////////////////////////////////////////////////////////////////////////
-
- #include "m68000.hxx"
- #include <iostream.h>
-
- DecodeEntry m68000::decode_table[] = {
- #include "m68000DecodeTable.hxx" // Built from instruction.list file
- };
-
- ExecutionPointer *m68000::decode_cache_table = (void*)0;
-
- ///////////////////////////////////////////////////////////////////////////////
- // Decode the given opcode
- ///////////////////////////////////////////////////////////////////////////////
- ExecutionPointer m68000::DecodeInstruction(int opcode)
- {
- // Check to see if this opcode needs to be decoded
- if(decode_cache_table[opcode] == (void*)0)
- {
- // Decode the opcode using a linear search (slow :-{ )
- for(int s=0;s<(sizeof(decode_table)/sizeof(DecodeEntry));++s)
- {
- if ( (opcode & decode_table[s].mask) == decode_table[s].signature )
- {
- decode_cache_table[opcode]=decode_table[s].execute;
- }
- }
-
- // If not found then it's an invalid instruction
- if(decode_cache_table[opcode] == (void*)0)
- decode_cache_table[opcode]=&m68000::ExecuteInvalid;
- }
-
- return(decode_cache_table[opcode]);
- }
-