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...
?B_BANK&N: CLR A ORL A, ?B_CURRENTBANK ANL A,#?B_MASK CJNE A,#BANK&N,XLABEL ; etc...
hi, ORL A, ?B_CURRENTBANK is not R-M-W instruction because destination is not a port but the acc. Good days!
If that's the case, then it's necessary to store a copy of the current bank somewhere else. But, back to my original point, is the L51_BANK code incorrect?
Seems so. In fact, if current loading of P1 is not so much (for example, if 74N244/245 buffer used) then it is still correct because you will read value from pin same as from latch. Anyway, some MCU have different input/output schemes and reading from pin which previously was set to 0, does not guarantee same value back. Yeah, seems it is error really. Good days!
View all questions in Keil forum