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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/22/05 14:38
Read: times


 
#92161 - Examining the assembly
Responding to: ???'s previous message
When in doubt, it is not necessary to rewrite in asm, just have a look at the asm generated by the compiler. I have found many reasons that my C did not work by looking at the assembler and then slapping my forehead, saying Oh ....


I don't yet know if my C is faulty, but the below sequence looks a little strange to me, in respect to the clearing of the variable "c", which is - as far as I can tell, used nowhere, neither in this snippet nor anywhere below it.

Or is the "c" the carry-bit?

--------------------------------------
;     while(1)
			; SOURCE LINE # 58
;     {
			; SOURCE LINE # 59
;         P1 ^= 0x10;                     // Toggles every 8th usec, 125 kHz
			; SOURCE LINE # 60
	XRL  	P1,#010H
; 
;         if(timer0_tick >= 14)           /* Timer input = OSC/12 = 921.600 kHz */
			; SOURCE LINE # 62
	MOV  	DPTR,#timer0_tick
	MOVX 	A,@DPTR
	CLR  	C
	XRL  	A,#080H
	SUBB 	A,#08EH
	JC   	?C0006
;         {                               /* => 14 overflows per second         */
			; SOURCE LINE # 63
;             secs++; 
			; SOURCE LINE # 64
	MOV  	DPTR,#secs+01H
	MOVX 	A,@DPTR
	INC  	A
	MOVX 	@DPTR,A
	JNZ  	?C0011
	MOV  	DPTR,#secs
	MOVX 	A,@DPTR
	INC  	A
	MOVX 	@DPTR,A
?C0011:
--------------------------------------

Why would we want to only continue mangling with "secs" if the accumulator is not zero? Incrementing it makes it "never zero", doesn't it? But then again - why does this piece of code try to access "secs" at an address 1 bit higher than it ought to be (#secs+01h)?

--------------------------------------
;             timer0_tick = 0; 
			; SOURCE LINE # 65
	CLR  	A
	MOV  	DPTR,#timer0_tick
	MOVX 	@DPTR,A
;             P1 ^= 0x01; 
			; SOURCE LINE # 66
	XRL  	P1,#01H
;         }
			; SOURCE LINE # 67
?C0006:
--------------------------------------

I understand the last part and it seems logical - resetting the accumulator to zero, moving the address of "timer0_tick" into a pointer and then moving the contents of the accumulator to the gathered address.

Or'ing P1 with 01 hex toggles P1.0.

/Thomas

List of 33 messages in thread
TopicAuthorDate
DS89C450 / uVision2, timer0 trouble            01/01/70 00:00      
   perhaps            01/01/70 00:00      
      nope - didn't work            01/01/70 00:00      
   never used Dallas but            01/01/70 00:00      
      I just followed orders            01/01/70 00:00      
         link, please            01/01/70 00:00      
            my apologies            01/01/70 00:00      
               try system clock            01/01/70 00:00      
                  The system clock vs. External Oscillator            01/01/70 00:00      
                     Try >=?            01/01/70 00:00      
                        good idea            01/01/70 00:00      
                           probably a watchdog or such            01/01/70 00:00      
                              about the beer ...            01/01/70 00:00      
                                 reason            01/01/70 00:00      
                                    puzzled by the simplicity            01/01/70 00:00      
                                       It's getting late in Denmark            01/01/70 00:00      
                                          the Thomas Skyt late night show ...            01/01/70 00:00      
                                             kiss            01/01/70 00:00      
                                                KISS/2            01/01/70 00:00      
   A variety of thoughts            01/01/70 00:00      
      A variety of answers            01/01/70 00:00      
         Thoughts for variety of answers            01/01/70 00:00      
            sfr's            01/01/70 00:00      
            the watchdog            01/01/70 00:00      
               The watchdog, timed access, and errata            01/01/70 00:00      
                  setting the OCR to disable the watchdog            01/01/70 00:00      
                     Timed access, take 2            01/01/70 00:00      
                        unnecessary excersize            01/01/70 00:00      
                           The watchdog, take 3            01/01/70 00:00      
                              when in doubt            01/01/70 00:00      
                                 Examining the assembly            01/01/70 00:00      
                                    get out of there            01/01/70 00:00      
                                       I got out, found a solution            01/01/70 00:00      

Back to Subject List