Skip to content
Browse files

Slightly improved step out

  • Loading branch information...
1 parent 3db426d commit 2c2846b4d3eac9e7be3594d9d6f8f42007be89ba @mattgodbolt committed Jul 5, 2011
Showing with 17 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +16 −2 debug.js
View
1 .gitignore
@@ -1,2 +1,3 @@
roms/
roms.js
+.*.swp
View
18 debug.js
@@ -81,10 +81,24 @@ function stepOver() {
stepUntil(function () { return z80.pc == nextPc || z80.sp == sp; });
}
+function isReturn(addr) {
+ var result = disassemble(addr);
+ if (result[0].match(/^RET/)) {
+ return true;
+ }
+ return false;
+}
+
function stepOut() {
var sp = z80.sp;
- // TODO: this isn't very good really...it catches POP etc.
- stepUntil(function () { return z80.sp > sp; });
+ stepUntil(function () {
+ if (z80.sp >= sp && isReturn(z80.pc)) {
+ var nextInstr = nextInstruction(z80.pc);
+ step();
+ return z80.pc != nextInstr;
+ }
+ return false;
+ });
}
function currentDis() {

0 comments on commit 2c2846b

Please sign in to comment.
Something went wrong with that request. Please try again.