8051 code to use R4(LSB) and R5(MSB) as a single 16bit counter, and increment the pair untill number is FFFFh

Logic is too simple. For better understanding i would suggest you somthing.
Use a scientific calci and in hex mode go on adding 0x01 each time. And then study my code. You will have a better understanding.
ORG 000h
MOV R4,#00h
MOV R5,#00h
         INC R4
         CJNE R4,#0FFh,main
         CJNE R5,#0FFh,end  ; Observe this line carefully and think after it 
         INC R5
         MOV R4,#00h
end: NOP
Enjoy coding…..XD

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger