Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; 8080 + 8251 KICK START
- ;
- USRTRD EQU 11111110B ;8251 data register
- USRTRC EQU 11111111B ;8251 control register
- ;
- ; RESET VECTOR
- ORG 0000H
- SYSINI:
- LXI SP,0FEFCH ;setup stack
- MVI A,00H
- STA RBFCNT ;setup ring buffer
- STA RBFRDP
- STA RBFWTP
- OUT USRTRC ;setup 8251
- OUT USRTRC
- OUT USRTRC
- MVI A,01000000B
- OUT USRTRC
- MVI A,01001110B
- OUT USRTRC
- MVI A,00110111B
- OUT USRTRC
- EI
- JMP MAIN
- ;
- ; A -> 8251
- PUTCHR:
- PUSH PSW
- PCLOP1: IN USRTRC
- ANI 00000001B ;transmitter ready?
- JZ PCLOP1
- POP PSW
- OUT USRTRD ;transmit
- RET
- ;
- ; RST7 VECTOR
- ORG 0038H
- ;
- ; 8251 -> BUFFER
- DI
- PUSH PSW
- PUSH B
- PUSH D
- PUSH H
- IN USRTRC
- ANI 00000010B ;receiver ready?
- JZ INTEXT
- IN USRTRD ;receive
- MOV D,A ;data -> reg.byte.D
- LDA RBFCNT ;get data count
- CPI 0FFH ;buffer full?
- JZ INTEXT
- INR A ;increment data count
- STA RBFCNT
- LDA RBFWTP ;get write point
- MOV C,A ;write point low -> reg.byte.C
- MVI B,00H ;write point high -> reg.byte.B
- LXI H,RECBUF ;buffer top -> HL
- DAD B ;HL + BC -> HL
- MOV M,D ;reg.byte.D -> (HL)
- INR A ;increment write point
- STA RBFWTP
- INTEXT: POP H
- POP D
- POP B
- POP PSW
- EI
- RET
- ;
- ; BUFER -> A
- GETCHR:
- PUSH B
- PUSH D
- PUSH H
- GCLOP1: LDA RBFCNT ;get data count
- CPI 00H ;Is there data?
- JZ GCLOP1
- DI
- DCR A ;decrement data count
- STA RBFCNT
- LDA RBFRDP ;get read point
- MOV C,A ;read point low -> reg.byte.C
- MVI B,00H ;read point high -> reg.byte.B
- LXI H,RECBUF ;buffer top -> HL
- DAD B ;HL + BC -> HL
- MOV D,M ;(HL) -> reg.byte.D
- INR A ;increment read point
- STA RBFRDP
- MOV A,D ;data -> Acc
- EI
- POP H
- POP D
- POP B
- RET
- ;
- MAIN:
- MVI A,'A' ;print 'A'
- CALL PUTCHR
- MVI A,'B' ;print 'B'
- CALL PUTCHR
- MVI A,'C' ;print 'C'
- CALL PUTCHR
- MVI A,13 ;CR, LF
- CALL PUTCHR
- MVI A,10
- CALL PUTCHR
- LOOP:
- CALL GETCHR ;key-in and echo
- CALL PUTCHR
- JMP LOOP
- ;
- ; SYSTEM PARAMETERS
- ORG 0FEFDH
- RBFCNT DS 01H ;data count
- RBFRDP DS 01H ;read point
- RBFWTP DS 01H ;write point
- RECBUF DS 100H ;buffer
- ;
- END 0000H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement