The logic is easy. Go on decrementing LSB . Let me consider an example.
let the number be 0xffff . this means 0xff in both R4 and R5 registers. go on decrementing R4(LSB).once it reaches 0x00,then decrement R5(MSB) which makes it 0xfe in R5. Then reset the value of R4 to 0xff and follow the same process…
The following code is as follows :
MOV R4,#0FFh ;you can store any number u like
DJNZ R5,end ;There is a specific reason for placing it here *
So why did i place ‘ DJNZ R5,end ‘ there, just think,then you go on decrementing msb and it becomes 0x00 , u still have 0xff in lsb. So you still have to execute another loop .