;
; Ex2.asm  ---- Example program 2 for the MiniDRAGON (c)2002, EVBplus.com
;		Written by Wayne Chu
;
;     Function:	Flash the word "HELP" on the 7-segment LED
;
#include        reg9s12.h
REGBLK:		equ	$0000
SPEED:		equ	$FFFF	; change this number to change flashing speed
;
STACK:	equ	$2000
;
        org     $2000		; program code
	jmp	start
segm_ptrn:						; segment pattern
	fcb     $3f,$06,$5b,$4f,$66,$6d,$7d,$07		; 0-7
;		 0,  1,  2,  3,  4,  5,  6,  7
        fcb     $7f,$6f,$77,$7c,$39,$5e,$79,$71		; 8-$0f
;		 8,  9,  A,  b,  C,  d,  E,  F
       	fcb     $3d,$76,$74,$1e,$38,$54,$63,$5c		; 10-17
;		 G,  H,  h,  J   L   n   o   o
       	fcb     $73,$50,$78,$3e,$1c,$6e,$08,$40		; 18-1f
;		 P,  r,  t,  U,  u   Y   -   -
       	fcb     $00,$01,$48,$41,$09,$49			; 20-23
;		blk, -,  =,  =,  =,  =
seven_segment:
	pshx
	pshb
	ldx	#segm_ptrn
	psha
	anda	#$3f
	tab
	abx
	ldaa	0,x		; get segment
	pulb
	andb	#$80		; add DP
	aba
	pulb
	pulx
	rts
;
display_data:
	fcb	$11,$0e,$14,$18,$20,$20   ; 7-segment code for "HELP  "
start:
	lds	#STACK
	ldx	#REGBLK
	ldaa	#$ff
	staa	ddrh,x		; make port H an output port

	ldx	#display_data
back:	pshx
	ldaa	0,x
	jsr	seven_segment
	ldx	#REGBLK
	staa 	pth,x
	jsr	delay_250ms
	pulx
	inx
	cpx	#display_data+6
	bne	back
	jmp	start
	
*
delay_250ms:
	ldab	#250
dly1:	ldy	#6000		; 6000 x 4 = 24,000 cycles = 1ms
dly:	dey			; 1 cycle
	bne	dly		; 3 cycles
	decb
	bne	dly1
	rts
  	end

