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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/31/05 10:50
Read: times


 
#98504 - why +1?
Responding to: ???'s previous message
hi,
Jon Ward said:

inc r7
inc r6
Of course, the loop label is branched to 1+r6:r7 times.


Jon, I think this solution is enough. You should send it to Erik instead public here (=
By the way, this solution does produce not +1 but exactly required number of itterations. Next test shows it:
START:
	MOV	R0,#0
	MOV	R1,#0
	MOV	R7,#LOW(value)
	MOV	R6,#HIGH(value)
	CALL	LOOP
	JMP	START

LOOP:
	INC	R6
	INC	R7
	JMP	LOOP_B
LOOP_A:
	INC	R0
	CJNE	R0,#0,LOOP_B
	INC	R1
LOOP_B:
	DJNZ	R7,LOOP_A
	DJNZ	R6,LOOP_A
	RET
Here R1:R0 collect total number of itterations. You may test this code and see that after return from subroutine LOOP the registers will contain exactly the number which was loaded into R6:R7 before call it.

Regards,
Oleg

List of 32 messages in thread
TopicAuthorDate
This weeks puzzle            01/01/70 00:00      
   This weeks Puzzle            01/01/70 00:00      
   its D-J-N-Z not J-N-Z-D            01/01/70 00:00      
   inc r6            01/01/70 00:00      
      Fails if R6 is Zero            01/01/70 00:00      
   in my point of view :            01/01/70 00:00      
   not correct question            01/01/70 00:00      
   LSB count value lost in first count            01/01/70 00:00      
   Setup R6/R7            01/01/70 00:00      
      why +1?            01/01/70 00:00      
   this is no fun            01/01/70 00:00      
      Thread closed            01/01/70 00:00      
   It is easy Erik!            01/01/70 00:00      
   Ok, you blew it            01/01/70 00:00      
      Not our mistake...            01/01/70 00:00      
         which was done again and again for the i            01/01/70 00:00      
            which the most of might never have noti            01/01/70 00:00      
               Well...            01/01/70 00:00      
                  well,well            01/01/70 00:00      
                  The explanation is:            01/01/70 00:00      
                     Never the intention            01/01/70 00:00      
                     Thoughts            01/01/70 00:00      
                        I really do not know            01/01/70 00:00      
                        discussion after the solution            01/01/70 00:00      
                           Agree            01/01/70 00:00      
                        Please, no sophisticated forum rules!            01/01/70 00:00      
                           agree            01/01/70 00:00      
      Never mind            01/01/70 00:00      
   My old solution:            01/01/70 00:00      
      constant            01/01/70 00:00      
         Re: constant            01/01/70 00:00      
   Re-Cap            01/01/70 00:00      

Back to Subject List