SCF and CCF z80 instructions
SCF and CCF z80 instructions
Ok, so similar to the "there's a hover key in Jetpac??" revelation, where everyone rolls their eyes in a 'didn't you know that already?' sort of way...
...I've just read that the CCF instruction doesn't actually 'clear the carry flag', but toggles it.
Is this right? If so, does it mean that every time you want use the instruction to clear the carry flag, you would have to:
SCF
CCF
(P.S. If someone now tells me that I was wrong about SCF as well, I'm going to assume that I've entered the matrix...)
...I've just read that the CCF instruction doesn't actually 'clear the carry flag', but toggles it.
Is this right? If so, does it mean that every time you want use the instruction to clear the carry flag, you would have to:
SCF
CCF
(P.S. If someone now tells me that I was wrong about SCF as well, I'm going to assume that I've entered the matrix...)
My Speccy site: thirdharmoniser.com
Re: SCF and CCF z80 instructions
You are right, CCF switches CY flag. But to clear CY, you can use OR A, AND A. They affect Z flag too.
Proud owner of Didaktik M
Re: SCF and CCF z80 instructions
Wait... What hover key are you talking about ? Please, tell me you are joking.
There is no hover key in Jetpac. I KNOW there is no such key in Jetpac.
Proud owner of Didaktik M
- Lethargeek
- Manic Miner
- Posts: 743
- Joined: Wed Dec 11, 2019 6:47 am
Re: SCF and CCF z80 instructions
Re: SCF and CCF z80 instructions
I have no words. I will ve back later to ask what key it is then. But now I have to contemplate about fact I lived for more than thirty years in a lie.
Proud owner of Didaktik M
Re: SCF and CCF z80 instructions
To reset carry I just do 1 of these:
AND A
OR A
CP A
AND A
OR A
CP A
Re: SCF and CCF z80 instructions
For completeness: XOR A is reset A instead of long LD A,0
Coder of ZXOOM, Euphoria 2D, ZX Like Pascal, Russian Railway Magnate...
Re: SCF and CCF z80 instructions
I hit that exact issue when looking at the Z88DK display handling code just a few weeks ago. I was patiently corrected by the guys in the Z88DK support forum. Still felt a bit stupid though.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: SCF and CCF z80 instructions
Indeed. The first C stands for “complement,” not “clear.”
Last edited by Ast A. Moore on Tue May 26, 2020 3:49 pm, edited 1 time in total.
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Re: SCF and CCF z80 instructions
Ah, that's it... 'Complement'...
Always wondered why people were more inclined to do things like OR A, as it seemed to affect other stuff a bit more that could potentially give me future debugging headaches. But now I know...
Always wondered why people were more inclined to do things like OR A, as it seemed to affect other stuff a bit more that could potentially give me future debugging headaches. But now I know...
My Speccy site: thirdharmoniser.com
Re: SCF and CCF z80 instructions
AND A not only resets the flag Z, but is used instead CP 0
Coder of ZXOOM, Euphoria 2D, ZX Like Pascal, Russian Railway Magnate...