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
Dynamite Dan
Posts: 1340
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)
0 x

Weiv
Berk
Posts: 28
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".
1 x

User avatar
Morkin
Dynamite Dan
Posts: 1340
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 :)
0 x

Weiv
Berk
Posts: 28
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
1 x

User avatar
Morkin
Dynamite Dan
Posts: 1340
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..!
1 x

Post Reply