implemented timer, opcode decoding

This commit is contained in:
privsk 2025-12-03 10:13:58 +01:00
parent 5a06b2bc0b
commit 76b2c711ef
2 changed files with 384 additions and 1 deletions

View file

@ -2,6 +2,8 @@
#define MACHINE_H
#include <cstdint>
#include <thread>
#include <atomic>
#include "Device.h"
@ -24,6 +26,11 @@ class Machine {
int PC; // Program Counter (24-bit)
int SW; // Status Word (24-bit)
// timer simulation
std::atomic<bool> running;
std::thread* timerThread;
int speed; // kHz
public:
Machine();
~Machine();
@ -62,12 +69,31 @@ class Machine {
int getByte(int addr) const;
void setByte(int addr, int val);
int getWord(int addr) const;
void setWord(int addr, int val);
Device* getDevice(int num) const;
void setDevice(int num, Device* device);
// error handling
void notImplemented(const char* mnemonic);
void invalidOpcode(int opcode);
void invalidAddressing();
// execution
int fetch();
void execute();
bool execF1(int opcode);
bool execF2(int opcode, int operand);
bool execSICF3F4(int opcode, int ni, int operand);
// timer simulation
void start();
void stop();
bool isRunning() const;
int getSpeed() const;
void setSpeed(int kHz);
};
#endif // MACHINE_H