Permalink
Browse files

fix I, R registers save/restore omission

Registers I and R were not being saved nor restored when hitting (and
continuing from) a breakpoint. This caused the stub to report R and I
values to be zero (uninitialized values) back to gdb.
  • Loading branch information...
legumbre committed May 22, 2012
1 parent 341e5e1 commit 37794eb9f317b8a3877f590db5b9c3ea35fe3921
Showing with 16 additions and 0 deletions.
  1. +16 −0 z80-stub.c
View
@@ -979,6 +979,15 @@ sr() __naked
ld (#_registers + R_IX), ix
ld (#_registers + R_IY), iy
+ ;; save I and R
+ push af
+ ld a, i
+ ld (#_registers + R_I), a ; yes, A
+ ld a, r
+ ld (#_registers + R_R), a ; yes, A
+ pop af
+
+
;; alternate register set
exx
ex af,af' ;;'
@@ -1027,6 +1036,13 @@ sr() __naked
ld ix, (#_registers + R_IX)
ld iy, (#_registers + R_IY)
+ ;; restore I and R
+ push af
+ ld a, (#_registers + R_I)
+ ld i, a
+ ld a, (#_registers + R_R)
+ ld r, a
+ pop af ;; do not forget to restore A and F
exx
ex af, af' ;'

0 comments on commit 37794eb

Please sign in to comment.