forked from jmatzen/leventhal-6809
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6809_WRLINE.s
122 lines (113 loc) · 2.61 KB
/
6809_WRLINE.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
; Title: Write Line
;
; Name: WRLINE
;
; Purpose: Write characters to output device
;
; Entry: Register X = Base address of buffer
; Register A = Number of characters in buffer
;
; Exit: None
;
; Registers Used: ALL
;
; Time: Indeterminate, depends on the speed of the WRCHAR routine.
;
; Size: Program 14 bytes
;
WRLINE:
;
; EXIT IMMEDIATELY IF BUFFER IS EMPTY
;
TSTA ; TEST NUMBER OF CHARACTERS IN BUFFER
BEQ EXITWL ; BRANCH (EXIT) IF BUFFER EMPTY
; X = BASE ADDRESS OF BUFFER
;
; LOOP SENDING CHARACTERS TO OUTPUT DEVICE
;
TFR A,B ; MOVE CHARACTER COUNT TO B
WRLLP:
LDA ,X+ ; GET NEXT CHARACTER
JSR WRCHAR ; SEND CHARACTER
DECB ; DECREMENT COUNTER
BNE WRLLP ; CONTINUE UNTIL ALL CHARACTERS SENT
EXITWL:
RTS ; EXIT
;
; ********************************************************
;
; THE FOLLOWING SUBROUTINES ARE TYPICAL EXAMPLES USING THE
; RADIO SHACK COLOR COMPUTER WITH BASIC IN ROM
;
; ********************************************************
;
; ****************************************
; ROUTINE: WRCHAR
; PURPOSE: WRITE CHARACTER TO 0UTPUT DEVICE
; ENTRY: REGISTER A = CHARACTER
; EXIT: NONE
; REGISTERS USED: ALL
;
; ****************************************
; COLOR COMPUTER EQUATES
;
CLRSCN EQU $A928 ; STARTING ADDRESS FOR ROUTINE THAT CLEARS SCREEN
;
OUTPTR EQU $A002 ; POINTER TO OUTPUT ROUTINE
; UNIT NUMBER GOES IN LOCATION
; $006F (0 = SCREEN)
; CHARACTER GOES IN REGISTER A
;
WRCHAR:
;
; SEND CHARACTER TO OUTPUT DEVICE FROM REGISTER A
; LOCATION $006F SHOULD CONTAIN A UNIT NUMBER
; (DEFAULT IS SCREEN = 0)
;
;
; SAMPLE EXECUTION:
JSR [OUTPTR] ; SEND CHARACTER
RTS
;
; CHARACTER EQUATES
;
CR EQU $0D ; CARRIAGE RETURN FOR CONSOLE
LF EQU $0A ; LINE FEED FOR CONSOLE
PROMPT EQU "?" ; OPERATOR PROMPT = QUESTION MARK
;
SC8B:
;
; CALL BASIC SUBROUTINE THAT CLEARS SCREEN
;
JSR CLRSCN ; CLEAR SCREEN
;
; READ LINE FROM CONSOLE
;
LDA #PROMPT ; OUTPUT PROMPT ('?)
JSR WRCHAR
LDX #INBUFF ; POINT TO INPUT BUFFER
JSR RDLINE ; READ LINE FROM CONSOLE
PSHS A ; SAVE LINE LENGTH IN STACK
LDA #2 ; OUTPUT LINE FEED, CARRIAGE RETURN
LDX #CRLF
JSR WRCHAR
;
; WRITE LINE TO CONSOLE
;
PULS A ; RESTORE LINE LENGTH FROM STACK
LDX #INBUFF ; GET BASE ADDRESS OF BUFFER
JSR WRLINE ; WRITE LINE
LDX #CRLF ; OUTPUT CARRIAGE RETURN, LINE FEED
LDA #2 ; LENGTH OF CRLF STRING
JSR WRLINE ; WRITE CRLF STRING
BRA SC8B ; REPEAT CLEAR, READ, WRITE SEQUENCE
;
; DATA SECTION
;
CRLF FCB CR,LF ; CARRIAGE RETURN, LINE FEED
LINBUF EQU $10 ; LENGTH OF INPUT BUFFER
INBUFF: RMB LINBUF ; DATA BUFFER
; Need this dummy label to compile:
.org $F000
RDLINE:
END