Skip to content

Commit

Permalink
add IP, BS, SP as supported register pair parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Nov 6, 2023
1 parent 021818d commit 2b4f071
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
13 changes: 8 additions & 5 deletions source/assembler/assembler.d
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ class Assembler {

ubyte RegisterPairByte(string reg) {
switch (reg) {
case "ab": return 0;
case "cd": return 1;
case "ef": return 2;
case "ds": return 3;
case "sr": return 4;
case "ab": return RegPair.AB;
case "cd": return RegPair.CD;
case "ef": return RegPair.EF;
case "ds": return RegPair.DS;
case "sr": return RegPair.SR;
case "bs": return RegPair.BS;
case "ip": return RegPair.IP;
case "sp": return RegPair.SP;
default: assert(0);
}
}
Expand Down
17 changes: 14 additions & 3 deletions source/computer.d
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ enum RegPair {
EF = 2,
DS = 3,
SR = 4,
BS = 5
BS = 5,
IP = 6,
SP = 7
}

enum ErrorInterrupt {
Expand Down Expand Up @@ -139,6 +141,11 @@ class Computer {
// initialise display stuff
ram[0x000404] = 0x10; // 320x200 8bpp

// initialise interrupt table
for (uint i = 0x000004; i < 0x000404; ++ i) {
ram[i] = 0;
}

// initialise devices
import yeti16.devices.debugDevice;
import yeti16.devices.keyboard;
Expand Down Expand Up @@ -225,6 +232,8 @@ class Computer {
case RegPair.DS: ds = value; break;
case RegPair.SR: sr = value; break;
case RegPair.BS: bs = value; break;
case RegPair.IP: ip = value; break;
case RegPair.SP: sp = value; break;
default: Error(ErrorInterrupt.BadParam);
}
}
Expand All @@ -243,6 +252,8 @@ class Computer {
case RegPair.DS: return ds;
case RegPair.SR: return sr;
case RegPair.BS: return bs;
case RegPair.IP: return ip;
case RegPair.SP: return sp;
default: {
Error(ErrorInterrupt.BadParam);
return 0;
Expand Down Expand Up @@ -686,9 +697,9 @@ int ComputerCLI(string[] args) {
stderr.writeln("===============");
stderr.writefln(
"A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nF: %X\nDS: %X\nSR: %X\n" ~
"IP: %X\nSP: %X",
"IP: %X\nSP: %X\nBS: %X",
computer.a, computer.b, computer.c, computer.d, computer.e, computer.f,
computer.ds, computer.sr, computer.ip, computer.sp
computer.ds, computer.sr, computer.ip, computer.sp, computer.bs
);
writeln(e);
return 1;
Expand Down

0 comments on commit 2b4f071

Please sign in to comment.