Closed r-downing closed 1 year ago
Octo's behavior for flag-results is designed to match CHIP8 on the COSMAC VIP. Try running this test program on a VIP emulator if you wish to confirm: https://github.com/JohnEarnest/Octo/blob/gh-pages/examples/tests/testquirks.8o#L38-L45
Years ago, this behavior had a configurable quirks-mode flag, but I removed it from the UI; Prior to Octo's existence there was little evidence of programs which depended on either interpretation, and I didn't want to encourage the creation of future CHIP8 programs which took a dissenting opinion.
Good to know, thanks for the quick response!
Hello!
I noticed some potential inconsistencies between your implementation and others I've seen online for
vf
, so I was wondering which is correct, and if you have any concrete documentation on this.Here's a short example program:
In Octo it compiles to
So if I'm interpreting correctly, you're
vf
to some value-=
onvf
vf
is 0 (assuming it indicates the borrow)Looks like you expand these comparison expressions by using vf as a temporary reg for the subtraction and the no-borrow flag.
But is it guaranteed that
vf
gets updated to the no-borrow value after it's set to the result of subtraction?In some chip8 emulators I've seen (and my own when I first implemented it), they first check for borrowing, then set
vf
, and then setvx
to the subtraction result after. But in this casevf
andvx
are the same, so they'd be overwriting the borrow immediately.I was wondering which way is correct? Or if there even is a correct/standard way, when vf is both the destination for the result and the carry/borrow