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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/11/04 23:31
Read: times


 
Msg Score: 0
 -1 Gimmee Code
 +1 Underrated
#75774 - RE: ASM routines libraries?
Responding to: ???'s previous message
Hello Bartosz,

Math wise the 8051 software routines have been beat to
death BUT there is still lots to be done in ASSEMBLY.

One of the routines I was looking for recently and had
to write myself was a "month/day/year" to be part of the
real time clock. Below is that routine.

I don't think we will ever solve this problem but at least it can be thought thru a little.

Regards,

Charles Bannister


.EQU    MONTH1,   0x3F  	;; Real Time Clock Month variable
.EQU    MONTH1BCD, 0x40  	;; Real Time Clock Month variable
.EQU    DAY1,     0x41  	;; Real Time Clock Day variable 
.EQU    DAY1BCD,  0x42  	;; Real Time Clock Day variable 
.EQU    YEAR1,    0x43  	;; Real Time Clock Year variable 
.EQU    YEAR1BCD, 0x44  	;; Real Time Clock Year variable 
RTC_A:
        ...
        ...
        ...
       lcall  mmddyy1  	       ;; increment mm/dd/yy as needed
RTC_D: POP     PSW
       POP     ACC
       RETI

;;*********************************************************************
;;	Increment day, month and year variables within real time clock
;;	Take into account leap years
;;	.EQU    MONTH1,   0x3F  	;; Real Time Clock Month variable
;;	.EQU    MONTH1BCD, 0x40  	;; Real Time Clock Month variable
;;	.EQU    DAY1,     0x41  	;; Real Time Clock Day variable 
;;	.EQU    DAY1BCD,  0x42  	;; Real Time Clock Day variable 
;;	.EQU    YEAR1,    0x43  	;; Real Time Clock Year variable 
;;	.EQU    YEAR1BCD, 0x44  	;; Real Time Clock Year variable
;;*********************************************************************

mmddyy1:
       	inc    	DAY1		;; increment present day
       	MOV    	A, DAY1BCD       ;; INCREMENT DAY BCD
       	ADD    	A, #0x01
       	DA     	A
       	MOV    	DAY1BCD, A       	
	mov	a, 	month1	;; get current month into accumulator
;;	CJNE	A, 	LEAPYEAR,	mmddyy??	;; process leap year here
       	mov	dptr, 	#months2	;; 
       	movc	a, 	@a+dptr	;; get amount of days this month into acc
       	cjne	a, day1, mmddyy5	
	mov	day1, 	#0x01	;; start new month at 1st
	mov	DAY1BCD, #0x01	;; update day bcd value
	inc	month1		;; >
	MOV    	A,MONTH1BCD     ;; INCREMENT MONTH BCD
       	ADD    	A,#0x01
       	DA     	A
       	MOV    	MONTH1BCD,A
       	mov	a, month1       	
	cjne    a, #13, mmddyy5
	mov	month1, #0x01	;; start new year with 1st month
	mov	MONTH1BCD, #0x01 ;; update day bcd value	
	inc	year1
	MOV    	A,YEAR1BCD     	;; INCREMENT YEAR BCD
       	ADD    	A,#0x01
       	DA     	A
       	MOV    	YEAR1BCD,A       	
mmddyy5:   ret

months2: 	.DB	00	; Fence Post
		.DB     32	; January
		.DB	29	; February
		.DB	32	; March
		.DB	31	; April
		.DB	32	; May
		.DB	31	; June
		.DB	32	; July
		.DB	32	; August
		.DB	31	; September
		.DB	32	; October
		.DB	31	; November
		.DB	32	; December



List of 9 messages in thread
TopicAuthorDate
ASM routines libraries?            01/01/70 00:00      
   RE: ASM routines libraries?            01/01/70 00:00      
   RE: ASM routines libraries?            01/01/70 00:00      
      RE: ASM routines libraries?            01/01/70 00:00      
         RE: ASM routines libraries?            01/01/70 00:00      
      RE: ASM routines libraries?            01/01/70 00:00      
   RE: ASM routines libraries?            01/01/70 00:00      
      RE: ASM routines libraries?            01/01/70 00:00      
   RE: ASM routines libraries?            01/01/70 00:00      

Back to Subject List