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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/11/05 01:32
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#87115 - tracing your code manually....
Responding to: ???'s previous message
is a useful exercise for short programs in assembly. Take a piece of paper and write a column heading for each of the registers that you use, in your case R0, R1, R2, R3, R4, P1, P2, TL0, Th0, DPTR, and ACC. Then mentally step through your code one instruction at a time and write down the contents of that register as a result of the execution of the instruction.

In the case of your code, the first time it goes through the loop
P1= <4400h> ( the "<4400h>" means "contents of location 4400h")
P2 = <4401h>
TL0 = <4200h>
TH0 = <4201h>

the next pass through the "again" loop results in:
P1= <4402h>
P2= <4403h>
TL0 = <4202h>
TH0 = <4203h>

Is this what you want? In order for you to have this work correctly for you, you would have had to have filled 322 bytes (161 x 2) with the timer counts starting at address 4400h and going up.

If you only intended the low and high bytes of the timer to be stored at 4200h and 4201h, respectively, and only reload the timer from these two locations, the problem is that the pointer for the high and low bytes are incremented by two on every pass through "again". There are a few ways you can fix this.

In the "again" routines, three instructions before the MOVC for that you use to look up the value for TL0, change the MOV DPH,R2 to MOV DPH,#0x42 and change the MOV DPL,R3 to MOV DPL,#0. An alternative is to remove the "MOV R2,DPH" and "MOV R3,DPL" instructions that follow the JNB, CLR TR0, CLR TF0 instructions after the label "here:".

I hope this helps - Bill

List of 41 messages in thread
TopicAuthorDate
constant delay-----problem            01/01/70 00:00      
   clarification needed            01/01/70 00:00      
   Timer 0 Mode 1            01/01/70 00:00      
       Timer 0 Mode 1            01/01/70 00:00      
         yes 16-bit mode            01/01/70 00:00      
            show the code            01/01/70 00:00      
               code            01/01/70 00:00      
                  check            01/01/70 00:00      
                  be sure your problem easily solved            01/01/70 00:00      
                     no i am using a trainer kit            01/01/70 00:00      
                        re:no i am using a trainer kit            01/01/70 00:00      
                           code again            01/01/70 00:00      
                              direct vs. immediate addressing            01/01/70 00:00      
                              be sure your problem easily solved again            01/01/70 00:00      
                                 i tried ur code            01/01/70 00:00      
                                    Please be specific!            01/01/70 00:00      
                                       oh YOU            01/01/70 00:00      
                                       re:jan            01/01/70 00:00      
                                          hello            01/01/70 00:00      
                                             use MOVX @Ri            01/01/70 00:00      
                                                8-BIT MEMORY I/O ?            01/01/70 00:00      
                                                   can't be done            01/01/70 00:00      
                                                   can be done            01/01/70 00:00      
                                                      i am asking 8-bit I/O            01/01/70 00:00      
                                                         If you read Erik's answer            01/01/70 00:00      
                                                         now you lost me            01/01/70 00:00      
                                                            Guessing what he means            01/01/70 00:00      
                                                         Set P2            01/01/70 00:00      
                                                            Write P2 once            01/01/70 00:00      
                                       tested code and pulses            01/01/70 00:00      
                                          Missing Picture            01/01/70 00:00      
                                          picture again            01/01/70 00:00      
                                             Re:Picture again            01/01/70 00:00      
                                          picture and code posted again            01/01/70 00:00      
                                    Have you Tried a fixed value?            01/01/70 00:00      
                     no i am using a trainer kit            01/01/70 00:00      
                        Divide and conquer            01/01/70 00:00      
                           And not writing them...            01/01/70 00:00      
               want a program of timer            01/01/70 00:00      
   tracing your code manually....            01/01/70 00:00      
   thanks            01/01/70 00:00      

Back to Subject List