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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/24/06 04:26
Read: times


 
#116999 - Comments
Responding to: ???'s previous message

In your DELAYMS subroutine, how did you come up with the number of 1027 cycles? Remember that 0xff does not equal 256! However, this does not explain the time difference.


MOV R7,#00H ;put value of 0 in register R7 
LOOPA: 
INC R7 ;increase R7 by one (R7 = R7 +1) 
MOV A,R7 ;move value in R7 to Accumlator (also known as A) 
CJNE A,#0FFH,LOOPA ;compare A to FF hex (256). If not equal go to LOOPA 
RET ;return to the point that this routine was called from 



Also, your comments are useless - INC R7; increase R7 by one!!!!!! That's pretty obvious isn't it? Comments like this are useless, comments must tell us something we don't know are aren't obvious.

Also, if you write something like:

clr A
loopa:
djnz a,loopa

makes your code simpler and you can add nops in the loop to pad it out. At least this way you're not needlessly using a register to hold a value. Also, it is usual to count down and test for zero - mainly as there's an instruction for it :- djnz (decrement and jump if not zero) and because the cpu hardware can test for zero easier than testing for another number.


With the code from LOOPB, what is R6 initially loaded with?

So is it your code or the simulator that is wrong? Have you tried running your code in a real cpu?




List of 8 messages in thread
TopicAuthorDate
wrong calculation of timer delay ...            01/01/70 00:00      
   Comments            01/01/70 00:00      
   Russel Sir ... have a look again pl            01/01/70 00:00      
      Yes I'm looking            01/01/70 00:00      
         Russell Sir ... once again have a look            01/01/70 00:00      
            I'm still looking!            01/01/70 00:00      
   Try this:            01/01/70 00:00      
   Sometimes a Calculator helps            01/01/70 00:00      

Back to Subject List