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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/14/07 12:41
Modified:
  06/14/07 12:42

Read: times


 
#140752 - Comparing data with cjne...
Long story short... I'm trying to write some code to compare 2 BCD dates in memory, one stored at 50h for 6 bytes, and one stored at 60h for 6 bytes. I want to compare year first, then month and so on. If the last used date is later than the date now then I know the RTC has been tampered with.

This was the best I could come up with, but it's ugly, and I'd rather it was a loop. Problem is, cjne only works with direct addresses or immediate data.

Any thoughts?

    
    Date DATA    50h	     ;Date now
    Last_Used_Date DATA	60h  ;Date application was last used
...
...
    setb c	;Kill box if both dates are the same
    mov R0, #Date ;Location of current date
    mov a, R0
    add a, #5	;Location of current YY
    mov R0, a
    mov a, @R0
    cjne a, 65h, Date_Diff	;65h is where old date YY is stored
    dec R0
    mov a, @R0
    cjne a, 64h, Date_Diff	;64h is where old date MM is stored
    dec R0
    mov a, @R0
    cjne a, 63h, Date_Diff	;65h is where old date DD is stored
    dec R0
    mov a, @R0
    cjne a, 62h, Date_Diff	;65h is where old date hh is stored
    dec R0
    mov a, @R0
    cjne a, 61h, Date_Diff	;65h is where old date mm is stored
    dec R0
    mov a, @R0
    cjne a, 60h, Date_Diff	;65h is where old date ss is stored

    
Date_Diff:
    
	jc KILLIT
    
LATER_THAN_LAST_USED:



List of 10 messages in thread
TopicAuthorDate
Comparing data with cjne...            01/01/70 00:00      
   cjne a,direct,displacement            01/01/70 00:00      
      Thanks            01/01/70 00:00      
         it does            01/01/70 00:00      
            Indeed            01/01/70 00:00      
               Alternative solution            01/01/70 00:00      
                  Sure?            01/01/70 00:00      
                     Surely not.            01/01/70 00:00      
                  That`s wrong            01/01/70 00:00      
         you could as well use also direct RAM            01/01/70 00:00      

Back to Subject List