; ***************************************************
;   6801 slot control
;6 April 1982 2:51 pm PST (Tuesday)
;****************************************************
;ram equates
;****************************************************
.getnolist "m6801predefs.sr"
datadir1 = 00000 ;  data direction register 1
datadir2 = 00001 ;  data direction register 2
ipoprt1  = 00002 ;  ipo port 1 
ipoprt2  = 00003 ;  ipo port 2
datadir3 = 00004 ;  data direction register 3(not used)
datadir4 = 00005 ;  data direction register 4(not used)
ipoprt3  = 00006 ;  ipo port 3(not used) 
ipoprt4  = 00007 ;  ipo port 4(not used)
tcsr     = 00008 ; timer control status register
cntrhi   = 00009 ; counter high byte
cntrlo   = 0000a ; counter low byte
outcmphi = 0000b ; output compare high byte
outcmplo = 0000c ; output compare low byte
inpcaphi = 0000d ; input capture high byte
inpcaplo = 0000e ; input capture low byte
ipoprt3cs= 0000f ; ipo port 3 control,status register
serate   = 00010 ; serial rate and mode register 
sercon   = 00011 ; serial control and status register
serrx    = 00012 ; serial receiver data register
sertx    = 00013 ; serial transmit data register
ramcon   = 00014 ; rampeprom control register
; ***************************************************
; 15 to 1f hex reserved (don't ask)
; ***************************************************
; interupt vector equates
; ***************************************************
restrtms = 0fffe
restrtls = 0ffff ; restart vector
nmims    = 0fffc 
nmils    = 0fffd ; nonmaskable interupt
swims    = 0fffa
swils    = 0fffb ; software interupt
irq1ms   = 0fff8 
irq1ls   = 0fff9 ; irq1 interupt
tcapms   = 0fff6
tcapls   = 0fff7 ; timer input capture or irq 2 interupt
tcompms  = 0fff4 
tcompls  = 0fff5 ; timer output compare or irq 2 interupt
tovms    = 0fff2 
tovls    = 0fff3 ; timer overflow or irq 2 interupt 
serinms  = 0fff0 
serinls  = 0fff1 ; serial ipo interupt
;****************************************************
; INIT the machine
;****************************************************
outchar  = 00080 ; output char address
wait     = 00400  ; counter wait time
.loc 0f800
;****************************************************
; start 
;****************************************************
start :
ldaai 009 ; 
staae serate ;     set rate to 9600 baud CC1 1 CC0 0 S1 0 S0 1  
ldaai 00a ; 
staae sercon ;        set tx and rx enable
Init1 :
	ldaai 0a0 ;
	staae outchar ;
start1 :
	ldaae outchar ;
	subai 0c8 ;
	beq Init1 ;
	ldaae outchar ;
	addai 01 ;
	staae outchar ;
output1 :
	ldabe sercon ; 
	staae sertx ;        send letter 
;	
; 	TIMER ROUTINE
		lddi wait ; load D with wait count
		addde cntrhi ; add D to counter
		clre tcsr ; clear timer control status reg
		stde outcmphi ; set output compare
		ldaai 040 ; 
;
		time1 :
			bitae tcsr ; now wait for output compare flag
			beq time1 ; not yet
; 	END TIMER
;
jmp start1 ; back to send the next charter
;
; 	END PROGRAM
;
; 	INTERRUPT VECTORS
;
.loc 0fffe
0f8
00
;
;