This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bank switch code reads port, not latch.

The sample L51_BANK.A51 module uses the following code to determine the current bank:

?B_BANK&N:
                MOV     A,?B_CURRENTBANK
                ANL     A,#?B_MASK
                CJNE    A,#BANK&N,XLABEL

                ; etc...

For 8051 compatible devices, shouldn't it use a R-M-W instruction, so that it reads the latch, rather than the port? Something like:

?B_BANK&N:
                CLR     A
                ORL     A, ?B_CURRENTBANK
                ANL     A,#?B_MASK
                CJNE    A,#BANK&N,XLABEL

                ; etc...

Parents Reply Children
  • I was investigating this as a potential cause of a problem I was having. It turned out to be hardware.

    Thanks for the replies.

    Plus it sounds like it would be one hell of a subtle bug if your bank-switch hardware / port setup meant that it was possible to read the "wrong" value.