468,765 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Test yourself for Performance

I use Intel C++ Compiler 8.1 for my Xeon Pentium III 550MHz machine. I
have executed six different tests for performance. GV stands for global
variable. GF stands for global function. SV stands for struct variable or
class variable. SF stands for struct member function or class member
function. JMP stands for switch (xx). CALL stands for pointer to function.
My output screen test shows that GV GF and SV GF have almost the same
speed. It is impossible to tell that GV GF is faster than SV GF or GV GF is
slower than SV GF, but the fact is that SV SF is always slower than GV GF
and/or SV GF.
If you want to concentrate on speed which it is very critical, then GV
GF or SV GF would be the best choice for game and/or general emulator.
I can tell that pointer to function is the best for speed than switch
(xx). I think that small functions are best for cache however switch (xx)
can make one function larger, and it cannot be in the cache. C/C++ Compiler
can only limit switch (xx) up to 32,768 lines (it depends...). Pointer to
function can be up to 5,000 or more, but it takes more memory.
Please feel free to take a look at my header code and source code below,
but you don't have to read it if you don't have to do so. You can copy and
paste them to your C++ Compiler. Compile to test your machine for Pentium
4. Please comment what you have gotten six tests for speed. It is fun for
curious.
Please look at my sample output screen for six tests. Please comment
your opinion what you think my code.

Bryan Parkoff

// Output Screen
Delay for one seconds
Done!

GV GF: JMP GV GF: CALL SV GF: JMP SV GF: CALL SV SF: JMP SV SF:
CALL
844.0 422.0 890.0 406.0 875.0 484.0
875.0 406.0 891.0 390.0 891.0 469.0
859.0 422.0 875.0 407.0 875.0 469.0
860.0 422.0 890.0 406.0 890.0 484.0
859.0 406.0 891.0 391.0 875.0 469.0
859.0 422.0 891.0 406.0 891.0 468.0
860.0 407.0 875.0 406.0 875.0 485.0
859.0 421.0 890.0 391.0 891.0 469.0
844.0 422.0 891.0 406.0 875.0 468.0
859.0 407.0 891.0 406.0 875.0 485.0

Average Time
857.8 415.7 887.5 401.5 881.3 475.0
Press any key to continue

// MAIN.H
#ifndef MAIN_H
#define MAIN_H

#include <stdio.h>
#include <time.h>

void sleep(clock_t wait);
void main(void);

extern unsigned __int8 g_A;
extern unsigned __int8 g_X;
extern unsigned __int8 g_Y;
extern unsigned __int8 g_O;
extern unsigned __int8 g_M;
extern unsigned __int8 g_N;
extern unsigned __int8 g_Z;
extern unsigned __int8* g_Mem;
extern unsigned __int16 g_PC;
extern unsigned __int32 g_Cycle;

void Initialize(void);
void Terminate(void);
void Run(void);
void Opcode1(void);
void Opcode2(void);
extern void (*pRun[0x100])(void);

struct CPU
{
unsigned __int8 A;
unsigned __int8 X;
unsigned __int8 Y;
unsigned __int8 O;
unsigned __int8 M;
unsigned __int8 N;
unsigned __int8 Z;
unsigned __int8* Mem;
unsigned __int16 PC;
unsigned __int32 Cycle;
};

extern CPU cpu;

void CPU_Initialize(void);
void CPU_Terminate(void);
void CPU_Run(void);
void CPU_Opcode1(void);
void CPU_Opcode2(void);
extern void (*CPU_pRun[0x100])(void);

struct CPU2
{
unsigned __int8 A;
unsigned __int8 X;
unsigned __int8 Y;
unsigned __int8 O;
unsigned __int8 M;
unsigned __int8 N;
unsigned __int8 Z;
unsigned __int8* Mem;
unsigned __int16 PC;
unsigned __int32 Cycle;

void Initialize(void);
void Terminate(void);
void Run(void);
void Opcode1(void);
void Opcode2(void);

typedef void (CPU2::*Action)();

static Action pRun[0x100];
inline void Run2(void);
};

extern CPU2 cpu2;

#endif

// Main.cpp
#include "Main.h"

unsigned __int8 g_A = 0;
unsigned __int8 g_X = 0;
unsigned __int8 g_Y = 0;
unsigned __int8 g_O = 0;
unsigned __int8 g_M = 0;
unsigned __int8 g_N = 0;
unsigned __int8 g_Z = 0;
unsigned __int8* g_Mem = 0;
unsigned __int16 g_PC = 0;
unsigned __int32 g_Cycle = 0;

void Initialize(void)
{
g_Mem = new unsigned __int8[0x10000];

unsigned __int32 loop, loop2;

for (loop2 = 0; loop2 < 85; ++loop2)
{
for (loop = 0; loop < 255; ++loop)
{
g_Mem[g_PC] = unsigned __int8(loop);
g_Mem[g_PC + 1] = 0x01;
g_Mem[g_PC + 2] = 0x20;
g_PC += 3;
}
}

for (loop = 0; loop < 169; ++loop)
{
g_Mem[g_PC] = unsigned __int8(loop);
g_Mem[g_PC + 1] = 0x01;
g_Mem[g_PC + 2] = 0x20;
g_PC += 3;
}

g_Mem[g_PC] = 0xFF;
g_Mem[g_PC + 1] = 0x00;
g_Mem[g_PC + 2] = 0x00;
g_Mem[g_PC + 3] = 0x00;
g_PC += 4;

g_O = g_Mem[g_PC];
g_PC++;

return;
}

void Terminate(void)
{
delete [] g_Mem;

return;
}

void Run(void)
{
switch (g_O)
{
case 0x00:
Opcode1();
return;

case 0x01:
Opcode1();
return;

case 0x02:
Opcode1();
return;

case 0x03:
Opcode1();
return;

case 0x04:
Opcode1();
return;

case 0x05:
Opcode1();
return;

case 0x06:
Opcode1();
return;

case 0x07:
Opcode1();
return;

case 0x08:
Opcode1();
return;

case 0x09:
Opcode1();
return;

case 0x0A:
Opcode1();
return;

case 0x0B:
Opcode1();
return;

case 0x0C:
Opcode1();
return;

case 0x0D:
Opcode1();
return;

case 0x0E:
Opcode1();
return;

case 0x0F:
Opcode1();
return;

case 0x10:
Opcode1();
return;

case 0x11:
Opcode1();
return;

case 0x12:
Opcode1();
return;

case 0x13:
Opcode1();
return;

case 0x14:
Opcode1();
return;

case 0x15:
Opcode1();
return;

case 0x16:
Opcode1();
return;

case 0x17:
Opcode1();
return;

case 0x18:
Opcode1();
return;

case 0x19:
Opcode1();
return;

case 0x1A:
Opcode1();
return;

case 0x1B:
Opcode1();
return;

case 0x1C:
Opcode1();
return;

case 0x1D:
Opcode1();
return;

case 0x1E:
Opcode1();
return;

case 0x1F:
Opcode1();
return;

case 0x20:
Opcode1();
return;

case 0x21:
Opcode1();
return;

case 0x22:
Opcode1();
return;

case 0x23:
Opcode1();
return;

case 0x24:
Opcode1();
return;

case 0x25:
Opcode1();
return;

case 0x26:
Opcode1();
return;

case 0x27:
Opcode1();
return;

case 0x28:
Opcode1();
return;

case 0x29:
Opcode1();
return;

case 0x2A:
Opcode1();
return;

case 0x2B:
Opcode1();
return;

case 0x2C:
Opcode1();
return;

case 0x2D:
Opcode1();
return;

case 0x2E:
Opcode1();
return;

case 0x2F:
Opcode1();
return;

case 0x30:
Opcode1();
return;

case 0x31:
Opcode1();
return;

case 0x32:
Opcode1();
return;

case 0x33:
Opcode1();
return;

case 0x34:
Opcode1();
return;

case 0x35:
Opcode1();
return;

case 0x36:
Opcode1();
return;

case 0x37:
Opcode1();
return;

case 0x38:
Opcode1();
return;

case 0x39:
Opcode1();
return;

case 0x3A:
Opcode1();
return;

case 0x3B:
Opcode1();
return;

case 0x3C:
Opcode1();
return;

case 0x3D:
Opcode1();
return;

case 0x3E:
Opcode1();
return;

case 0x3F:
Opcode1();
return;

case 0x40:
Opcode1();
return;

case 0x41:
Opcode1();
return;

case 0x42:
Opcode1();
return;

case 0x43:
Opcode1();
return;

case 0x44:
Opcode1();
return;

case 0x45:
Opcode1();
return;

case 0x46:
Opcode1();
return;

case 0x47:
Opcode1();
return;

case 0x48:
Opcode1();
return;

case 0x49:
Opcode1();
return;

case 0x4A:
Opcode1();
return;

case 0x4B:
Opcode1();
return;

case 0x4C:
Opcode1();
return;

case 0x4D:
Opcode1();
return;

case 0x4E:
Opcode1();
return;

case 0x4F:
Opcode1();
return;

case 0x50:
Opcode1();
return;

case 0x51:
Opcode1();
return;

case 0x52:
Opcode1();
return;

case 0x53:
Opcode1();
return;

case 0x54:
Opcode1();
return;

case 0x55:
Opcode1();
return;

case 0x56:
Opcode1();
return;

case 0x57:
Opcode1();
return;

case 0x58:
Opcode1();
return;

case 0x59:
Opcode1();
return;

case 0x5A:
Opcode1();
return;

case 0x5B:
Opcode1();
return;

case 0x5C:
Opcode1();
return;

case 0x5D:
Opcode1();
return;

case 0x5E:
Opcode1();
return;

case 0x5F:
Opcode1();
return;

case 0x60:
Opcode1();
return;

case 0x61:
Opcode1();
return;

case 0x62:
Opcode1();
return;

case 0x63:
Opcode1();
return;

case 0x64:
Opcode1();
return;

case 0x65:
Opcode1();
return;

case 0x66:
Opcode1();
return;

case 0x67:
Opcode1();
return;

case 0x68:
Opcode1();
return;

case 0x69:
Opcode1();
return;

case 0x6A:
Opcode1();
return;

case 0x6B:
Opcode1();
return;

case 0x6C:
Opcode1();
return;

case 0x6D:
Opcode1();
return;

case 0x6E:
Opcode1();
return;

case 0x6F:
Opcode1();
return;

case 0x70:
Opcode1();
return;

case 0x71:
Opcode1();
return;

case 0x72:
Opcode1();
return;

case 0x73:
Opcode1();
return;

case 0x74:
Opcode1();
return;

case 0x75:
Opcode1();
return;

case 0x76:
Opcode1();
return;

case 0x77:
Opcode1();
return;

case 0x78:
Opcode1();
return;

case 0x79:
Opcode1();
return;

case 0x7A:
Opcode1();
return;

case 0x7B:
Opcode1();
return;

case 0x7C:
Opcode1();
return;

case 0x7D:
Opcode1();
return;

case 0x7E:
Opcode1();
return;

case 0x7F:
Opcode1();
return;

case 0x80:
Opcode1();
return;

case 0x81:
Opcode1();
return;

case 0x82:
Opcode1();
return;

case 0x83:
Opcode1();
return;

case 0x84:
Opcode1();
return;

case 0x85:
Opcode1();
return;

case 0x86:
Opcode1();
return;

case 0x87:
Opcode1();
return;

case 0x88:
Opcode1();
return;

case 0x89:
Opcode1();
return;

case 0x8A:
Opcode1();
return;

case 0x8B:
Opcode1();
return;

case 0x8C:
Opcode1();
return;

case 0x8D:
Opcode1();
return;

case 0x8E:
Opcode1();
return;

case 0x8F:
Opcode1();
return;

case 0x90:
Opcode1();
return;

case 0x91:
Opcode1();
return;

case 0x92:
Opcode1();
return;

case 0x93:
Opcode1();
return;

case 0x94:
Opcode1();
return;

case 0x95:
Opcode1();
return;

case 0x96:
Opcode1();
return;

case 0x97:
Opcode1();
return;

case 0x98:
Opcode1();
return;

case 0x99:
Opcode1();
return;

case 0x9A:
Opcode1();
return;

case 0x9B:
Opcode1();
return;

case 0x9C:
Opcode1();
return;

case 0x9D:
Opcode1();
return;

case 0x9E:
Opcode1();
return;

case 0x9F:
Opcode1();
return;

case 0xA0:
Opcode1();
return;

case 0xA1:
Opcode1();
return;

case 0xA2:
Opcode1();
return;

case 0xA3:
Opcode1();
return;

case 0xA4:
Opcode1();
return;

case 0xA5:
Opcode1();
return;

case 0xA6:
Opcode1();
return;

case 0xA7:
Opcode1();
return;

case 0xA8:
Opcode1();
return;

case 0xA9:
Opcode1();
return;

case 0xAA:
Opcode1();
return;

case 0xAB:
Opcode1();
return;

case 0xAC:
Opcode1();
return;

case 0xAD:
Opcode1();
return;

case 0xAE:
Opcode1();
return;

case 0xAF:
Opcode1();
return;

case 0xB0:
Opcode1();
return;

case 0xB1:
Opcode1();
return;

case 0xB2:
Opcode1();
return;

case 0xB3:
Opcode1();
return;

case 0xB4:
Opcode1();
return;

case 0xB5:
Opcode1();
return;

case 0xB6:
Opcode1();
return;

case 0xB7:
Opcode1();
return;

case 0xB8:
Opcode1();
return;

case 0xB9:
Opcode1();
return;

case 0xBA:
Opcode1();
return;

case 0xBB:
Opcode1();
return;

case 0xBC:
Opcode1();
return;

case 0xBD:
Opcode1();
return;

case 0xBE:
Opcode1();
return;

case 0xBF:
Opcode1();
return;

case 0xC0:
Opcode1();
return;

case 0xC1:
Opcode1();
return;

case 0xC2:
Opcode1();
return;

case 0xC3:
Opcode1();
return;

case 0xC4:
Opcode1();
return;

case 0xC5:
Opcode1();
return;

case 0xC6:
Opcode1();
return;

case 0xC7:
Opcode1();
return;

case 0xC8:
Opcode1();
return;

case 0xC9:
Opcode1();
return;

case 0xCA:
Opcode1();
return;

case 0xCB:
Opcode1();
return;

case 0xCC:
Opcode1();
return;

case 0xCD:
Opcode1();
return;

case 0xCE:
Opcode1();
return;

case 0xCF:
Opcode1();
return;

case 0xD0:
Opcode1();
return;

case 0xD1:
Opcode1();
return;

case 0xD2:
Opcode1();
return;

case 0xD3:
Opcode1();
return;

case 0xD4:
Opcode1();
return;

case 0xD5:
Opcode1();
return;

case 0xD6:
Opcode1();
return;

case 0xD7:
Opcode1();
return;

case 0xD8:
Opcode1();
return;

case 0xD9:
Opcode1();
return;

case 0xDA:
Opcode1();
return;

case 0xDB:
Opcode1();
return;

case 0xDC:
Opcode1();
return;

case 0xDD:
Opcode1();
return;

case 0xDE:
Opcode1();
return;

case 0xDF:
Opcode1();
return;

case 0xE0:
Opcode1();
return;

case 0xE1:
Opcode1();
return;

case 0xE2:
Opcode1();
return;

case 0xE3:
Opcode1();
return;

case 0xE4:
Opcode1();
return;

case 0xE5:
Opcode1();
return;

case 0xE6:
Opcode1();
return;

case 0xE7:
Opcode1();
return;

case 0xE8:
Opcode1();
return;

case 0xE9:
Opcode1();
return;

case 0xEA:
Opcode1();
return;

case 0xEB:
Opcode1();
return;

case 0xEC:
Opcode1();
return;

case 0xED:
Opcode1();
return;

case 0xEE:
Opcode1();
return;

case 0xEF:
Opcode1();
return;

case 0xF0:
Opcode1();
return;

case 0xF1:
Opcode1();
return;

case 0xF2:
Opcode1();
return;

case 0xF3:
Opcode1();
return;

case 0xF4:
Opcode1();
return;

case 0xF5:
Opcode1();
return;

case 0xF6:
Opcode1();
return;

case 0xF7:
Opcode1();
return;

case 0xF8:
Opcode1();
return;

case 0xF9:
Opcode1();
return;

case 0xFA:
Opcode1();
return;

case 0xFB:
Opcode1();
return;

case 0xFC:
Opcode1();
return;

case 0xFD:
Opcode1();
return;

case 0xFE:
Opcode1();
return;

case 0xFF:
Opcode2();
return;

}
}

void Opcode1(void)
{
unsigned __int8 g_L = g_Mem[g_PC];
unsigned __int8 g_H = g_Mem[g_PC + 1];
g_A = g_Mem[(g_H << 8) | g_L];
g_N = unsigned __int8 (g_A & 0x80);
(g_A == 0x00) ? g_Z = 0x02 : g_Z = 0x00;
g_O = g_Mem[g_PC + 2];
g_PC += 3;
g_Cycle += 3;

return;
}

void Opcode2(void)
{
unsigned __int8 g_L = g_Mem[g_PC];
unsigned __int8 g_H = g_Mem[g_PC + 1];
g_PC = unsigned __int16 ((g_H << 8) | g_L);
g_O = g_Mem[g_PC];
g_PC++;
g_Cycle += 3;

return;
}

void (*pRun[0x100])(void) = { Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1, Opcode1,
Opcode2 };

CPU cpu;

void CPU_Initialize(void)
{
cpu.Mem = new unsigned __int8[0x10000];

unsigned __int32 loop, loop2;

for (loop2 = 0; loop2 < 85; ++loop2)
{
for (loop = 0; loop < 255; ++loop)
{
cpu.Mem[cpu.PC] = unsigned __int8(loop);
cpu.Mem[cpu.PC + 1] = 0x01;
cpu.Mem[cpu.PC + 2] = 0x20;
cpu.PC += 3;
}
}

for (loop = 0; loop < 169; ++loop)
{
cpu.Mem[cpu.PC] = unsigned __int8(loop);
cpu.Mem[cpu.PC + 1] = 0x01;
cpu.Mem[cpu.PC + 2] = 0x20;
cpu.PC += 3;
}

cpu.Mem[cpu.PC] = 0xFF;
cpu.Mem[cpu.PC + 1] = 0x00;
cpu.Mem[cpu.PC + 2] = 0x00;
cpu.Mem[cpu.PC + 3] = 0x00;
cpu.PC += 4;

cpu.O = cpu.Mem[cpu.PC];
cpu.PC++;

return;
}

void CPU_Terminate(void)
{
delete [] cpu.Mem;

return;
}

void CPU_Run(void)
{
switch (cpu.O)
{
case 0x00:
CPU_Opcode1();
return;

case 0x01:
CPU_Opcode1();
return;

case 0x02:
CPU_Opcode1();
return;

case 0x03:
CPU_Opcode1();
return;

case 0x04:
CPU_Opcode1();
return;

case 0x05:
CPU_Opcode1();
return;

case 0x06:
CPU_Opcode1();
return;

case 0x07:
CPU_Opcode1();
return;

case 0x08:
CPU_Opcode1();
return;

case 0x09:
CPU_Opcode1();
return;

case 0x0A:
CPU_Opcode1();
return;

case 0x0B:
CPU_Opcode1();
return;

case 0x0C:
CPU_Opcode1();
return;

case 0x0D:
CPU_Opcode1();
return;

case 0x0E:
CPU_Opcode1();
return;

case 0x0F:
CPU_Opcode1();
return;

case 0x10:
CPU_Opcode1();
return;

case 0x11:
CPU_Opcode1();
return;

case 0x12:
CPU_Opcode1();
return;

case 0x13:
CPU_Opcode1();
return;

case 0x14:
CPU_Opcode1();
return;

case 0x15:
CPU_Opcode1();
return;

case 0x16:
CPU_Opcode1();
return;

case 0x17:
CPU_Opcode1();
return;

case 0x18:
CPU_Opcode1();
return;

case 0x19:
CPU_Opcode1();
return;

case 0x1A:
CPU_Opcode1();
return;

case 0x1B:
CPU_Opcode1();
return;

case 0x1C:
CPU_Opcode1();
return;

case 0x1D:
CPU_Opcode1();
return;

case 0x1E:
CPU_Opcode1();
return;

case 0x1F:
CPU_Opcode1();
return;

case 0x20:
CPU_Opcode1();
return;

case 0x21:
CPU_Opcode1();
return;

case 0x22:
CPU_Opcode1();
return;

case 0x23:
CPU_Opcode1();
return;

case 0x24:
CPU_Opcode1();
return;

case 0x25:
CPU_Opcode1();
return;

case 0x26:
CPU_Opcode1();
return;

case 0x27:
CPU_Opcode1();
return;

case 0x28:
CPU_Opcode1();
return;

case 0x29:
CPU_Opcode1();
return;

case 0x2A:
CPU_Opcode1();
return;

case 0x2B:
CPU_Opcode1();
return;

case 0x2C:
CPU_Opcode1();
return;

case 0x2D:
CPU_Opcode1();
return;

case 0x2E:
CPU_Opcode1();
return;

case 0x2F:
CPU_Opcode1();
return;

case 0x30:
CPU_Opcode1();
return;

case 0x31:
CPU_Opcode1();
return;

case 0x32:
CPU_Opcode1();
return;

case 0x33:
CPU_Opcode1();
return;

case 0x34:
CPU_Opcode1();
return;

case 0x35:
CPU_Opcode1();
return;

case 0x36:
CPU_Opcode1();
return;

case 0x37:
CPU_Opcode1();
return;

case 0x38:
CPU_Opcode1();
return;

case 0x39:
CPU_Opcode1();
return;

case 0x3A:
CPU_Opcode1();
return;

case 0x3B:
CPU_Opcode1();
return;

case 0x3C:
CPU_Opcode1();
return;

case 0x3D:
CPU_Opcode1();
return;

case 0x3E:
CPU_Opcode1();
return;

case 0x3F:
CPU_Opcode1();
return;

case 0x40:
CPU_Opcode1();
return;

case 0x41:
CPU_Opcode1();
return;

case 0x42:
CPU_Opcode1();
return;

case 0x43:
CPU_Opcode1();
return;

case 0x44:
CPU_Opcode1();
return;

case 0x45:
CPU_Opcode1();
return;

case 0x46:
CPU_Opcode1();
return;

case 0x47:
CPU_Opcode1();
return;

case 0x48:
CPU_Opcode1();
return;

case 0x49:
CPU_Opcode1();
return;

case 0x4A:
CPU_Opcode1();
return;

case 0x4B:
CPU_Opcode1();
return;

case 0x4C:
CPU_Opcode1();
return;

case 0x4D:
CPU_Opcode1();
return;

case 0x4E:
CPU_Opcode1();
return;

case 0x4F:
CPU_Opcode1();
return;

case 0x50:
CPU_Opcode1();
return;

case 0x51:
CPU_Opcode1();
return;

case 0x52:
CPU_Opcode1();
return;

case 0x53:
CPU_Opcode1();
return;

case 0x54:
CPU_Opcode1();
return;

case 0x55:
CPU_Opcode1();
return;

case 0x56:
CPU_Opcode1();
return;

case 0x57:
CPU_Opcode1();
return;

case 0x58:
CPU_Opcode1();
return;

case 0x59:
CPU_Opcode1();
return;

case 0x5A:
CPU_Opcode1();
return;

case 0x5B:
CPU_Opcode1();
return;

case 0x5C:
CPU_Opcode1();
return;

case 0x5D:
CPU_Opcode1();
return;

case 0x5E:
CPU_Opcode1();
return;

case 0x5F:
CPU_Opcode1();
return;

case 0x60:
CPU_Opcode1();
return;

case 0x61:
CPU_Opcode1();
return;

case 0x62:
CPU_Opcode1();
return;

case 0x63:
CPU_Opcode1();
return;

case 0x64:
CPU_Opcode1();
return;

case 0x65:
CPU_Opcode1();
return;

case 0x66:
CPU_Opcode1();
return;

case 0x67:
CPU_Opcode1();
return;

case 0x68:
CPU_Opcode1();
return;

case 0x69:
CPU_Opcode1();
return;

case 0x6A:
CPU_Opcode1();
return;

case 0x6B:
CPU_Opcode1();
return;

case 0x6C:
CPU_Opcode1();
return;

case 0x6D:
CPU_Opcode1();
return;

case 0x6E:
CPU_Opcode1();
return;

case 0x6F:
CPU_Opcode1();
return;

case 0x70:
CPU_Opcode1();
return;

case 0x71:
CPU_Opcode1();
return;

case 0x72:
CPU_Opcode1();
return;

case 0x73:
CPU_Opcode1();
return;

case 0x74:
CPU_Opcode1();
return;

case 0x75:
CPU_Opcode1();
return;

case 0x76:
CPU_Opcode1();
return;

case 0x77:
CPU_Opcode1();
return;

case 0x78:
CPU_Opcode1();
return;

case 0x79:
CPU_Opcode1();
return;

case 0x7A:
CPU_Opcode1();
return;

case 0x7B:
CPU_Opcode1();
return;

case 0x7C:
CPU_Opcode1();
return;

case 0x7D:
CPU_Opcode1();
return;

case 0x7E:
CPU_Opcode1();
return;

case 0x7F:
CPU_Opcode1();
return;

case 0x80:
CPU_Opcode1();
return;

case 0x81:
CPU_Opcode1();
return;

case 0x82:
CPU_Opcode1();
return;

case 0x83:
CPU_Opcode1();
return;

case 0x84:
CPU_Opcode1();
return;

case 0x85:
CPU_Opcode1();
return;

case 0x86:
CPU_Opcode1();
return;

case 0x87:
CPU_Opcode1();
return;

case 0x88:
CPU_Opcode1();
return;

case 0x89:
CPU_Opcode1();
return;

case 0x8A:
CPU_Opcode1();
return;

case 0x8B:
CPU_Opcode1();
return;

case 0x8C:
CPU_Opcode1();
return;

case 0x8D:
CPU_Opcode1();
return;

case 0x8E:
CPU_Opcode1();
return;

case 0x8F:
CPU_Opcode1();
return;

case 0x90:
CPU_Opcode1();
return;

case 0x91:
CPU_Opcode1();
return;

case 0x92:
CPU_Opcode1();
return;

case 0x93:
CPU_Opcode1();
return;

case 0x94:
CPU_Opcode1();
return;

case 0x95:
CPU_Opcode1();
return;

case 0x96:
CPU_Opcode1();
return;

case 0x97:
CPU_Opcode1();
return;

case 0x98:
CPU_Opcode1();
return;

case 0x99:
CPU_Opcode1();
return;

case 0x9A:
CPU_Opcode1();
return;

case 0x9B:
CPU_Opcode1();
return;

case 0x9C:
CPU_Opcode1();
return;

case 0x9D:
CPU_Opcode1();
return;

case 0x9E:
CPU_Opcode1();
return;

case 0x9F:
CPU_Opcode1();
return;

case 0xA0:
CPU_Opcode1();
return;

case 0xA1:
CPU_Opcode1();
return;

case 0xA2:
CPU_Opcode1();
return;

case 0xA3:
CPU_Opcode1();
return;

case 0xA4:
CPU_Opcode1();
return;

case 0xA5:
CPU_Opcode1();
return;

case 0xA6:
CPU_Opcode1();
return;

case 0xA7:
CPU_Opcode1();
return;

case 0xA8:
CPU_Opcode1();
return;

case 0xA9:
CPU_Opcode1();
return;

case 0xAA:
CPU_Opcode1();
return;

case 0xAB:
CPU_Opcode1();
return;

case 0xAC:
CPU_Opcode1();
return;

case 0xAD:
CPU_Opcode1();
return;

case 0xAE:
CPU_Opcode1();
return;

case 0xAF:
CPU_Opcode1();
return;

case 0xB0:
CPU_Opcode1();
return;

case 0xB1:
CPU_Opcode1();
return;

case 0xB2:
CPU_Opcode1();
return;

case 0xB3:
CPU_Opcode1();
return;

case 0xB4:
CPU_Opcode1();
return;

case 0xB5:
CPU_Opcode1();
return;

case 0xB6:
CPU_Opcode1();
return;

case 0xB7:
CPU_Opcode1();
return;

case 0xB8:
CPU_Opcode1();
return;

case 0xB9:
CPU_Opcode1();
return;

case 0xBA:
CPU_Opcode1();
return;

case 0xBB:
CPU_Opcode1();
return;

case 0xBC:
CPU_Opcode1();
return;

case 0xBD:
CPU_Opcode1();
return;

case 0xBE:
CPU_Opcode1();
return;

case 0xBF:
CPU_Opcode1();
return;

case 0xC0:
CPU_Opcode1();
return;

case 0xC1:
CPU_Opcode1();
return;

case 0xC2:
CPU_Opcode1();
return;

case 0xC3:
CPU_Opcode1();
return;

case 0xC4:
CPU_Opcode1();
return;

case 0xC5:
CPU_Opcode1();
return;

case 0xC6:
CPU_Opcode1();
return;

case 0xC7:
CPU_Opcode1();
return;

case 0xC8:
CPU_Opcode1();
return;

case 0xC9:
CPU_Opcode1();
return;

case 0xCA:
CPU_Opcode1();
return;

case 0xCB:
CPU_Opcode1();
return;

case 0xCC:
CPU_Opcode1();
return;

case 0xCD:
CPU_Opcode1();
return;

case 0xCE:
CPU_Opcode1();
return;

case 0xCF:
CPU_Opcode1();
return;

case 0xD0:
CPU_Opcode1();
return;

case 0xD1:
CPU_Opcode1();
return;

case 0xD2:
CPU_Opcode1();
return;

case 0xD3:
CPU_Opcode1();
return;

case 0xD4:
CPU_Opcode1();
return;

case 0xD5:
CPU_Opcode1();
return;

case 0xD6:
CPU_Opcode1();
return;

case 0xD7:
CPU_Opcode1();
return;

case 0xD8:
CPU_Opcode1();
return;

case 0xD9:
CPU_Opcode1();
return;

case 0xDA:
CPU_Opcode1();
return;

case 0xDB:
CPU_Opcode1();
return;

case 0xDC:
CPU_Opcode1();
return;

case 0xDD:
CPU_Opcode1();
return;

case 0xDE:
CPU_Opcode1();
return;

case 0xDF:
CPU_Opcode1();
return;

case 0xE0:
CPU_Opcode1();
return;

case 0xE1:
CPU_Opcode1();
return;

case 0xE2:
CPU_Opcode1();
return;

case 0xE3:
CPU_Opcode1();
return;

case 0xE4:
CPU_Opcode1();
return;

case 0xE5:
CPU_Opcode1();
return;

case 0xE6:
CPU_Opcode1();
return;

case 0xE7:
CPU_Opcode1();
return;

case 0xE8:
CPU_Opcode1();
return;

case 0xE9:
CPU_Opcode1();
return;

case 0xEA:
CPU_Opcode1();
return;

case 0xEB:
CPU_Opcode1();
return;

case 0xEC:
CPU_Opcode1();
return;

case 0xED:
CPU_Opcode1();
return;

case 0xEE:
CPU_Opcode1();
return;

case 0xEF:
CPU_Opcode1();
return;

case 0xF0:
CPU_Opcode1();
return;

case 0xF1:
CPU_Opcode1();
return;

case 0xF2:
CPU_Opcode1();
return;

case 0xF3:
CPU_Opcode1();
return;

case 0xF4:
CPU_Opcode1();
return;

case 0xF5:
CPU_Opcode1();
return;

case 0xF6:
CPU_Opcode1();
return;

case 0xF7:
CPU_Opcode1();
return;

case 0xF8:
CPU_Opcode1();
return;

case 0xF9:
CPU_Opcode1();
return;

case 0xFA:
CPU_Opcode1();
return;

case 0xFB:
CPU_Opcode1();
return;

case 0xFC:
CPU_Opcode1();
return;

case 0xFD:
CPU_Opcode1();
return;

case 0xFE:
CPU_Opcode1();
return;

case 0xFF:
CPU_Opcode2();
return;

}
}

void CPU_Opcode1(void)
{
unsigned __int8 L = cpu.Mem[cpu.PC];
unsigned __int8 H = cpu.Mem[cpu.PC + 1];
cpu.A = cpu.Mem[(H << 8) | L];
cpu.N = unsigned __int8 (cpu.A & 0x80);
(cpu.A == 0x00) ? cpu.Z = 0x02 : cpu.Z = 0x00;
cpu.O = cpu.Mem[cpu.PC + 2];
cpu.PC += 3;
cpu.Cycle += 3;

return;
}

void CPU_Opcode2(void)
{
unsigned __int8 L = cpu.Mem[cpu.PC];
unsigned __int8 H = cpu.Mem[cpu.PC + 1];
cpu.PC = unsigned __int16 ((H << 8) | L);
cpu.O = cpu.Mem[cpu.PC];
cpu.PC++;
cpu.Cycle += 3;

return;
}

void (*CPU_pRun[0x100])(void) = { CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1, CPU_Opcode1,
CPU_Opcode2 };

CPU2 cpu2;

void CPU2::Initialize(void)
{
Mem = new unsigned __int8[0x10000];

unsigned __int32 loop, loop2;

for (loop2 = 0; loop2 < 85; ++loop2)
{
for (loop = 0; loop < 255; ++loop)
{
Mem[PC] = unsigned __int8(loop);
Mem[PC + 1] = 0x01;
Mem[PC + 2] = 0x20;
PC += 3;
}
}

for (loop = 0; loop < 169; ++loop)
{
Mem[PC] = unsigned __int8(loop);
Mem[PC + 1] = 0x01;
Mem[PC + 2] = 0x20;
PC += 3;
}

Mem[PC] = 0xFF;
Mem[PC + 1] = 0x00;
Mem[PC + 2] = 0x00;
Mem[PC + 3] = 0x00;
PC += 4;

O = Mem[PC];
PC++;

return;
}

void CPU2::Terminate(void)
{
delete [] Mem;

return;
}

void CPU2::Run(void)
{
switch (O)
{
case 0x00:
Opcode1();
return;

case 0x01:
Opcode1();
return;

case 0x02:
Opcode1();
return;

case 0x03:
Opcode1();
return;

case 0x04:
Opcode1();
return;

case 0x05:
Opcode1();
return;

case 0x06:
Opcode1();
return;

case 0x07:
Opcode1();
return;

case 0x08:
Opcode1();
return;

case 0x09:
Opcode1();
return;

case 0x0A:
Opcode1();
return;

case 0x0B:
Opcode1();
return;

case 0x0C:
Opcode1();
return;

case 0x0D:
Opcode1();
return;

case 0x0E:
Opcode1();
return;

case 0x0F:
Opcode1();
return;

case 0x10:
Opcode1();
return;

case 0x11:
Opcode1();
return;

case 0x12:
Opcode1();
return;

case 0x13:
Opcode1();
return;

case 0x14:
Opcode1();
return;

case 0x15:
Opcode1();
return;

case 0x16:
Opcode1();
return;

case 0x17:
Opcode1();
return;

case 0x18:
Opcode1();
return;

case 0x19:
Opcode1();
return;

case 0x1A:
Opcode1();
return;

case 0x1B:
Opcode1();
return;

case 0x1C:
Opcode1();
return;

case 0x1D:
Opcode1();
return;

case 0x1E:
Opcode1();
return;

case 0x1F:
Opcode1();
return;

case 0x20:
Opcode1();
return;

case 0x21:
Opcode1();
return;

case 0x22:
Opcode1();
return;

case 0x23:
Opcode1();
return;

case 0x24:
Opcode1();
return;

case 0x25:
Opcode1();
return;

case 0x26:
Opcode1();
return;

case 0x27:
Opcode1();
return;

case 0x28:
Opcode1();
return;

case 0x29:
Opcode1();
return;

case 0x2A:
Opcode1();
return;

case 0x2B:
Opcode1();
return;

case 0x2C:
Opcode1();
return;

case 0x2D:
Opcode1();
return;

case 0x2E:
Opcode1();
return;

case 0x2F:
Opcode1();
return;

case 0x30:
Opcode1();
return;

case 0x31:
Opcode1();
return;

case 0x32:
Opcode1();
return;

case 0x33:
Opcode1();
return;

case 0x34:
Opcode1();
return;

case 0x35:
Opcode1();
return;

case 0x36:
Opcode1();
return;

case 0x37:
Opcode1();
return;

case 0x38:
Opcode1();
return;

case 0x39:
Opcode1();
return;

case 0x3A:
Opcode1();
return;

case 0x3B:
Opcode1();
return;

case 0x3C:
Opcode1();
return;

case 0x3D:
Opcode1();
return;

case 0x3E:
Opcode1();
return;

case 0x3F:
Opcode1();
return;

case 0x40:
Opcode1();
return;

case 0x41:
Opcode1();
return;

case 0x42:
Opcode1();
return;

case 0x43:
Opcode1();
return;

case 0x44:
Opcode1();
return;

case 0x45:
Opcode1();
return;

case 0x46:
Opcode1();
return;

case 0x47:
Opcode1();
return;

case 0x48:
Opcode1();
return;

case 0x49:
Opcode1();
return;

case 0x4A:
Opcode1();
return;

case 0x4B:
Opcode1();
return;

case 0x4C:
Opcode1();
return;

case 0x4D:
Opcode1();
return;

case 0x4E:
Opcode1();
return;

case 0x4F:
Opcode1();
return;

case 0x50:
Opcode1();
return;

case 0x51:
Opcode1();
return;

case 0x52:
Opcode1();
return;

case 0x53:
Opcode1();
return;

case 0x54:
Opcode1();
return;

case 0x55:
Opcode1();
return;

case 0x56:
Opcode1();
return;

case 0x57:
Opcode1();
return;

case 0x58:
Opcode1();
return;

case 0x59:
Opcode1();
return;

case 0x5A:
Opcode1();
return;

case 0x5B:
Opcode1();
return;

case 0x5C:
Opcode1();
return;

case 0x5D:
Opcode1();
return;

case 0x5E:
Opcode1();
return;

case 0x5F:
Opcode1();
return;

case 0x60:
Opcode1();
return;

case 0x61:
Opcode1();
return;

case 0x62:
Opcode1();
return;

case 0x63:
Opcode1();
return;

case 0x64:
Opcode1();
return;

case 0x65:
Opcode1();
return;

case 0x66:
Opcode1();
return;

case 0x67:
Opcode1();
return;

case 0x68:
Opcode1();
return;

case 0x69:
Opcode1();
return;

case 0x6A:
Opcode1();
return;

case 0x6B:
Opcode1();
return;

case 0x6C:
Opcode1();
return;

case 0x6D:
Opcode1();
return;

case 0x6E:
Opcode1();
return;

case 0x6F:
Opcode1();
return;

case 0x70:
Opcode1();
return;

case 0x71:
Opcode1();
return;

case 0x72:
Opcode1();
return;

case 0x73:
Opcode1();
return;

case 0x74:
Opcode1();
return;

case 0x75:
Opcode1();
return;

case 0x76:
Opcode1();
return;

case 0x77:
Opcode1();
return;

case 0x78:
Opcode1();
return;

case 0x79:
Opcode1();
return;

case 0x7A:
Opcode1();
return;

case 0x7B:
Opcode1();
return;

case 0x7C:
Opcode1();
return;

case 0x7D:
Opcode1();
return;

case 0x7E:
Opcode1();
return;

case 0x7F:
Opcode1();
return;

case 0x80:
Opcode1();
return;

case 0x81:
Opcode1();
return;

case 0x82:
Opcode1();
return;

case 0x83:
Opcode1();
return;

case 0x84:
Opcode1();
return;

case 0x85:
Opcode1();
return;

case 0x86:
Opcode1();
return;

case 0x87:
Opcode1();
return;

case 0x88:
Opcode1();
return;

case 0x89:
Opcode1();
return;

case 0x8A:
Opcode1();
return;

case 0x8B:
Opcode1();
return;

case 0x8C:
Opcode1();
return;

case 0x8D:
Opcode1();
return;

case 0x8E:
Opcode1();
return;

case 0x8F:
Opcode1();
return;

case 0x90:
Opcode1();
return;

case 0x91:
Opcode1();
return;

case 0x92:
Opcode1();
return;

case 0x93:
Opcode1();
return;

case 0x94:
Opcode1();
return;

case 0x95:
Opcode1();
return;

case 0x96:
Opcode1();
return;

case 0x97:
Opcode1();
return;

case 0x98:
Opcode1();
return;

case 0x99:
Opcode1();
return;

case 0x9A:
Opcode1();
return;

case 0x9B:
Opcode1();
return;

case 0x9C:
Opcode1();
return;

case 0x9D:
Opcode1();
return;

case 0x9E:
Opcode1();
return;

case 0x9F:
Opcode1();
return;

case 0xA0:
Opcode1();
return;

case 0xA1:
Opcode1();
return;

case 0xA2:
Opcode1();
return;

case 0xA3:
Opcode1();
return;

case 0xA4:
Opcode1();
return;

case 0xA5:
Opcode1();
return;

case 0xA6:
Opcode1();
return;

case 0xA7:
Opcode1();
return;

case 0xA8:
Opcode1();
return;

case 0xA9:
Opcode1();
return;

case 0xAA:
Opcode1();
return;

case 0xAB:
Opcode1();
return;

case 0xAC:
Opcode1();
return;

case 0xAD:
Opcode1();
return;

case 0xAE:
Opcode1();
return;

case 0xAF:
Opcode1();
return;

case 0xB0:
Opcode1();
return;

case 0xB1:
Opcode1();
return;

case 0xB2:
Opcode1();
return;

case 0xB3:
Opcode1();
return;

case 0xB4:
Opcode1();
return;

case 0xB5:
Opcode1();
return;

case 0xB6:
Opcode1();
return;

case 0xB7:
Opcode1();
return;

case 0xB8:
Opcode1();
return;

case 0xB9:
Opcode1();
return;

case 0xBA:
Opcode1();
return;

case 0xBB:
Opcode1();
return;

case 0xBC:
Opcode1();
return;

case 0xBD:
Opcode1();
return;

case 0xBE:
Opcode1();
return;

case 0xBF:
Opcode1();
return;

case 0xC0:
Opcode1();
return;

case 0xC1:
Opcode1();
return;

case 0xC2:
Opcode1();
return;

case 0xC3:
Opcode1();
return;

case 0xC4:
Opcode1();
return;

case 0xC5:
Opcode1();
return;

case 0xC6:
Opcode1();
return;

case 0xC7:
Opcode1();
return;

case 0xC8:
Opcode1();
return;

case 0xC9:
Opcode1();
return;

case 0xCA:
Opcode1();
return;

case 0xCB:
Opcode1();
return;

case 0xCC:
Opcode1();
return;

case 0xCD:
Opcode1();
return;

case 0xCE:
Opcode1();
return;

case 0xCF:
Opcode1();
return;

case 0xD0:
Opcode1();
return;

case 0xD1:
Opcode1();
return;

case 0xD2:
Opcode1();
return;

case 0xD3:
Opcode1();
return;

case 0xD4:
Opcode1();
return;

case 0xD5:
Opcode1();
return;

case 0xD6:
Opcode1();
return;

case 0xD7:
Opcode1();
return;

case 0xD8:
Opcode1();
return;

case 0xD9:
Opcode1();
return;

case 0xDA:
Opcode1();
return;

case 0xDB:
Opcode1();
return;

case 0xDC:
Opcode1();
return;

case 0xDD:
Opcode1();
return;

case 0xDE:
Opcode1();
return;

case 0xDF:
Opcode1();
return;

case 0xE0:
Opcode1();
return;

case 0xE1:
Opcode1();
return;

case 0xE2:
Opcode1();
return;

case 0xE3:
Opcode1();
return;

case 0xE4:
Opcode1();
return;

case 0xE5:
Opcode1();
return;

case 0xE6:
Opcode1();
return;

case 0xE7:
Opcode1();
return;

case 0xE8:
Opcode1();
return;

case 0xE9:
Opcode1();
return;

case 0xEA:
Opcode1();
return;

case 0xEB:
Opcode1();
return;

case 0xEC:
Opcode1();
return;

case 0xED:
Opcode1();
return;

case 0xEE:
Opcode1();
return;

case 0xEF:
Opcode1();
return;

case 0xF0:
Opcode1();
return;

case 0xF1:
Opcode1();
return;

case 0xF2:
Opcode1();
return;

case 0xF3:
Opcode1();
return;

case 0xF4:
Opcode1();
return;

case 0xF5:
Opcode1();
return;

case 0xF6:
Opcode1();
return;

case 0xF7:
Opcode1();
return;

case 0xF8:
Opcode1();
return;

case 0xF9:
Opcode1();
return;

case 0xFA:
Opcode1();
return;

case 0xFB:
Opcode1();
return;

case 0xFC:
Opcode1();
return;

case 0xFD:
Opcode1();
return;

case 0xFE:
Opcode1();
return;

case 0xFF:
Opcode2();
return;

}
}

void CPU2::Opcode1(void)
{
unsigned __int8 L = Mem[PC];
unsigned __int8 H = Mem[PC + 1];
A = Mem[(H << 8) | L];
N = unsigned __int8 (A & 0x80);
(A == 0x00) ? Z = 0x02 : Z = 0x00;
O = Mem[PC + 2];
PC += 3;
Cycle += 3;

return;
}

void CPU2::Opcode2(void)
{
unsigned __int8 L = Mem[PC];
unsigned __int8 H = Mem[PC + 1];
PC = unsigned __int16 ((H << 8) | L);
O = Mem[PC];
PC++;
Cycle += 3;

return;
}

CPU2::Action CPU2::pRun[0x100] = { &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1,
&CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode1, &CPU2::Opcode2 };

void CPU2::Run2(void)
{
(this->*pRun[O])();

return;
}
void sleep(clock_t wait)
{
clock_t goal;
goal = wait + clock();
while(goal > clock());

return;
}

void main(void)
{
unsigned int loop, loop2;
clock_t start[6][10], finish[6][10];
double duration[6][10], avg[6];

avg[0] = 0;
avg[1] = 0;
avg[2] = 0;
avg[3] = 0;
avg[4] = 0;
avg[5] = 0;

printf( "Delay for one seconds\n" );
sleep( (clock_t)1 * CLOCKS_PER_SEC );
printf( "Done!\n\n" );

Initialize();
CPU_Initialize();
cpu2.Initialize();

printf("GV GF: JMP GV GF: CALL SV GF: JMP SV GF: CALL SV SF: JMP
SV SF: CALL\n");

for (loop2 = 0; loop2 < 10; ++loop2)
{
start[0][loop2] = clock();

for(loop = 0; loop < 10000000; ++loop)
{
Run();
}

finish[0][loop2] = clock();

duration[0][loop2] = (double)(finish[0][loop2] - start[0][loop2]);
}

for (loop2 = 0; loop2 < 10; ++loop2)
{
start[1][loop2] = clock();

for(loop = 0; loop < 10000000; ++loop)
{
pRun[g_O]();
}

finish[1][loop2] = clock();

duration[1][loop2] = (double)(finish[1][loop2] - start[1][loop2]);
}

for (loop2 = 0; loop2 < 10; ++loop2)
{
start[2][loop2] = clock();

for(loop = 0; loop < 10000000; ++loop)
{
CPU_Run();
}

finish[2][loop2] = clock();

duration[2][loop2] = (double)(finish[2][loop2] - start[2][loop2]);
}

for (loop2 = 0; loop2 < 10; ++loop2)
{
start[3][loop2] = clock();

for(loop = 0; loop < 10000000; ++loop)
{
CPU_pRun[cpu.O]();
}

finish[3][loop2] = clock();

duration[3][loop2] = (double)(finish[3][loop2] - start[3][loop2]);
}

for (loop2 = 0; loop2 < 10; ++loop2)
{
start[4][loop2] = clock();

for(loop = 0; loop < 10000000; ++loop)
{
cpu2.Run();
}

finish[4][loop2] = clock();

duration[4][loop2] = (double)(finish[4][loop2] - start[4][loop2]);
}

for (loop2 = 0; loop2 < 10; ++loop2)
{
start[5][loop2] = clock();

for(loop = 0; loop < 10000000; ++loop)
{
cpu2.Run2();
}

finish[5][loop2] = clock();

duration[5][loop2] = (double)(finish[5][loop2] - start[5][loop2]);
}

for (loop2 = 0; loop2 < 6; ++loop2)
{
for (loop = 0; loop < 10; ++loop)
{
avg[loop2] += duration[loop2][loop];
}
avg[loop2] /= 10;
}

for (loop = 0; loop < 10; ++loop)
printf("%2.1f %2.1f %2.1f %2.1f %2.1f
%2.1f\n", duration[0][loop], duration[1][loop], duration[2][loop],
duration[3][loop], duration[4][loop], duration[5][loop] /* / CLOCKS_PER_SEC
*/);

printf("\nAverage Time\n");
printf("%2.1f %2.1f %2.1f %2.1f %2.1f
%2.1f\n", avg[0], avg[1], avg[2], avg[3], avg[4], avg[5] /* / CLOCKS_PER_SEC
*/);

Terminate();
CPU_Terminate();
cpu2.Terminate();

return;
}
Jul 23 '05 #1
0 1095

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by dave | last post: by
9 posts views Thread by Steve Sargent | last post: by
3 posts views Thread by Alexis | last post: by
5 posts views Thread by Hasin Hayder | last post: by
6 posts views Thread by Vyacheslav Maslov | last post: by
reply views Thread by H - Recruiter - Testing | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.