Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/02/99 23:10
Read: times


 
#792 - Use DJNZ instead of CJNE
Craig's answer is 100% good and correct. I would just like to add
my 2 cents worth to make a more efficient coding.

I suggest using DJNZ since it does not affect the Carry Flag and it
replaces both INC & CJNE instructions (for a savings of 2 bytes!)
Believe me, I used to have to cram code! not much fun.

timer isp:
MOV TH0,#... (the usual reloading of the timer)
MOV TL0,#..

DJNZ SomeCounter, timer-isp-exit
MOV SomeCounter, #60 ;reload the counter

PUSH PSW
;& push what ever else needs to be pushed around

; Do what ever code needed for every 3 seconds...

;pop all that's been pushed OR ELSE!!!!
POP PSW

timer-isp-exit: RETI ;return from interrupt


Notice the Push and Pop only happens if the 3 second back ground
code needs to execute... further, push and pop may not even be
needed if the code doesn't affect any status flags or accumulator... for instance what if only a bit in ram needs to be set.

My 2 cents worth,
Josh.


No replies in thread

Back to Subject List