The F register unused bits

edited January 2009 in Development
I'm doing some reading and trying to organize my Spectrum ML apprenticeship and while looking in greater detail at the flag register one question popped.

Can I manipulate this register directly or make use of bits 3 and 5 indirectly? From all I can see from the instructions set, I can't. But those two unused bits surely look very tempting...
Post edited by rahtgaz on

Comments

  • edited January 2009
    You can set them to whatever you want with POP AF instruction, however most instructions modify them as they modify any other bits in the F register. So their use for anything practical is a bit limited.

    Patrik
  • edited January 2009
    But will those instructions also reset bits 3 and 5, the unused ones?

    Edit: I understand I can test this myself :) I just don't have the means right now but am curious still...

    EDIT 2: Nevermind. You answered this already. My apologies. Those bits get reset. A shame though.
  • edited January 2009
    Bits 3 and 5 are not unused, they are officially undocumented. Read this.
  • edited January 2009
    Oh! Thank you very much for that link.
  • edited January 2009
    Some things in that link (at the least undocumented flags after SCF and CCF) are certainly wrong. You'd be better off reading the links from the tech info wiki, in particular The Undocumented Z80 Documented. (The link from the wiki itself seems to be dead, but the file itself available here).
  • edited January 2009
    Bloody hell! I always forget the wiki.
    Thank you :)
  • edited January 2009
    (The link from the wiki itself seems to be dead, but the file itself available here).

    Looks like they replaced the page, and the link should now point here:
    http://www.myquest.nl/z80undocumented/

    PD: fixed in the wiki
  • edited January 2009
    But those two unused bits surely look very tempting...

    If I could give you some advice Rahtgaz, if you have just started to learn Z80 assmebler, don't learn about unused bits (which are however sometimes changed in complicated and indirect way), undocumented instructions and other esoteric stuff. You won't need it now IMHO. Z80 has a lot of registers to store your data (not like 6502 used in Commodore ;-))

    The most useful flags in F registers are carry and zero flag (maybe parity also can be useful). I never used any other of them.
  • edited January 2009
    You are absolutely right. I need to curb my impatience.

    You know, it's not being an easy task as I thought it would. I have used assembly before as a support for C and C++ programming. Although quite different naturally in form and meaning, it still spills over and confuses my mind. I often think the worst knowledge is some knowledge. It gets in the way when trying to learn something new, it makes you skip important information you would otherwise be willing to read through and it makes exceedingly hard the task of organizing your apprenticeship. A blank mind on the other hand is much better.

    Trying to blank my mind of any preconceived ideas and start from a clean slate is what I should do. But... not easy.
  • edited January 2009
    rahtgaz wrote: »
    A blank mind on the other hand is much better.
    So why isn't mel a genius coder?
    I wanna tell you a story 'bout a woman I know...
Sign In or Register to comment.