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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/24/00 10:05
Read: times


 
#1935 - RE: Figuring out a detail of DJNZ
Hi J.,

calculating the delay on 2 cascaded DJNZ loops
was a little bit tricky.
So the following macro can do it for every
value of cycles.
But on the Keil assembler only until 65535 cycles.

Peter



mdelay macro value, rx, ry ;cycle, used register(s)
local m____1
if( value < 5 )
rept value
nop
endm
elseif( value < 515 )
if nul &rx
mov r7, #low((value-1)/2)
djnz r7, $
else
mov rx, #low((value-1)/2)
djnz rx, $
endif
if((value and 1) = 0)
nop
endif
else
if nul &rx
mov r7, #high(value/2+253)
mov r6, #low(value/2-2)
m____1: djnz r6, m____1
djnz r7, m____1
else
mov rx, #high(value/2+253)
mov ry, #low(value/2-2)
m____1: djnz ry, m____1
djnz rx, m____1
endif
if(value and 1)
nop
endif
endif
endm


List of 6 messages in thread
TopicAuthorDate
Figuring out a detail of DJNZ            01/01/70 00:00      
RE: Figuring out a detail of DJNZ            01/01/70 00:00      
RE: Figuring out a detail of DJNZ            01/01/70 00:00      
RE: Figuring out a detail of DJNZ            01/01/70 00:00      
RE: Figuring out a detail of DJNZ            01/01/70 00:00      
RE: Figuring out a detail of DJNZ            01/01/70 00:00      

Back to Subject List