Welcome, Guest. Please login or register.


Author Topic: Stackpointer-Bug in EP128EMU? (Read 5577 times)

Offline Prodatron

  • EP user
  • *
  • Posts: 256
  • Country: de
  • Back on the Z80
    • http://www.symbos.de
Stackpointer-Bug in EP128EMU?
« on: 2014.December.18. 18:31:34 »
I have a strange behaviour in EP128Emu.
When I unlock the interrupts with EI after there is already an IRQ the following happens:
- the next command after EI will be executed; this is correct
- new #38 is called, which is correct, too
- BUT: instead of having the address of the next command on the stack I have this address increased by 1

Example:

#1000:  EI
#1001:  LD BC,#1006
#1004:  PUSH BC
#1005:  JP (HL)
#1006:  ...
The IRQ happens between LD BC,#1234 and PUSH BC.
The return address in the Stack should be #1004 now.
But it is #1005. PUSH BC is just skipped, when the IRQ returns :eek:
When I add a NOP after the LD BC,#1006 it works...

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: Stackpointer-Bug in EP128EMU?
« Reply #1 on: 2014.December.18. 21:05:21 »
Can you post a snapshot that reproduces this issue ?

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: Stackpointer-Bug in EP128EMU?
« Reply #2 on: 2014.December.21. 12:06:26 »
I tried to reproduce the problem with this code entered in the monitor while IS-BASIC was running:

Code: ZiLOG Z80 Assembler
  1. A   0FF0  F3           DI  
  2. A   0FF1  31 F0 0F     LD    SP, 0FF0
  3. A   0FF4  21 00 00     LD    HL, 0000
  4. A   0FF7  2B           DEC   HL
  5. A   0FF8  7D           LD    A, L
  6. A   0FF9  B4           OR    H
  7. A   0FFA  C2 F7 0F     JP    NZ, 0FF7
  8. A   0FFD  21 F0 0F     LD    HL, 0FF0
  9. A   1000  FB           EI  
  10. A   1001  01 06 10     LD    BC, 1006
  11. A   1004  C5           PUSH  BC
  12. A   1005  E9           JP    (HL)

However, after setting a 0038x breakpoint and starting the code with G FF0, the return address on the stack was always 1004h. I do not know exactly what conditions could trigger the bug, but it cannot be common, because something basic like this being broken would otherwise cause a lot of crashes.

Offline Prodatron

  • EP user
  • *
  • Posts: 256
  • Country: de
  • Back on the Z80
    • http://www.symbos.de
Re: Stackpointer-Bug in EP128EMU?
« Reply #3 on: 2014.December.21. 16:43:43 »
Absolutely strange, now it doesn't happen anymore. Now I could remove the NOP command and it doesn't crash, it works again as it should.
You are right, if there would be a general bug it would crash much more often. Next time (if there is a next time at all...) I will make a snapshot at once.
Anyway thanks a lot for your investigation! (and for this great emulator, I really love it!)