UNPKG

@asm80/core

Version:

Core ASM80 compiler / assembler

1,119 lines (1,098 loc) 243 kB
import { Z80 } from "../cpu/z80.js"; import { Parser } from "../expression-parser.js"; import QUnit from "qunit" import { asyncThrows } from "./_asyncThrows.js"; QUnit.module("ASM - Z80"); //jsHintQUnit.test( "JSHint", "../../lib/z80.js"); var vars = {"LOOP":0x1234,"SHORT":0x21,"_PC":0x0100}; var s = [], p; QUnit.test( "LD A,(IX+666)", function() { s = {"opcode":"LD","params":["A","(IX+666)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x7E,"Opcode 1 = 0x7E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); QUnit.assert.throws(function(){p.lens[2]({_PC:0x100})},"OK"); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD C,(1234)", function() { s = {"opcode":"LD","params":["C","(1234)"],"addr":0x100,"lens":[],"bytes":0}; QUnit.assert.throws(function(){ Z80.parseOpcode(s,vars, Parser);},"Throw OK"); }); QUnit.test( "LD 123", function() { s = {"opcode":"LD","params":["123"],"addr":0x100,"lens":[],"bytes":0}; QUnit.assert.throws(function(){ Z80.parseOpcode(s,vars, Parser);},"Throw OK"); }); QUnit.test( "IM 5", function() { s = {"opcode":"IM","params":["5"],"addr":0x100,"lens":[],"bytes":0}; QUnit.assert.throws(function(){ Z80.parseOpcode(s,vars, Parser);},"Throw OK"); }); QUnit.test( "RST 99", function() { s = {"opcode":"RST","params":["99"],"addr":0x100,"lens":[],"bytes":0}; QUnit.assert.throws(function(){ Z80.parseOpcode(s,vars, Parser);},"Throw OK"); }); QUnit.test( "POP BC,DE", function() { s = {"opcode":"POP","params":["BC","DE"],"addr":0x100,"lens":[],"bytes":0}; QUnit.assert.throws(function(){ Z80.parseOpcode(s,vars, Parser);},"Throw OK"); }); QUnit.test( "POP", function() { s = {"opcode":"POP","params":[],"addr":0x100,"lens":[],"bytes":0}; QUnit.assert.throws(function(){ Z80.parseOpcode(s,vars, Parser);},"Throw OK"); }); QUnit.test( "LD A,IXL", function() { s = {"opcode":"LD","params":["A","IXL"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x7D,"Opcode 1 = 0x7D OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD A,IYL", function() { s = {"opcode":"LD","params":["A","IYL"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x7D,"Opcode 1 = 0x7D OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); //syntaktic sugar const ssldpp = (rp1,rp2,oc1,oc2) => { QUnit.test( `LD ${rp1},${rp2}`, function() { s = {"opcode":"LD","params":[rp1,rp2],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],oc1,"Opcode 0 OK"); QUnit.assert.equal(p.lens[1],oc2,"Opcode 1 OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); } ssldpp("HL","DE",0x62,0x6b); ssldpp("HL","BC",0x60,0x69); ssldpp("DE","HL",0x54,0x5d); ssldpp("DE","BC",0x50,0x59); ssldpp("BC","HL",0x44,0x4d); ssldpp("BC","DE",0x42,0x4b); QUnit.test( "LD A,(0123)", function() { s = {"opcode":"LD","params":["A","(0123)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x3a,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,IXH", function() { s = {"opcode":"LD","params":["A","IXH"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x7C,"Opcode 1 = 0x7C OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD A,IYH", function() { s = {"opcode":"LD","params":["A","IYH"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x7C,"Opcode 1 = 0x7C OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "OUT (254),A", function() { s = {"opcode":"OUT","params":["(254)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xD3,"Opcode 0 = 0xD3 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "JR 1234", function() { s = {"opcode":"JR","params":["1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x18,"Opcode 0 = 0x18 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); QUnit.assert.throws(function(){p.lens[1]({_PC:0x100})},"OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "JR 1", function() { s = {"opcode":"JR","params":["1"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x18,"Opcode 0 = 0x18 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); QUnit.assert.throws(function(){p.lens[1]({_PC:0x100})},"OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "JR $", function() { s = {"opcode":"JR","params":["$"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x18,"Opcode 0 = 0x18 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); let test = p.lens[1]({_PC:0x100}) QUnit.assert.equal(test,254,"disp val"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "JR NC,$", function() { s = {"opcode":"JR","params":["NC","$"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x30,"Opcode 0 = 0x30 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); let test = p.lens[1]({_PC:0x100}) QUnit.assert.equal(test,254,"disp val"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "JR NC,1234", function() { s = {"opcode":"JR","params":["NC","1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x30,"Opcode 0 = 0x30 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); QUnit.assert.throws(function(){p.lens[1]({_PC:0x100})},"OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "JR NC,1", function() { s = {"opcode":"JR","params":["NC","1"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x30,"Opcode 0 = 0x30 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); QUnit.assert.throws(function(){p.lens[1]({_PC:0x100})},"OK"); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD A,A", function() { s = {"opcode":"LD","params":["A","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x7F,"Opcode 0 = 0x7F OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,B", function() { s = {"opcode":"LD","params":["A","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x78,"Opcode 0 = 0x78 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,C", function() { s = {"opcode":"LD","params":["A","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x79,"Opcode 0 = 0x79 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,D", function() { s = {"opcode":"LD","params":["A","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x7A,"Opcode 0 = 0x7A OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,E", function() { s = {"opcode":"LD","params":["A","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x7B,"Opcode 0 = 0x7B OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,H", function() { s = {"opcode":"LD","params":["A","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x7C,"Opcode 0 = 0x7C OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,L", function() { s = {"opcode":"LD","params":["A","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x7D,"Opcode 0 = 0x7D OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,(HL)", function() { s = {"opcode":"LD","params":["A","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x7E,"Opcode 0 = 0x7E OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,(BC)", function() { s = {"opcode":"LD","params":["A","(BC)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x0A,"Opcode 0 = 0x0A OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,(DE)", function() { s = {"opcode":"LD","params":["A","(DE)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x1A,"Opcode 0 = 0x1A OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD A,(0x1234)", function() { s = {"opcode":"LD","params":["A","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x3A,"Opcode 0 = 0x3A OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,(IX+0x34)", function() { s = {"opcode":"LD","params":["A","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x7E,"Opcode 1 = 0x7E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,(IX + 0x34) [with spaces]", function() { s = {"opcode":"LD","params":["A","(IX + 0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x7E,"Opcode 1 = 0x7E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,(IY+0x34)", function() { s = {"opcode":"LD","params":["A","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x7E,"Opcode 1 = 0x7E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,(IX-0x34)", function() { s = {"opcode":"LD","params":["A","(IX-0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x7E,"Opcode 1 = 0x7E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,(IY-0x34)", function() { s = {"opcode":"LD","params":["A","(IY-0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x7E,"Opcode 1 = 0x7E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD B,A", function() { s = {"opcode":"LD","params":["B","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x47,"Opcode 0 = 0x47 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,B", function() { s = {"opcode":"LD","params":["B","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x40,"Opcode 0 = 0x40 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,C", function() { s = {"opcode":"LD","params":["B","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x41,"Opcode 0 = 0x41 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,D", function() { s = {"opcode":"LD","params":["B","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x42,"Opcode 0 = 0x42 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,E", function() { s = {"opcode":"LD","params":["B","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x43,"Opcode 0 = 0x43 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,H", function() { s = {"opcode":"LD","params":["B","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x44,"Opcode 0 = 0x44 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,L", function() { s = {"opcode":"LD","params":["B","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x45,"Opcode 0 = 0x45 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,(HL)", function() { s = {"opcode":"LD","params":["B","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x46,"Opcode 0 = 0x46 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD B,(IX+0x34)", function() { s = {"opcode":"LD","params":["B","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x46,"Opcode 1 = 0x46 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD B,(IY+0x34)", function() { s = {"opcode":"LD","params":["B","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x46,"Opcode 1 = 0x46 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD C,A", function() { s = {"opcode":"LD","params":["C","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x4F,"Opcode 0 = 0x4F OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,B", function() { s = {"opcode":"LD","params":["C","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x48,"Opcode 0 = 0x48 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,C", function() { s = {"opcode":"LD","params":["C","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x49,"Opcode 0 = 0x49 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,D", function() { s = {"opcode":"LD","params":["C","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x4A,"Opcode 0 = 0x4A OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,E", function() { s = {"opcode":"LD","params":["C","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x4B,"Opcode 0 = 0x4B OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,H", function() { s = {"opcode":"LD","params":["C","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x4C,"Opcode 0 = 0x4C OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,L", function() { s = {"opcode":"LD","params":["C","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x4D,"Opcode 0 = 0x4D OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,(HL)", function() { s = {"opcode":"LD","params":["C","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x4E,"Opcode 0 = 0x4E OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD C,(IX+0x34)", function() { s = {"opcode":"LD","params":["C","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x4E,"Opcode 1 = 0x4E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD C,(IY+0x34)", function() { s = {"opcode":"LD","params":["C","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x4E,"Opcode 1 = 0x4E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD D,A", function() { s = {"opcode":"LD","params":["D","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x57,"Opcode 0 = 0x57 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,B", function() { s = {"opcode":"LD","params":["D","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x50,"Opcode 0 = 0x50 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,C", function() { s = {"opcode":"LD","params":["D","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x51,"Opcode 0 = 0x51 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,D", function() { s = {"opcode":"LD","params":["D","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x52,"Opcode 0 = 0x52 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,E", function() { s = {"opcode":"LD","params":["D","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x53,"Opcode 0 = 0x53 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,H", function() { s = {"opcode":"LD","params":["D","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x54,"Opcode 0 = 0x54 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,L", function() { s = {"opcode":"LD","params":["D","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x55,"Opcode 0 = 0x55 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,(HL)", function() { s = {"opcode":"LD","params":["D","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x56,"Opcode 0 = 0x56 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD D,(IX+0x34)", function() { s = {"opcode":"LD","params":["D","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x56,"Opcode 1 = 0x56 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD D,(IY+0x34)", function() { s = {"opcode":"LD","params":["D","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x56,"Opcode 1 = 0x56 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD E,A", function() { s = {"opcode":"LD","params":["E","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x5F,"Opcode 0 = 0x5F OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,B", function() { s = {"opcode":"LD","params":["E","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x58,"Opcode 0 = 0x58 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,C", function() { s = {"opcode":"LD","params":["E","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x59,"Opcode 0 = 0x59 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,D", function() { s = {"opcode":"LD","params":["E","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x5A,"Opcode 0 = 0x5A OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,E", function() { s = {"opcode":"LD","params":["E","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x5B,"Opcode 0 = 0x5B OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,H", function() { s = {"opcode":"LD","params":["E","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x5C,"Opcode 0 = 0x5C OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,L", function() { s = {"opcode":"LD","params":["E","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x5D,"Opcode 0 = 0x5D OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,(HL)", function() { s = {"opcode":"LD","params":["E","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x5E,"Opcode 0 = 0x5E OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD E,(IX+0x34)", function() { s = {"opcode":"LD","params":["E","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x5E,"Opcode 1 = 0x5E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD E,(IY+0x34)", function() { s = {"opcode":"LD","params":["E","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x5E,"Opcode 1 = 0x5E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD H,A", function() { s = {"opcode":"LD","params":["H","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x67,"Opcode 0 = 0x67 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,B", function() { s = {"opcode":"LD","params":["H","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x60,"Opcode 0 = 0x60 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,C", function() { s = {"opcode":"LD","params":["H","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x61,"Opcode 0 = 0x61 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,D", function() { s = {"opcode":"LD","params":["H","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x62,"Opcode 0 = 0x62 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,E", function() { s = {"opcode":"LD","params":["H","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x63,"Opcode 0 = 0x63 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,H", function() { s = {"opcode":"LD","params":["H","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x64,"Opcode 0 = 0x64 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,L", function() { s = {"opcode":"LD","params":["H","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x65,"Opcode 0 = 0x65 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,(HL)", function() { s = {"opcode":"LD","params":["H","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x66,"Opcode 0 = 0x66 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD H,(IX+0x34)", function() { s = {"opcode":"LD","params":["H","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x66,"Opcode 1 = 0x66 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD H,(IY+0x34)", function() { s = {"opcode":"LD","params":["H","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x66,"Opcode 1 = 0x66 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD L,A", function() { s = {"opcode":"LD","params":["L","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x6F,"Opcode 0 = 0x6F OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,B", function() { s = {"opcode":"LD","params":["L","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x68,"Opcode 0 = 0x68 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,C", function() { s = {"opcode":"LD","params":["L","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x69,"Opcode 0 = 0x69 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,D", function() { s = {"opcode":"LD","params":["L","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x6A,"Opcode 0 = 0x6A OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,E", function() { s = {"opcode":"LD","params":["L","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x6B,"Opcode 0 = 0x6B OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,H", function() { s = {"opcode":"LD","params":["L","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x6C,"Opcode 0 = 0x6C OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,L", function() { s = {"opcode":"LD","params":["L","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x6D,"Opcode 0 = 0x6D OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,(HL)", function() { s = {"opcode":"LD","params":["L","(HL)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x6E,"Opcode 0 = 0x6E OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD L,(IX+0x34)", function() { s = {"opcode":"LD","params":["L","(IX+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x6E,"Opcode 1 = 0x6E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD L,(IY+0x34)", function() { s = {"opcode":"LD","params":["L","(IY+0x34)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x6E,"Opcode 1 = 0x6E OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (HL),A", function() { s = {"opcode":"LD","params":["(HL)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x77,"Opcode 0 = 0x77 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (HL),B", function() { s = {"opcode":"LD","params":["(HL)","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x70,"Opcode 0 = 0x70 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (HL),C", function() { s = {"opcode":"LD","params":["(HL)","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x71,"Opcode 0 = 0x71 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (HL),D", function() { s = {"opcode":"LD","params":["(HL)","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x72,"Opcode 0 = 0x72 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (HL),E", function() { s = {"opcode":"LD","params":["(HL)","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x73,"Opcode 0 = 0x73 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (HL),H", function() { s = {"opcode":"LD","params":["(HL)","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x74,"Opcode 0 = 0x74 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (HL),L", function() { s = {"opcode":"LD","params":["(HL)","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x75,"Opcode 0 = 0x75 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (IX+0x34),A", function() { s = {"opcode":"LD","params":["(IX+0x34)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x77,"Opcode 1 = 0x77 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IX+0x34),B", function() { s = {"opcode":"LD","params":["(IX+0x34)","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x70,"Opcode 1 = 0x70 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IX+0x34),C", function() { s = {"opcode":"LD","params":["(IX+0x34)","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x71,"Opcode 1 = 0x71 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IX+0x34),D", function() { s = {"opcode":"LD","params":["(IX+0x34)","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x72,"Opcode 1 = 0x72 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IX+0x34),E", function() { s = {"opcode":"LD","params":["(IX+0x34)","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x73,"Opcode 1 = 0x73 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IX+0x34),H", function() { s = {"opcode":"LD","params":["(IX+0x34)","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x74,"Opcode 1 = 0x74 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IX+0x34),L", function() { s = {"opcode":"LD","params":["(IX+0x34)","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x75,"Opcode 1 = 0x75 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),A", function() { s = {"opcode":"LD","params":["(IY+0x34)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x77,"Opcode 1 = 0x77 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),B", function() { s = {"opcode":"LD","params":["(IY+0x34)","B"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x70,"Opcode 1 = 0x70 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),C", function() { s = {"opcode":"LD","params":["(IY+0x34)","C"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x71,"Opcode 1 = 0x71 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),D", function() { s = {"opcode":"LD","params":["(IY+0x34)","D"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x72,"Opcode 1 = 0x72 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),E", function() { s = {"opcode":"LD","params":["(IY+0x34)","E"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x73,"Opcode 1 = 0x73 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),H", function() { s = {"opcode":"LD","params":["(IY+0x34)","H"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x74,"Opcode 1 = 0x74 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (IY+0x34),L", function() { s = {"opcode":"LD","params":["(IY+0x34)","L"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x75,"Opcode 1 = 0x75 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD A,0x12", function() { s = {"opcode":"LD","params":["A","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x3E,"Opcode 0 = 0x3E OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD B,0x12", function() { s = {"opcode":"LD","params":["B","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x06,"Opcode 0 = 0x06 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD C,0x12", function() { s = {"opcode":"LD","params":["C","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x0E,"Opcode 0 = 0x0E OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD D,0x12", function() { s = {"opcode":"LD","params":["D","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x16,"Opcode 0 = 0x16 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD E,0x12", function() { s = {"opcode":"LD","params":["E","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x1E,"Opcode 0 = 0x1E OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD H,0x12", function() { s = {"opcode":"LD","params":["H","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x26,"Opcode 0 = 0x26 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD L,0x12", function() { s = {"opcode":"LD","params":["L","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x2E,"Opcode 0 = 0x2E OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD (HL),0x12", function() { s = {"opcode":"LD","params":["(HL)","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x36,"Opcode 0 = 0x36 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,2,"Length OK"); }); QUnit.test( "LD (IX+0x34),0x12", function() { s = {"opcode":"LD","params":["(IX+0x34)","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x36,"Opcode 1 = 0x36 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(typeof(p.lens[3]),"function","Opcode 3 OK"); p.lens[3]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (IY+0x34),0x12", function() { s = {"opcode":"LD","params":["(IY+0x34)","0x12"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x36,"Opcode 1 = 0x36 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(typeof(p.lens[3]),"function","Opcode 3 OK"); p.lens[3]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (BC),A", function() { s = {"opcode":"LD","params":["(BC)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x02,"Opcode 0 = 0x02 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (DE),A", function() { s = {"opcode":"LD","params":["(DE)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x12,"Opcode 0 = 0x12 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD (0x1234),A", function() { s = {"opcode":"LD","params":["(0x1234)","A"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x32,"Opcode 0 = 0x32 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD BC,0x1234", function() { s = {"opcode":"LD","params":["BC","0x1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x01,"Opcode 0 = 0x01 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD DE,0x1234", function() { s = {"opcode":"LD","params":["DE","0x1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x11,"Opcode 0 = 0x11 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD HL,0x1234", function() { s = {"opcode":"LD","params":["HL","0x1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x21,"Opcode 0 = 0x21 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD SP,0x1234", function() { s = {"opcode":"LD","params":["SP","0x1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x31,"Opcode 0 = 0x31 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD IX,0x1234", function() { s = {"opcode":"LD","params":["IX","0x1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x21,"Opcode 1 = 0x21 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD IY,0x1234", function() { s = {"opcode":"LD","params":["IY","0x1234"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x21,"Opcode 1 = 0x21 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD HL,(0x1234)", function() { s = {"opcode":"LD","params":["HL","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x2A,"Opcode 0 = 0x2A OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD BC,(0x1234)", function() { s = {"opcode":"LD","params":["BC","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xED,"Opcode 0 = 0xED OK"); QUnit.assert.equal(p.lens[1],0x4B,"Opcode 1 = 0x4B OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD DE,(0x1234)", function() { s = {"opcode":"LD","params":["DE","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xED,"Opcode 0 = 0xED OK"); QUnit.assert.equal(p.lens[1],0x5B,"Opcode 1 = 0x5B OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD SP,(0x1234)", function() { s = {"opcode":"LD","params":["SP","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xED,"Opcode 0 = 0xED OK"); QUnit.assert.equal(p.lens[1],0x7B,"Opcode 1 = 0x7B OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD IX,(0x1234)", function() { s = {"opcode":"LD","params":["IX","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x2A,"Opcode 1 = 0x2A OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD IY,(0x1234)", function() { s = {"opcode":"LD","params":["IY","(0x1234)"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x2A,"Opcode 1 = 0x2A OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (0x1234),HL", function() { s = {"opcode":"LD","params":["(0x1234)","HL"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0x22,"Opcode 0 = 0x22 OK"); QUnit.assert.equal(typeof(p.lens[1]),"function","Opcode 1 OK"); p.lens[1]({}); QUnit.assert.equal(p.bytes,3,"Length OK"); }); QUnit.test( "LD (0x1234),BC", function() { s = {"opcode":"LD","params":["(0x1234)","BC"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xED,"Opcode 0 = 0xED OK"); QUnit.assert.equal(p.lens[1],0x43,"Opcode 1 = 0x43 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (0x1234),DE", function() { s = {"opcode":"LD","params":["(0x1234)","DE"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xED,"Opcode 0 = 0xED OK"); QUnit.assert.equal(p.lens[1],0x53,"Opcode 1 = 0x53 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (0x1234),IX", function() { s = {"opcode":"LD","params":["(0x1234)","IX"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xDD,"Opcode 0 = 0xDD OK"); QUnit.assert.equal(p.lens[1],0x22,"Opcode 1 = 0x22 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (0x1234),IY", function() { s = {"opcode":"LD","params":["(0x1234)","IY"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xFD,"Opcode 0 = 0xFD OK"); QUnit.assert.equal(p.lens[1],0x22,"Opcode 1 = 0x22 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD (0x1234),SP", function() { s = {"opcode":"LD","params":["(0x1234)","SP"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xED,"Opcode 0 = 0xED OK"); QUnit.assert.equal(p.lens[1],0x73,"Opcode 1 = 0x73 OK"); QUnit.assert.equal(typeof(p.lens[2]),"function","Opcode 2 OK"); p.lens[2]({}); QUnit.assert.equal(p.bytes,4,"Length OK"); }); QUnit.test( "LD SP,HL", function() { s = {"opcode":"LD","params":["SP","HL"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.parseOpcode(s,vars, Parser); QUnit.assert.equal(p.lens[0],0xF9,"Opcode 0 = 0xF9 OK"); QUnit.assert.equal(p.bytes,1,"Length OK"); }); QUnit.test( "LD SP,IX", function() { s = {"opcode":"LD","params":["SP","IX"],"addr":0x100,"lens":[],"bytes":0}; p = Z80.pars