ASxxxx Assembler V02.10  (Motorola 6809), page 1.

MC6850 ACIA Control Routines

                              2 	.sbttl	MC6850 ACIA Control Routines
                              3 
                              4 	.module	acia
                              5 
ASxxxx Assembler V02.10  (Motorola 6809), page 2.

MC6850 ACIA Control Routines

                              6 	.include	/area.def/
                              1 	.sbttl	Area Definitions and Linking Order
                              2 
                              3 	; indexed label definitions
                              4 
                              5 	.area	PORTDATA	(ABS,OVR)
                              6 	.area	ACQBUFR		(ABS,OVR)
                              7 	.area	ACQVARBL	(ABS,OVR)
                              8 
                              9 	; data areas
                             10 
                             11 	.area	WORKPG		(REL,CON)
                             12 	.area	BUFSAV		(REL,CON)
                             13 	.area	ACQDATA		(REL,CON)
                             14 
                             15 	; program areas
                             16 
                             17 	.area	PGMSAV		(REL,CON)
                             18 	.area	ACIA		(REL,CON)
                             19 	.area	ACQ		(REL,CON)
                             20 	.area	HVCTRL		(REL,CON)
                             21 	.area	TERMIO		(REL,CON)
                             22 	.area	SELECT		(REL,CON)
                             23 	.area	SCREEN		(REL,CON)
                             24 	.area	SCRNUPDT	(REL,CON)
                             25 	.area	AICONV		(REL,CON)
                             26 	.area	MONDEB		(REL,CON)
                             27 	.area	IRQVEC		(REL,CON)
                             28 
                             29 	.sbttl	Default Direct Page
                             30 
                             31 	.setdp	0,PORTDATA
                             32 
ASxxxx Assembler V02.10  (Motorola 6809), page 3.

Default Direct Page

                              7 
                              8 	.area	ACIA
                              9 
                             10 	;	dlstat status register format
                             11 	;
                             12 	;	7-	interrupt request flag
                             13 	;	6-	parity error flag
                             14 	;	5-	rcvr overrun flag
                             15 	;	4-	framing error flag
                             16 	;	3-	/cts monitor
                             17 	;	2-	/dcd monitor
                             18 	;	1-	transmitter data register empty
                             19 	;	0-	rcvr data register full
                             20 	;	
                             21 	;
                             22 	;	dlcsr control register format
                             23 	;
                             24 	;	7-	rcvr interrupt enable
                             25 	;	6-	$ - transmitter function
                             26 	;	5-	$
                             27 	;		6 5	Function
                             28 	;		- -	--------
                             29 	;		0 0	/RTS = low,  xmtr interrupt disabled
                             30 	;		0 1	/RTS = low,  xmtr interrupt enabled
                             31 	;		1 0	/RTS = high, xmtr interrupt disabled
                             32 	;		1 1	/RTS = low,  xmtr interrupt disabled and
                             33 	;				     transmits a break
                             34 	;	4-	#
                             35 	;	3-	# - data encoding format
                             36 	;	2-	#
                             37 	;		4 3 2	Function
                             38 	;		- - -	--------
                             39 	;		0 0 0	7 Bits + Even Parity + 2 Stop Bits
                             40 	;		0 0 1	7 Bits + Odd  Parity + 2 Stop Bits
                             41 	;		0 1 0	7 Bits + Even Parity + 1 Stop Bit
                             42 	;		0 1 1	7 Bits + Even Parity + 1 Stop Bit
                             43 	;		1 0 0	8 Bits + 2 Stop Bits
                             44 	;		1 0 1	8 Bits + 1 Stop Bit
                             45 	;		1 1 0	8 Bits + Even Parity + 1 Stop Bits
                             46 	;		1 1 1	8 Bits + Even Parity + 1 Stop Bits
                             47 	;
                             48 	;	1-	% - counter divider select
                             49 	;	0-	%
                             50 	;		1 0	Function
                             51 	;		- -	--------
                             52 	;		0 0	Counter Divide Ratio 1
                             53 	;		0 1	Counter Divide Ratio 16
                             54 	;		1 0	Counter Divide Ratio 64
                             55 	;		1 1	Master Reset
                             56 	;
                             57 	;
                             58 
ASxxxx Assembler V02.10  (Motorola 6809), page 4.

ACIA Initialization

                             60 	.sbttl	ACIA Initialization
                             61 
                             62 	;	Enter with index register u = user's base data address
                             63 	;	Enter with register d = serial port number (0, 1, or 2)
                             64 
                             65 
   8B83                      66 ini$6850::
   8B83 34 26                67 	pshs	d,y		; save registers
                             68 
   8B85 34 06                69 	pshs	d
   8B87 1F 30                70 	tfr	u,d
   8B89 1F 8B                71 	tfr	a,dp		; direct page register
   8B8B 35 06                72 	puls	d
                             73 
   8B8D 58                   74 	aslb
   8B8E 4F                   75 	clra
   8B8F C3 7F 08             76 	addd	#sys$ser0	; hardware address of serial port 0
   8B92 DD 02                77 	std	*ser$port	; port status register address
   8B94 C3 00 01             78 	addd	#1
   8B97 DD 04                79 	std	*ser$port+2	; port rcvr/xmtr register address
                             80 
                             81 
   8B99 86 03                82 	lda	#3		; reset acia's
   8B9B A7 D9 00 02          83 	sta	[dlcsr,u]
                             84 
                             85 	;set acia for
                             86 	; 1.	8 bits data + no parity + 1 stop
                             87 	; 2.	64x clock from MC14441 baud rate generator
                             88 	; 3.	transmitter interrupt disable
                             89 	; 4.	receiver interrupt enable
                             90 	;
                             91 	;	   76543210
                             92 	;	   --------
   8B9F 86 96                93 	lda	#0b10010110
   8BA1 A7 D9 00 02          94 	sta	[dlcsr,u]	; load acia
   8BA5 97 15                95 	sta	*d.csr		; save setup
                             96 
   8BA7 31 C9 02 00          97 	leay	dlbuf,u		; preset host link buffer
   8BAB 10 9F 08             98 	sty	*dlqntr
   8BAE 10 9F 0A             99 	sty	*dlpntr
                            100 
   8BB1 31 A9 01 00         101 	leay	dllen,y		; preset end of buffer
   8BB5 10 9F 0C            102 	sty	*dlend
                            103 
   8BB8 31 C9 01 00         104 	leay	scbuf,u		; preset scan buffer
   8BBC 10 9F 0F            105 	sty	*scqntr
   8BBF 10 9F 11            106 	sty	*scpntr
                            107 
   8BC2 31 A9 01 00         108 	leay	sclen,y		; preset end of buffer
   8BC6 10 9F 13            109 	sty	*scend
                            110 
   8BC9 0F 06               111 	clr	*bfstat		; buffers are empty
                            112 
   8BCB 0F 17               113 	clr	*$dxonf		; clear special character
                            114 
   8BCD 86 01               115 	lda	#1		; xon/xoff enabled
ASxxxx Assembler V02.10  (Motorola 6809), page 5.

ACIA Initialization

   8BCF 97 16               116 	sta	*d.stat
                            117 
   8BD1 35 26               118 	puls	d,y		; restore registers
   8BD3 39                  119 	rts			; finished
