本文整理汇总了C++中CPU类的典型用法代码示例。如果您正苦于以下问题:C++ CPU类的具体用法?C++ CPU怎么用?C++ CPU使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPU类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main(){
char a;
FILE file;
FILE *fp = &file;
// 汇编生成目标代码
printf("生成目标代码\n");
Asm Asm("data.asm");
Asm.parse();
printf("line width offset\n");
fopen_s(&fp, "data.bin", "w");
Asm.write(fp);
fclose(fp);
printf("汇编结束\n");
// 虚拟机执行
printf("虚拟机执行\n");
CPU CPU;
CPU.init();
fopen_s(&fp, "data.bin", "r");
CPU.load(fp);
fclose(fp);
CPU.execute();
CPU.store();
printf("执行结束\n");
cin >> a;
}
示例2: CPU
static void *machine_thread(void *arg) {
CPU cpu = CPU();
while (cpu.is_running) {
cpu.Tick();
usleep(1);
}
print("CPU has finished work\n");
}
示例3: cmd_continue
void cmd_continue(CPU &cpu, stringstream &cmdstream) {
cout << "Continuing\n";
cpu.install_sigint();
do {
cpu.tick();
} while (find(breakpoints.begin(), breakpoints.end(), cpu.pc)
== breakpoints.end());
cpu.uninstall_sigint();
cpu.printState();
}
示例4: intToReg
void TestCpu::intToReg() {
CPU cpu;
QFETCH(int, value);
QFETCH(QString, result);
QString got = cpu.convertIntToReg(value);
QCOMPARE(got, result);
}
示例5: regToInt
void TestCpu::regToInt() {
CPU cpu;
QFETCH(QString, string);
QFETCH(int, result);
int got = cpu.convertRegToInt(string);
QCOMPARE(result, got);
}
示例6: main
int main(){
Memory m;
m.cylinderCount = {2,1,0,214};
CPU c;
//Valid track numbers for disk 1 are 0,1
assert(c.checkIfTrackIsInDisk(2,1)==false);
cout << '\n' << "cylinder 1: " << m.cylinderCount[0] << '\n';
assert(c.checkIfTrackIsInDisk(1,1)==true);
assert(c.checkIfTrackIsInDisk(0,1)==true);
//Only valid track is 0
assert(c.checkIfTrackIsInDisk(0,2)==true);
assert(c.checkIfTrackIsInDisk(1,2)==false);
assert(c.checkIfTrackIsInDisk(2,2)==false);
//No valid tracks
assert(c.checkIfTrackIsInDisk(0,3)==false);
//Tracks 0-213 are valid
assert(c.checkIfTrackIsInDisk(214,4)==false);
assert(c.checkIfTrackIsInDisk(213,4)==true);
assert(c.checkIfTrackIsInDisk(0,4)==true);
assert(c.checkIfTrackIsInDisk(1,4)==true);
assert(c.checkIfTrackIsInDisk(2,4)==true);
return 0;
}
示例7: CPU
void PartionedManualMPSimExecutor::createSimCPUScheduler(){
unsigned int nCPU = GUI_CONTEXT.getNCPU();
CPU *newCPU;
for(unsigned int i=0; i<nCPU; i++){
newCPU = new CPU();
newCPU->setIndex(i);
CPUs[i] = newCPU;
kernelCPUSchedulerMap[newCPU] = createScheduler(i);
}
}
示例8: main
int main()
{
CPU a(P6,3,300);
cout<<"cpu a's parameter"<<endl;
a.showinfo(); //显示性能参数
CPU b;
cout<<"cpu b's parameter"<<endl;
b.showinfo(); //显示性能参数
CPU c(a);
cout<<"cpu c's parameter"<<endl;
c.showinfo(); //显示性能参数
}
示例9: updateGraphics
void Video::updateGraphics(const int &cycles, CPU &cpuTemp)
{
setLCDStatus(cpuTemp);
if (isLCDEnabled())
_scanLineCounter -= cycles;
else
return;
if (_scanLineCounter <= 0)
{
// time to move onto next scanline
_memory->directModification(LY, _memory->read(LY) + 1);
BYTE currentline = _memory->read(LY);
_scanLineCounter = 456;
// we have entered vertical blank period
if (currentline == 144)
cpuTemp.requestInterrupt(VBlank);
// if gone past scanline 153 reset to 0
else if (currentline > 153)
_memory->directModification(LY, 0x00);
// draw the current scanline
else if (currentline < 144)
drawScanLine();
}
}
示例10: update_view
void update_view(CPU& cpu,
WINDOW *mem_win, WINDOW *a_win, WINDOW *x_win, WINDOW *y_win,
WINDOW *p_win, WINDOW *sp_win)
{
for (uint16_t i=0; i<=20; ++i) {
uint16_t pc = cpu.PC + i - 10;
uint8_t insVal = cpu.read_mem_val(pc);
Instruction ins = decode_instruction(insVal);
if (pc == cpu.PC) { wattron(mem_win, COLOR_PAIR(1)); }
mvwprintw(mem_win, i+1, 1, "%04x: %02x %s %-17s",
pc, insVal, optype_str[ins.type], addrmode_str[ins.mode]);
if (pc == cpu.PC) { wattroff(mem_win, COLOR_PAIR(1)); }
}
wrefresh(mem_win);
mvwprintw(a_win, 1, 1, "%02x", cpu.A);
wrefresh(a_win);
mvwprintw(x_win, 1, 1, "%02x", cpu.X);
wrefresh(x_win);
mvwprintw(y_win, 1, 1, "%02x", cpu.Y);
wrefresh(y_win);
mvwprintw(p_win, 1, 1, std::bitset<8>(cpu.P).to_string().c_str(), cpu.P);
mvwprintw(p_win, 2, 1, "NV-BDIZC");
wrefresh(p_win);
mvwprintw(sp_win, 1, 1, "%02x", cpu.SP);
wrefresh(sp_win);
}
示例11: AAA
AAA() : GenericInstruction(1, "aad", [](Machine& machine) {
CPU* cpu = machine.cpu;
Registers& regs = cpu->regs();
if ((regs.al() & 0x0F) > 9 || regs.flags().AF)
{
regs.ax() += 0x106;
regs.flags().AF = 1;
regs.flags().CF = 1;
}
else
{
regs.flags().AF = 0;
regs.flags().CF = 0;
}
regs.al() &= 0x0F;
})
{ }
示例12: Kickoff
void Kickoff()
{
bool wasActive = Clock::ActivatePIT();
// Start up all CPUs
size_t count = CPU::GetCPUCount();
for(size_t i = 0; i < count; i ++)
{
CPU *cpu = CPU::GetCPUWithID(i);
if(cpu->GetFlags() & CPU::Flags::Running)
continue;
KickoffCPU(cpu);
}
if(!wasActive)
Clock::DeactivatePIT();
}
示例13: CPU
CPU* uniformCPUFactory::createCPU(const string &name, int num_levels, double V[], int F[])
{
CPU *c;
if (_curr==_n)
if (num_levels==1)
// Creates a CPU without Power Saving:
c = new CPU(name);
else
// Creates a CPU with Power Saving:
c = new CPU(name, num_levels, V, F);
else
if (num_levels==1)
// Creates a CPU without Power Saving:
c = new CPU(_names[_curr++]);
else
// Creates a CPU with Power Saving:
c = new CPU(_names[_curr++], num_levels, V, F);
c->setIndex(index++);
return c;
}
示例14:
void Interface::start(void)
{
int key;
CPU cpu;
//Ram ram;
this->init_ncurse();
while ((key = this->getKey()) != ESCAPE)
{
if (this->_module & (0 << 1))
cpu.display(this->_y);
/*if (this->module & (1 << 1))
if (this->module & (2 << 1))
if (this->module & (3 << 1))
if (this->module & (4 << 1))
if (this->module & (5 << 1))*/
}
}
示例15: main
int main(int argc, char *argv[])
{
QueryPerformanceFrequency(&NFREQ);
#if CPU_TEST
cpu.load_rom("nestest.nes");
cpu.reset();
int clocks = 15000;
/*if (argc >= 2)
lines = atoi(argv[1]);*/
for (int i = 1; i <= clocks; ++i)
cpu.clock();
#else
SDLGraphicsSystem sdlGraphicsSystem;
IGraphicsSystem::SetSystem(&sdlGraphicsSystem);
char *romFileName = GetFilenameWin32();
if (!romFileName)
return 1;
cpu.load_rom(romFileName);
cpu.reset();
IGraphicsSystem *pSystem = IGraphicsSystem::GetSystem();
pSystem->SetDSPHandler(&DSPCallback);
pSystem->SetKeyHandler(&KeyHandler);
pSystem->Init(256 * 4, 240 * 4);
SDL_CreateThread(&EmulatorThread, NULL);
pSystem->RunSystem(&FrameUpdate);
#endif
return 0;
}