File: run.cc

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (39 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//#define XERR
#include "cpu.ih"

size_t counter = 0;

int CPU::run()
{
    d_hdr.start();                  // at the first instruction to execute

    Opcodes::Byte opcode;
    do
    {
        uint32_t offset = d_hdr.offset();
        opcode = as<Opcodes::Byte>(d_hdr.get<uint8_t>());    // next opcode

        if (not Opcodes::valid(opcode))
            throw Exception{} << "At offset 0x" << setw(4) << offset << 
                        ": opcode 0x" << setw(2) << opcode << " not defined";

        xerr(ios::dec << ++counter << hex << ": at " << offset << \
            ": opcode " << opcode << " (" << Opcodes::mnemonic(opcode) << ')');

        (this->*s_execute[opcode])();
//        xerr("executed " << opcode);
    }
    while (opcode != Opcodes::Byte::exit);

    xerr("leaving");
    return d_reg.forcedInt();           // force an int-value
}