AS11, an absolute assembler for Motorola MCU's, version 1.2e

                        *
                        * 5s_delay.asm  5 second delay timer for FOX11 board
                        *		with BUFFALO monitor, (c)2003, EVBplus.com
                        *		Written by Wayne Chu
                        *
                        *     Function:	5 second delay routine using output comparator OC2
                        *		The PB5 LED will be turned on immediately after running
                        *		the program. It will be turned off after 5 second delay. 
                        *		Change the DELAY_TIME to 18000 will delay 3 minutes
                        *
0040                    DB6:		equ	$40
0020                    PB5:		equ	$20
00bf                    NOTDB6		equ	$BF
1404                    portb:  	equ     $1404 		; 74HC273 latch
                        *
                        *
00c4                            ORG  $c4
                        *** Vector jump table for BUFFALO monitor ***
00c4                    JSCI    RMB   3
00c7                    JSPI    RMB   3
00ca                    JPAIE   RMB   3
00cd                    JPAO    RMB   3
00d0                    JTOF    RMB   3
00d3                    JTOC5   RMB   3
00d6                    JTOC4   RMB   3
00d9                    JTOC3   RMB   3
00dc                    JTOC2   RMB   3
00df                    JTOC1   RMB   3
00e2                    JTIC3   RMB   3
00e5                    JTIC2   RMB   3
00e8                    JTIC1   RMB   3
00eb                    JRTI    RMB   3
00ee                    JIRQ    RMB   3
00f1                    JXIRQ   RMB   3
00f4                    JSWI    RMB   3
00f7                    JILLOP  RMB   3
00fa                    JCOP    RMB   3
00fd                    JCLM    RMB   3
                        
e02b                    BUFFALO_mon:	equ	$e02b		; BUFFALO re-entry address
                        *
                        * 68HC11 control register address is the offset address from the
                        * register base address $1000, so index addressing mode can also be used.
                        *
0018                    toc2:   equ     $0018
0022                    tmsk1:	equ	$0022
0023                    tflg1:	equ	$0023	
1000                    REGBLK:	equ	$1000
                        
                        *
                        *DELAY_TIME:	equ	18000	; 18000 X 10 ms= 180 sec = 3 min
01f4                    DELAY_TIME:	equ	500	; 500 X 10 ms= 5 sec
4e20                    TB10MS:		equ	20000	; time base of 20,000 instruction cycles
                        *				; = 20,000 x 0.5us = 10ms at 8MHz
                        
0000                    	org	$00
                        *
0000                    flag_5s:	rmb	1
0001                    cnt_5s:		rmb	2
0003                    d10ms_flag:	rmb	1
                        *
8fff                    STACK:	equ	$8FFF
                        *
                        *
                        	
d000                    	org	$D000		; user program starts at $D000
                        	
d000                    start:
d000 8e 8f ff           	lds	#STACK
d003 ce 10 00           	ldx	#REGBLK
d006 86 40              	ldaa	#DB6	 
d008 a7 22              	staa	tmsk1,x
d00a 0e                 	cli
                        *
d00b 86 20              	ldaa	#PB5
d00d b7 14 04           	staa	portb		; turn on LED PB0
d010 bd d0 1b           	jsr	delay_5s
d013 86 80              	ldaa	#$80
d015 b7 14 04           	staa	portb		; turn off LED PB0
d018 7e e0 2b           	jmp	BUFFALO_mon     ; re-enter BUFFALO monitor
                        *
                        *
d01b                    delay_5s:
d01b 7f 00 01           	clr	cnt_5s
d01e 7f 00 02           	clr	cnt_5s+1
d021 7f 00 00           	clr	flag_5s
d024 96 00              delay:	ldaa	flag_5s
d026 27 fc              	beq	delay
d028 39                 	rts
                        *
d029                    tmr6oc2:
d029 de 01              	ldx	cnt_5s
d02b 08                 	inx
d02c df 01              	stx	cnt_5s
d02e 8c 01 f4           	cpx	#DELAY_TIME
d031 26 0a              	bne	tmr6
d033 7f 00 01           	clr	cnt_5s
d036 7f 00 02           	clr	cnt_5s+1
d039 86 01              	ldaa	#1
d03b 97 00              	staa	flag_5s
                        
                        * in an interrupt servicing routine the x register will be saved automatically
                        * the rti instruction will pop the x register off stack.
                        *
d03d                    tmr6:	
d03d ce 10 00           	ldx	#REGBLK	
d040 cc 4e 20           	ldd	#TB10MS		; reload the count for 10 ms time base
d043 e3 18              	addd	toc2,x
d045 ed 18              	std	toc2,x
d047 1d 23 bf           	bclr	tflg1,x NOTDB6
d04a 3b                 	rti
                        *
                        	
00dc                    	org	JTOC2		; BUFFALO RAM vector for OC2
00dc 7e d0 29           	jmp	tmr6oc2		; jmp to OC2 service routine
                        
                        	end
                        
                        
                        

Executed: Sat Dec 31 02:23:56 2005
Total cycles: 138, Total bytes: 78
Total errors: 0, Total warnings: 0
