ndfsak
This commit is contained in:
MallocNull 2015-01-29 14:10:02 -06:00
parent a9d85f7d60
commit f6ba8ad878
18 changed files with 276 additions and 31 deletions

View file

@ -116,10 +116,49 @@ var Word = (function () {
//return new Word(overflow[0].Get() + this.value[0].Add(overflow[1]).Get()); //return new Word(overflow[0].Get() + this.value[0].Add(overflow[1]).Get());
}; };
Word.prototype.AddByte = function (value) { Word.prototype.Sub = function (value) {
value = typeof value != "number" ? value.Get() : value; value = typeof value == "number" ? new Word(value) : value;
return this.Add(value.Neg());
};
Word.prototype.AddByte = function (value, signed) {
if (typeof signed === "undefined") { signed = false; }
value = typeof value != "number" ? new Word((value.Test(7) && signed ? 0xFF00 : 0x0000) | value.Get()) : new Word(value);
return this.Add(value); return this.Add(value);
}; };
Word.prototype.SubByte = function (value) {
value = typeof value != "number" ? new Byte(value) : value;
return this.AddByte(value.Neg(), true);
};
Word.prototype.Not = function () {
this.value[0].Not();
this.value[1].Not();
};
Word.prototype.And = function (value) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].And(value.High());
this.value[1].And(value.Low());
};
Word.prototype.Or = function (value) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Or(value.High());
this.value[1].Or(value.Low());
};
Word.prototype.Xor = function (value) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Xor(value.High());
this.value[1].Xor(value.Low());
};
Word.prototype.Neg = function () {
this.Not();
this.Add(1);
};
return Word; return Word;
})(); })();
//# sourceMappingURL=Byte.js.map //# sourceMappingURL=Byte.js.map

File diff suppressed because one or more lines are too long

View file

@ -137,10 +137,58 @@ class Word {
//return new Word(overflow[0].Get() + this.value[0].Add(overflow[1]).Get()); //return new Word(overflow[0].Get() + this.value[0].Add(overflow[1]).Get());
} }
public AddByte(value: number): Word; public Sub(value: number): Word;
public AddByte(value: Byte): Word; public Sub(value: Word): Word;
public AddByte(value: any): Word { public Sub(value: any): Word {
value = typeof value != "number" ? value.Get() : value; value = typeof value == "number" ? new Word(value) : value;
return this.Add(value.Neg());
}
public AddByte(value: number, signed: boolean): Word;
public AddByte(value: Byte, signed: boolean): Word;
public AddByte(value: any, signed: boolean = false): Word {
value = typeof value != "number" ? new Word((value.Test(7) && signed ? 0xFF00 : 0x0000) | value.Get()) : new Word(value);
return this.Add(value); return this.Add(value);
} }
public SubByte(value: number): Word;
public SubByte(value: Byte): Word;
public SubByte(value: any): Word {
value = typeof value != "number" ? new Byte(value) : value;
return this.AddByte(value.Neg(), true);
}
public Not() {
this.value[0].Not();
this.value[1].Not();
}
public And(value: number);
public And(value: Word);
public And(value: any) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].And(value.High());
this.value[1].And(value.Low());
}
public Or(value: number);
public Or(value: Word);
public Or(value: any) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Or(value.High());
this.value[1].Or(value.Low());
}
public Xor(value: number);
public Xor(value: Word);
public Xor(value: any) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Xor(value.High());
this.value[1].Xor(value.Low());
}
public Neg() {
this.Not();
this.Add(1);
}
} }

View file

@ -60,7 +60,9 @@ var Registers = (function () {
} }
}; };
Registers.Exchange = function (a, b) { Registers.SetRegisterPair = function (pair, value) {
Registers.byteRegisters[pair[0]] = value.High();
Registers.byteRegisters[pair[1]] = value.Low();
}; };
Registers.byteRegisters = []; Registers.byteRegisters = [];
Registers.shadowRegisters = []; Registers.shadowRegisters = [];

View file

@ -1 +1 @@
{"version":3,"file":"Registers.js","sourceRoot":"","sources":["Registers.ts"],"names":["Flags","Registers","Registers.constructor","Registers.Init","Registers.GenerateWord","Registers.SetFlag","Registers.GetFlag","Registers.ExchangeAFShadow","Registers.ExchangeShadow","Registers.Exchange"],"mappings":"AAAA,gCAAgC;AAEhC,IAAK,KAAK;AAA8D,CAAxE,UAAK,KAAK;IAAGA,mCAAKA;IAAEA,qCAAMA;IAAEA,qCAAMA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,iCA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,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,CAACA;YAClDA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA;SACpDA;IACLA,CAACA;;IAEDP,qBAAAA,UAAuBA,CAASA,EAAEA,CAASA;IAE3CQ,CAACA;IArDDR,0BAAsCA,EAAEA;IACxCA,4BAAwCA,EAAEA;IAC1CA,2BAAqCA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IAChDA,yBAAmCA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IAmDlDA,iBAACA;AAADA,CAACA,IAAA"} {"version":3,"file":"Registers.js","sourceRoot":"","sources":["Registers.ts"],"names":["Flags","Registers","Registers.constructor","Registers.Init","Registers.GenerateWord","Registers.SetFlag","Registers.GetFlag","Registers.ExchangeAFShadow","Registers.ExchangeShadow","Registers.SetRegisterPair"],"mappings":"AAAA,gCAAgC;AAEhC,IAAK,KAAK;AAA8D,CAAxE,UAAK,KAAK;IAAGA,mCAAKA;IAAEA,qCAAMA;IAAEA,qCAAMA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,iCAAIA;0BAAE;;AAExE;IAAAC;IAwDAC,CAACA;AAAAD,IAlDGA,iBAAAA;QACIE,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC5CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC5CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC5CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,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eAAeA,CAACA,IAAIA,CAACA;QACzCA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,EAAEA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA;QAC/FA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,CAACA;QACzCA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IAC5CA,CAACA;;IAEDN,2BAAAA;QACIO,IAAIA,IAAIA,GAAGA,CAACA,IAAIA,EAAEA,IAAIA,EAAEA,IAAIA,CAACA;QAC7BA,KAAIA,IAAIA,GAAGA,IAAIA,IAAIA,CAAEA;YACjBA,IAAIA,GAAGA,GAAGA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA;YAC9CA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,CAACA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,EAAEA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;YACtHA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,CAACA;YAClDA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA;SACpDA;IACLA,CAACA;;IAEDP,4BAAAA,UAA8BA,IAAYA,EAAEA,KAAWA;QACnDQ,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,KAAKA,CAACA,IAAIA,CAACA,CAACA;QAC/CA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,KAAKA,CAACA,GAAGA,CAACA,CAACA;IAClDA,CAACA;IAtDDR,0BAAsCA,EAAEA;IACxCA,4BAAwCA,EAAEA;IAC1CA,2BAAqCA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IAChDA,yBAAmCA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IAoDlDA,iBAACA;AAADA,CAACA,IAAA"}

View file

@ -54,7 +54,8 @@ class Registers {
} }
} }
public static Exchange(a: string, b: string) { public static SetRegisterPair(pair: string, value: Word) {
Registers.byteRegisters[pair[0]] = value.High();
Registers.byteRegisters[pair[1]] = value.Low();
} }
} }

View file

@ -12,7 +12,9 @@ var TI = (function () {
}; };
TI.Init = function () { TI.Init = function () {
Registers.Init();
LCD.Init(); LCD.Init();
Memory.Init();
var a = new Byte(0xF0); var a = new Byte(0xF0);
var b = new Byte(10); var b = new Byte(10);

View file

@ -1 +1 @@
{"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.PerformOperation","TI.Init"],"mappings":"AAAA,gCAAgC;AAChC,+BAA+B;AAC/B,kCAAkC;AAClC,qCAAqC;AACrC,mCAAmC;;AAUnC;IAAAA;IAgBAC,CAACA;AAAAD,IAbGA,sBAAAA,UAAwBA,IAAYA;QAChCE,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA;IACrCA,CAACA;;IAEDF,UAAAA;QACIG,GAAGA,CAACA,IAAIA,CAACA,CAACA;QACVA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,CAACA;QACtBA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA;;QACpBA,WAAWA;QACXA,iBAAiBA;QACjBA,CAACA,CAACA,SAASA,CAACA,IAAIA,CAACA;QACjBA,iBAAiBA;IACrBA,CAACA;IAdDH,aAAkCA,EAAEA;IAexCA,UAACA;AAADA,CAACA,IAAA"} {"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.PerformOperation","TI.Init"],"mappings":"AAAA,gCAAgC;AAChC,+BAA+B;AAC/B,kCAAkC;AAClC,qCAAqC;AACrC,mCAAmC;;AAUnC;IAAAA;IAkBAC,CAACA;AAAAD,IAfGA,sBAAAA,UAAwBA,IAAYA;QAChCE,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA;IACrCA,CAACA;;IAEDF,UAAAA;QACIG,SAASA,CAACA,IAAIA,CAACA,CAACA;QAChBA,GAAGA,CAACA,IAAIA,CAACA,CAACA;QACVA,MAAMA,CAACA,IAAIA,CAACA,CAACA;QACbA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,CAACA;QACtBA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA;;QACpBA,WAAWA;QACXA,iBAAiBA;QACjBA,CAACA,CAACA,SAASA,CAACA,IAAIA,CAACA;QACjBA,iBAAiBA;IACrBA,CAACA;IAhBDH,aAAkCA,EAAEA;IAiBxCA,UAACA;AAADA,CAACA,IAAA"}

View file

@ -20,7 +20,9 @@ class TI {
} }
static Init() { static Init() {
Registers.Init();
LCD.Init(); LCD.Init();
Memory.Init();
var a = new Byte(0xF0); var a = new Byte(0xF0);
var b = new Byte(10); var b = new Byte(10);
//a.Sub(b); //a.Sub(b);

View file

@ -8,8 +8,7 @@ TI.Opcodes[0x00] = function (args) {
}; };
TI.Opcodes[0x01] = function (args) { TI.Opcodes[0x01] = function (args) {
Registers.byteRegisters["B"] = args[2]; Registers.SetRegisterPair("BC", new Word(args[2], args[1]));
Registers.byteRegisters["C"] = args[1];
return [3, 10]; return [3, 10];
}; };
@ -19,8 +18,10 @@ TI.Opcodes[0x02] = function (args) {
}; };
TI.Opcodes[0x03] = function (args) { TI.Opcodes[0x03] = function (args) {
// inc bc var tmp = Registers.GenerateWord("B", "C");
return [1, 4]; tmp.Add(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
}; };
TI.Opcodes[0x04] = function (args) { TI.Opcodes[0x04] = function (args) {
@ -57,7 +58,13 @@ TI.Opcodes[0x08] = function (args) {
}; };
TI.Opcodes[0x09] = function (args) { TI.Opcodes[0x09] = function (args) {
// add hl, bc var tmp = [Registers.GenerateWord("H", "L"), Registers.GenerateWord("B", "C")];
var overflow = tmp[0].Add(tmp[1]);
Registers.SetRegisterPair("HL", tmp[0]);
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(0 /* CARRY */, overflow.Get() != 0);
// todo check if flags are set correctly
return [1, 11]; return [1, 11];
}; };
@ -67,8 +74,10 @@ TI.Opcodes[0x0A] = function (args) {
}; };
TI.Opcodes[0x0B] = function (args) { TI.Opcodes[0x0B] = function (args) {
// dec bc var tmp = Registers.GenerateWord("B", "C");
return [1, 4]; tmp.Sub(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
}; };
TI.Opcodes[0x0C] = function (args) { TI.Opcodes[0x0C] = function (args) {
@ -81,4 +90,21 @@ TI.Opcodes[0x0C] = function (args) {
Registers.SetFlag(7 /* SIGN */, Registers.byteRegisters["C"].Test(7)); Registers.SetFlag(7 /* SIGN */, Registers.byteRegisters["C"].Test(7));
return [1, 4]; return [1, 4];
}; };
TI.Opcodes[0x0D] = function (args) {
// dec c
return [1, 4];
};
TI.Opcodes[0x0E] = function (args) {
Registers.byteRegisters["A"] = args[1];
return [2, 7];
};
TI.Opcodes[0x0F] = function (args) {
Registers.SetFlag(0 /* CARRY */, Registers.byteRegisters["A"].ShiftRight(true));
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(4 /* HALF */, false);
return [1, 4];
};
//# s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,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC;;AAED,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,SAAS,CAAC,OAAO,CAAC,aAAW,EAAE,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7E,SAAS,CAAC,OAAO,CAAC,cAAY,EAAE,KAAK,CAAC;IACtC,SAAS,CAAC,OAAO,CAAC,YAAU,EAAE,KAAK,CAAC;IACpC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC"}

View file

@ -9,8 +9,7 @@ TI.Opcodes[0x00] = function(args: Byte[]): number[] {
}; };
TI.Opcodes[0x01] = function(args: Byte[]): number[] { TI.Opcodes[0x01] = function(args: Byte[]): number[] {
Registers.byteRegisters["B"] = args[2]; Registers.SetRegisterPair("BC", new Word(args[2], args[1]));
Registers.byteRegisters["C"] = args[1];
return [3, 10]; return [3, 10];
}; };
@ -20,8 +19,10 @@ TI.Opcodes[0x02] = function(args: Byte[]): number[] {
}; };
TI.Opcodes[0x03] = function(args: Byte[]): number[] { TI.Opcodes[0x03] = function(args: Byte[]): number[] {
// inc bc var tmp = Registers.GenerateWord("B", "C");
return [1, 4]; tmp.Add(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
}; };
TI.Opcodes[0x04] = function(args: Byte[]): number[] { TI.Opcodes[0x04] = function(args: Byte[]): number[] {
@ -31,7 +32,7 @@ TI.Opcodes[0x04] = function(args: Byte[]): number[] {
Registers.SetFlag(Flags.ZERO, over.Get() != 0); Registers.SetFlag(Flags.ZERO, over.Get() != 0);
Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters["B"].Test(7) == true); Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters["B"].Test(7) == true);
Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F); Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(Flags.SIGN, Registers.byteRegisters["B"].Test(7)) Registers.SetFlag(Flags.SIGN, Registers.byteRegisters["B"].Test(7));
return [1, 4]; return [1, 4];
}; };
@ -58,7 +59,12 @@ TI.Opcodes[0x08] = function(args: Byte[]): number[] {
}; };
TI.Opcodes[0x09] = function(args: Byte[]): number[] { TI.Opcodes[0x09] = function(args: Byte[]): number[] {
// add hl, bc var tmp = [Registers.GenerateWord("H", "L"), Registers.GenerateWord("B","C")];
var overflow = tmp[0].Add(tmp[1]);
Registers.SetRegisterPair("HL", tmp[0]);
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.CARRY, overflow.Get() != 0);
// todo check if flags are set correctly
return [1, 11]; return [1, 11];
}; };
@ -68,8 +74,10 @@ TI.Opcodes[0x0A] = function(args: Byte[]): number[] {
}; };
TI.Opcodes[0x0B] = function(args: Byte[]): number[] { TI.Opcodes[0x0B] = function(args: Byte[]): number[] {
// dec bc var tmp = Registers.GenerateWord("B", "C");
return [1, 4]; tmp.Sub(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
}; };
TI.Opcodes[0x0C] = function(args: Byte[]): number[] { TI.Opcodes[0x0C] = function(args: Byte[]): number[] {
@ -79,6 +87,23 @@ TI.Opcodes[0x0C] = function(args: Byte[]): number[] {
Registers.SetFlag(Flags.ZERO, over.Get() != 0); Registers.SetFlag(Flags.ZERO, over.Get() != 0);
Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters["C"].Test(7) == true); Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters["C"].Test(7) == true);
Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F); Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(Flags.SIGN, Registers.byteRegisters["C"].Test(7)) Registers.SetFlag(Flags.SIGN, Registers.byteRegisters["C"].Test(7));
return [1, 4];
};
TI.Opcodes[0x0D] = function(args: Byte[]): number[] {
// dec c
return [1, 4];
};
TI.Opcodes[0x0E] = function(args: Byte[]): number[] {
Registers.byteRegisters["A"] = args[1];
return [2, 7];
};
TI.Opcodes[0x0F] = function(args: Byte[]): number[] {
Registers.SetFlag(Flags.CARRY, Registers.byteRegisters["A"].ShiftRight(true));
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.HALF, false);
return [1, 4]; return [1, 4];
}; };

View file

@ -3,4 +3,32 @@
/// <reference path="../Memory.ts" /> /// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" /> /// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" /> /// <reference path="../TI.ts" />
TI.Opcodes[0x10] = function (args) {
Registers.byteRegisters["B"].Sub(1);
if (Registers.byteRegisters["B"].Get() != 0) {
Registers.programCounter.AddByte(args[1], true);
return [0, 13];
} else
return [2, 8];
};
TI.Opcodes[0x11] = function (args) {
Registers.SetRegisterPair("DE", new Word(args[2], args[1]));
return [3, 10];
};
TI.Opcodes[0x12] = function (args) {
Memory.Set(Registers.GenerateWord("D", "E"), Registers.byteRegisters["A"]);
return [1, 7];
};
TI.Opcodes[0x13] = function (args) {
var tmp = Registers.GenerateWord("D", "E");
tmp.Add(1);
Registers.SetRegisterPair("DE", tmp);
return [1, 6];
};
TI.Opcodes[0x13] = function (args) {
};
//# sourceMappingURL=0x1.js.map //# sourceMappingURL=0x1.js.map

View file

@ -1 +1 @@
{"version":3,"file":"0x1.js","sourceRoot":"","sources":["0x1.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kCAAkC;AAClC,qCAAqC;AACrC,wCAAwC;AACxC,iCAAiC"} {"version":3,"file":"0x1.js","sourceRoot":"","sources":["0x1.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kCAAkC;AAClC,qCAAqC;AACrC,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AC,IAAI,CAAC,GAAG,UAAS,IAAY;AAExC,CAAC"}

View file

@ -3,3 +3,32 @@
/// <reference path="../Memory.ts" /> /// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" /> /// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" /> /// <reference path="../TI.ts" />
TI.Opcodes[0x10] = function(args: Byte[]): number[] {
Registers.byteRegisters["B"].Sub(1);
if(Registers.byteRegisters["B"].Get() != 0) {
Registers.programCounter.AddByte(args[1], true);
return [0, 13];
} else return [2, 8];
};
TI.Opcodes[0x11] = function(args: Byte[]): number[] {
Registers.SetRegisterPair("DE", new Word(args[2], args[1]));
return [3, 10];
};
TI.Opcodes[0x12] = function(args: Byte[]): number[] {
Memory.Set(Registers.GenerateWord("D", "E"), Registers.byteRegisters["A"]);
return [1, 7];
};
TI.Opcodes[0x13] = function(args: Byte[]): number[] {
var tmp = Registers.GenerateWord("D","E");
tmp.Add(1);
Registers.SetRegisterPair("DE", tmp);
return [1, 6];
};
TI.Opcodes[0x13] = function(args: Byte[]): number[] {
};

21
js/ops/generic.js Normal file
View file

@ -0,0 +1,21 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
function IncrementRegister(reg) {
if (reg.length == 1) {
var tmp = Registers.byteRegisters[reg];
var over = Registers.byteRegisters[reg].Add(1);
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(6 /* ZERO */, over.Get() != 0);
Registers.SetFlag(2 /* PARITY */, tmp.Test(7) == false && Registers.byteRegisters[reg].Test(7) == true);
Registers.SetFlag(4 /* HALF */, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(7 /* SIGN */, Registers.byteRegisters[reg].Test(7));
} else {
var tmp = Registers.GenerateWord(reg[0], reg[1]);
tmp.Add(1);
Registers.SetRegisterPair(reg, tmp);
}
}
//# sourceMappingURL=generic.js.map

1
js/ops/generic.js.map Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"generic.js","sourceRoot":"","sources":["generic.ts"],"names":["IncrementRegister"],"mappings":"AAAA,mCAAmC;AACnC,kCAAkC;AAClC,qCAAqC;AACrC,wCAAwC;AACxC,iCAAiC;AAEjC,SAAS,iBAAiB,CAAC,GAAW;IAClCA,IAAGA,GAAGA,CAACA,MAAMA,IAAIA,CAACA,CAAEA;QAChBA,IAAIA,GAAGA,GAAGA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA;QACtCA,IAAIA,IAAIA,GAAGA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA;QAC9CA,SAASA,CAACA,OAAOA,CAACA,cAAYA,EAAEA,KAAKA,CAACA;QACtCA,SAASA,CAACA,OAAOA,CAACA,YAAUA,EAAEA,IAAIA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA;QAC9CA,SAASA,CAACA,OAAOA,CAACA,cAAYA,EAAEA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,IAAIA,KAAKA,IAAIA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,IAAIA,IAAIA,CAACA;QACrGA,SAASA,CAACA,OAAOA,CAACA,YAAUA,EAAEA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,IAAIA,IAAIA,CAACA;QACzDA,SAASA,CAACA,OAAOA,CAACA,YAAUA,EAAEA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;KACtEA,KAAMA;QACHA,IAAIA,GAAGA,GAAGA,SAASA,CAACA,YAAYA,CAACA,GAAGA,CAACA,CAACA,CAACA,EAACA,GAAGA,CAACA,CAACA,CAACA,CAACA;QAC/CA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA;QACVA,SAASA,CAACA,eAAeA,CAACA,GAAGA,EAAEA,GAAGA,CAACA;KACtCA;AACLA,CAACA"}

21
js/ops/generic.ts Normal file
View file

@ -0,0 +1,21 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
function IncrementRegister(reg: string) {
if(reg.length == 1) {
var tmp = Registers.byteRegisters[reg];
var over = Registers.byteRegisters[reg].Add(1);
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.ZERO, over.Get() != 0);
Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters[reg].Test(7) == true);
Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(Flags.SIGN, Registers.byteRegisters[reg].Test(7));
} else {
var tmp = Registers.GenerateWord(reg[0],reg[1]);
tmp.Add(1);
Registers.SetRegisterPair(reg, tmp);
}
}