Files
SyncHome/trunk/workspace/AVR-Computer/AVR65C02/SBC2OS/USART0.asm

104 lines
3.3 KiB
NASM
Raw Normal View History

2023-03-13 08:36:51 +00:00
; ----------------- assembly instructions ----------------------------
;
; this is a subroutine library only
; it must be included in an executable source file
;
;
;*** I/O Locations *******************************
; define the i/o address of the ACIA1 chip
;*** 6551 CIA ************************
UCSR0A = $3fc0
UCSR0B = $3fc1
UCSR0C = $3fc2
UDR0 = $3fc6
;
;***********************************************************************
; 6551 I/O Support Routines
;
ACIA1_init LDX #<ACIA1_Input ; set up RAM vectors for
LDA #>ACIA1_Input ; Input, Output, and Scan
TAY ; Routines
EOR #$A5 ;
sta ChrInVect+2 ;
sty ChrInVect+1 ;
stx ChrInVect ;
LDX #<ACIA1_Scan ;
LDA #>ACIA1_Scan ;
TAY ;
EOR #$A5 ;
sta ScanInVect+2 ;
sty ScanInVect+1 ;
stx ScanInVect ;
LDX #<ACIA1_Output ;
LDA #>ACIA1_Output ;
TAY ;
EOR #$A5 ;
sta ChrOutVect+2 ;
sty ChrOutVect+1 ;
stx ChrOutVect ;
lda #<ACIA1_scan ; setup BASIC vectors
sta VEC_IN
lda #>ACIA1_scan ; BASIC's chr input
sta VEC_IN+1
lda #<ACIA1_Output
sta VEC_OUT
lda #>ACIA1_Output ; BASIC's chr output
sta VEC_OUT+1
lda #<Psave
sta VEC_SV
lda #>Psave ; SAVE cmd
sta VEC_SV+1
lda #<pload
sta VEC_LD
lda #>pload ; LOAD cmd
sta VEC_LD+1
rts ; done
;
; input chr from ACIA1 (waiting)
;
cin
ACIA1_Input
lda UCSR0A ; Serial port status
and #$80 ; RXC0 bit
beq ACIA1_Input ; no char to get
lda UDR0 ; get chr
RTS ;
;
; non-waiting get character routine
;
CSCAN
ACIA1_Scan clc
lda UCSR0A ; Serial port status
and #$80 ; RXC0 bit
beq ACIA1_scan2
lda UDR0 ; get chr
sec
ACIA1_scan2 rts
;
; output to OutPut Port
;
cout
ACIA1_Output PHA ; save registers
ACIA1_Out1 lda UCSR0A ; Serial port status
and #$20 ; UDRE0 bit
beq ACIA1_Out1 ; no
PLA ; get chr
sta UDR0 ; put character to Port
RTS ; done
CROUT lda #$0d
jsr cout
lda #$0a
bra cout
cbrk jsr cscan
bcc cbrk2
cmp #$03
beq cbrk2
clc
cbrk2 rts
;
;end of file