We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
any body knows how to generate microsecond delay plz post all the code
DELAY: PUSH B ;push regista b PUSH R0 ;push regista r0 LOOP: MOV A, # 1000 ;load regista a with 100 DEC A ; decrament regista a CJNE A, # 0, LOOP ; goto loop if regista a is zero POP R1 ; pop regista ? RTS ; return to the code
Note The above code definitely does not work. I'm sure it was intended as a joke.
Please expand on this comment.
CJNE A, # 0, LOOP ; goto loop if regista a is zero
I think Jaff's routine is meant to be taken as a joke.
The interesting thing here is what to do to get 1us delay and what to do to get 12,000,000us delay, and how long 1us is for the specific processor when relating to clock freqiencies, cycle counts, ...
One can't do anything but get an infinite delay.
"One can't do anything but get an infinite delay."
Which may be preferable to pushing more than is popped and returning to oblivion.
I'm a bit against posting of intentionally broken code since there always exists people who think it is working.
In this case, there is mismatch of push count. And the popped register is different from the pushed. There is a question about regsiter size contra constant size, the loop reloads inside the loop, ... The problem is that the list may get a new thread sometime in the future linking to this code and asking why it doesn't work.
So, I suppose the mnemonic "RTS" stands for "Return To Somewhere"...?
Generally, I agree. I've marked the non-working code as such.
In the future, please mark code jokes so that a casual browser won't get confused and try to make it work.
Jon