added new instructions and new test
This commit is contained in:
parent
d4754a048d
commit
6b3f4989ae
6 changed files with 142 additions and 38 deletions
|
|
@ -5,8 +5,16 @@
|
|||
|
||||
class Machine; // forward declaration
|
||||
|
||||
// Type 1 instruction handlers
|
||||
void fix_handler(Machine& m);
|
||||
void float_handler(Machine& m);
|
||||
void hio_handler(Machine& m);
|
||||
void norm_handler(Machine& m);
|
||||
void sio_handler(Machine& m);
|
||||
void tio_handler(Machine& m);
|
||||
|
||||
|
||||
/* IDEJE ZA SIC_XE_XE :)*/
|
||||
// void nop(Machine& m);
|
||||
|
||||
// Type 2 instruction handlers
|
||||
void addr_handler(Machine& m, int r1, int r2);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
#include "constants.h"
|
||||
#include "device.h"
|
||||
|
|
@ -23,6 +26,7 @@ using std::cout;
|
|||
class Machine {
|
||||
public:
|
||||
Machine();
|
||||
Machine(int speedkHz) : Machine() { this->speedkHz = speedkHz; }
|
||||
~Machine();
|
||||
|
||||
int getA() const { return A; }
|
||||
|
|
@ -74,7 +78,6 @@ public:
|
|||
// Set a file device at index `num` using the provided filename.
|
||||
void setFileDevice(int num, const std::string &filename);
|
||||
|
||||
|
||||
// Fetch and execute instructions
|
||||
int fetch();
|
||||
void execute();
|
||||
|
|
@ -83,6 +86,12 @@ public:
|
|||
bool execF2(int opcode, int operand);
|
||||
bool execSICF3F4(int opcode, int ni, int x, int b, int p, int e, int operand);
|
||||
|
||||
// Execution and speed control
|
||||
int getSpeed() const;
|
||||
void setSpeed(int kHz);
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
// error handling methods
|
||||
void notImplemented(string mnemonic);
|
||||
void invalidOpcode(int opcode);
|
||||
|
|
@ -102,6 +111,11 @@ private:
|
|||
std::vector<std::shared_ptr<Device>> devices;
|
||||
// fallback device returned when device slot is empty/invalid
|
||||
Device fallbackDevice;
|
||||
|
||||
// Execution control
|
||||
std::atomic<bool> running{false};
|
||||
std::atomic<int> speedkHz{1}; // Default 1 kHz
|
||||
void tick(); // simulate a clock tick
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue