Emulator debugging - testing for conditions like JR NC

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
Post Reply
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Emulator debugging - testing for conditions like JR NC

Post by Morkin »

Basically I'm trying to work out how to test for a particular condition, like:

Code: Select all

JR NC, ....
In this example I want the program to break/pause when a NC occurs. Normally I'd put a breakpoint on the address jumped to after the NC, but that address is used by other routines as well.

I mainly use Spin & Spectaculator but can't figure it out, though it might be me just being stupid as I'm not great at debugging. Anyone know if there's a way of doing it in either of those emulators? Or if not, using any other/other tools?

(Have posted this in Emulators but feel free to move)
My Speccy site: thirdharmoniser.com
User avatar
Weiv
Microbot
Posts: 177
Joined: Fri Apr 06, 2018 5:28 pm
Location: Ukraine

Re: Emulator debugging - testing for conditions like JR NC

Post by Weiv »

You surely can't do it in Spectaculator. I can't say about ZXSpin, I don't know how breakpoints works in it.
You can do it in UnrealSpeccy with conditional breakpoint setted with expression (pc==address) && (f&1==0) (the emulator has brief help documentation).
Also you can do it in EmuZWin: button "Breakpoint List" in Debugger, button "New Breakpoint", edit Addr1=Addr2=address, check "And conditions satisfied", button "Edit conds", check "Stop if one of conditions satisfied", select Register F, Mask 1, Condition =, Vaule 0, button "Add", button "OK", button "OK".
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Emulator debugging - testing for conditions like JR NC

Post by Morkin »

Weiv wrote: Sat Nov 21, 2020 11:32 pm Also you can do it in EmuZWin: button "Breakpoint List" in Debugger, button "New Breakpoint", edit Addr1=Addr2=address, check "And conditions satisfied", button "Edit conds", check "Stop if one of conditions satisfied", select Register F, Mask 1, Condition =, Vaule 0, button "Add", button "OK", button "OK".
That's great, thanks..! I had a look at EmuZWin and gave it a try, and it seems to work OK.

Image

It hurts my brain trying to work out whether to use F & 01 = 1 or F & 01 = 0 to check the different NZ, Z, NC, C combinations but the principle is sound :)
My Speccy site: thirdharmoniser.com
User avatar
Weiv
Microbot
Posts: 177
Joined: Fri Apr 06, 2018 5:28 pm
Location: Ukraine

Re: Emulator debugging - testing for conditions like JR NC

Post by Weiv »

Morkin wrote: Sun Nov 22, 2020 2:01 pm It hurts my brain trying to work out whether to use F & 01 = 1 or F & 01 = 0 to check the different NZ, Z, NC, C combinations but the principle is sound :)
It's easy. Mask is a 2^position of needed flag in register F :
76543210
SZ-H-PNC,
NC is for CF=0, Mask for CF is 2^0 = 1, Value=0; C is for CF=1, Value=Mask=1
NZ is for ZF=0, Mask for ZF is 2^6=64=#40, Value=0, Z is for ZF=1, Value=Mask=64=#40.
PO is for PF=0, PE is for PF=1, Mask=2^2=4
P is for SF=0, M is for SF=1, Mask=2^7=128=#80
Or
NC: Mask=1 Value=0
C: Mask=1 Value=1
NZ: Mask=64 Value=0
Z: Mask=64 Value=64
PO: Mask=4 Value=0
PE: Mask=4 Value=4
P: Mask=128 Value=0
M: Mask=128 Value=128
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Emulator debugging - testing for conditions like JR NC

Post by Morkin »

Weiv wrote: Sun Nov 22, 2020 2:29 pm
Morkin wrote: Sun Nov 22, 2020 2:01 pm It hurts my brain trying to work out whether to use F & 01 = 1 or F & 01 = 0 to check the different NZ, Z, NC, C combinations but the principle is sound :)
It's easy. Mask is a 2^position of needed flag in register F :
76543210
SZ-H-PNC,
NC is for CF=0, Mask for CF is 2^0 = 1, Value=0; C is for CF=1, Value=Mask=1
NZ is for ZF=0, Mask for ZF is 2^6=64=#40, Value=0, Z is for ZF=1, Value=Mask=64=#40.
PO is for PF=0, PE is for PF=1, Mask=2^2=4
P is for SF=0, M is for SF=1, Mask=2^7=128=#80
Or
NC: Mask=1 Value=0
C: Mask=1 Value=1
NZ: Mask=64 Value=0
Z: Mask=64 Value=64
PO: Mask=4 Value=0
PE: Mask=4 Value=4
P: Mask=128 Value=0
M: Mask=128 Value=128
Thanks for the explanation - that's clear now..!
My Speccy site: thirdharmoniser.com
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Emulator debugging - testing for conditions like JR NC

Post by Morkin »

< bump >

Have re-visited EmuZWin to try to check something, but I think I may be getting something wrong (again)...

I'm trying to create a breakpoint that will stop the program when a CARRY jump takes place at a particular address.

The breakpoint seems to trigger even when the carry flag isn't set:

Image

Have re-read the guidance in the earlier post... I'm sure it worked OK last time I used it, but that was a JR NC scenario.

Perhaps I'm getting something wrong with the flag condition, now that it's a JR C..? Any suggestions welcome.
My Speccy site: thirdharmoniser.com
User avatar
Weiv
Microbot
Posts: 177
Joined: Fri Apr 06, 2018 5:28 pm
Location: Ukraine

Re: Emulator debugging - testing for conditions like JR NC

Post by Weiv »

Morkin wrote: Tue Apr 06, 2021 4:53 pm The breakpoint seems to trigger even when the carry flag isn't set:
I checked it and got the same result. It seems like it's a bug of the debugger. Unfortunately this emulator is pretty buggy(
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Emulator debugging - testing for conditions like JR NC

Post by Morkin »

Weiv wrote: Sun Apr 11, 2021 2:05 am
Morkin wrote: Tue Apr 06, 2021 4:53 pm The breakpoint seems to trigger even when the carry flag isn't set:
I checked it and got the same result. It seems like it's a bug of the debugger. Unfortunately this emulator is pretty buggy(
Ah - thanks for trying it, at least it's not just me going crazy..!

I think it may have worked the first time I set it, but when you try to change things it acts a bit weird.... No worries..!
My Speccy site: thirdharmoniser.com
Post Reply