added JSL and RTL
This commit is contained in:
parent
3bbb03143b
commit
02835299a7
30
cpu.js
30
cpu.js
|
@ -127,7 +127,7 @@ function CPU_65816() {
|
|||
0xda : PHX, 0xfa : PLX, 0x08 : PHP, 0x28 : PLP,
|
||||
0xf4 : PEA, 0xd4 : PEI, 0x8b : PHB, 0xab : PLB,
|
||||
0x4b : PHK, 0x0b : PHD, 0x2b : PLD, 0x62 : PER,
|
||||
0x20 : JSR, 0x60 : RTS };
|
||||
0x20 : JSR, 0x60 : RTS, 0x22 : JSL, 0x6b : RTL };
|
||||
|
||||
/**
|
||||
* Take a raw hex string representing the program and execute it.
|
||||
|
@ -206,6 +206,34 @@ var MMU = {
|
|||
}
|
||||
};
|
||||
|
||||
var JSL = {
|
||||
bytes_required:function() {
|
||||
return 4;
|
||||
},
|
||||
execute:function(cpu, bytes) {
|
||||
var location = cpu.r.pc - 1;
|
||||
var low_byte = location & 0x00ff;
|
||||
var high_byte = location >> 8;
|
||||
cpu.mmu.store_byte(cpu.r.s--, cpu.r.pbr);
|
||||
cpu.mmu.store_byte(cpu.r.s--, high_byte);
|
||||
cpu.mmu.store_byte(cpu.r.s--, low_byte);
|
||||
cpu.r.pbr = bytes[2];
|
||||
cpu.r.pc = (bytes[1]<<8)|bytes[0];
|
||||
}
|
||||
};
|
||||
|
||||
var RTL = {
|
||||
bytes_required:function() {
|
||||
return 1;
|
||||
},
|
||||
execute:function(cpu) {
|
||||
var low_byte = cpu.mmu.read_byte(++cpu.r.s);
|
||||
var high_byte = cpu.mmu.read_byte(++cpu.r.s);
|
||||
cpu.r.pbr = cpu.mmu.read_byte(++cpu.r.s);
|
||||
cpu.r.pc = ((high_byte<<8)|low_byte) + 1;
|
||||
}
|
||||
};
|
||||
|
||||
var JSR = {
|
||||
bytes_required:function() {
|
||||
return 3;
|
||||
|
|
Loading…
Reference in New Issue