Jump to content
IGNORED

Flags with Read/Write-only variables


Karl G

Recommended Posts

In the case of on-cart RAM with separate read and write addresses, if I write to one of these variables, do the appropriate flags still get set based on the changed value of the variable? E.g. if I decrement a write variable, will it still trigger the zero flag when that variable becomes zero?

 

Edit: now I'm wondering if INC or DEC would even work on these variables, since I assume it does both a read and a write "under the hood".

Link to comment
Share on other sites

The flags should be set appropriately, but the write back will not work as it is writing back to the read address. So you really have to do INC and DEC a longer way using this ram. I usually just load the value into the X, do a DEX, and write back.

 

There's more on instruction timings cycle by cycle here:

 

http://nesdev.com/6502_cpu.txt

 

 

If you take DEC absolute for example, it does this:

     Read-Modify-Write instructions (ASL, LSR, ROL, ROR, INC, DEC,
                                     SLO, SRE, RLA, RRA, ISB, DCP)

        #  address R/W description
       --- ------- --- ------------------------------------------
        1    PC     R  fetch opcode, increment PC
        2    PC     R  fetch low byte of address, increment PC
        3    PC     R  fetch high byte of address, increment PC
        4  address  R  read from effective address
        5  address  W  write the value back to effective address,
                       and do the operation on it
        6  address  W  write the new value to effective address

The effective address in this case is the one it reads from. So it tries to write back to the read address, and that won't work in this case.

  • Thanks 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...