Pristine Ack-5.5
[Ack-5.5.git] / mach / 6500 / libmon / libmon_s.a
1 eÿprint.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0[\ 2.define Mprint
2 .sect .text
3 .sect .rom
4 .sect .data
5 .sect .bss
6 .sect .text
7
8 ! This subroutine prints a zero terminated ascii string.
9 ! The registerpair AX contains the start of the string.
10 ! The subroutine WRCH is a special routine on the BBC microcomputer
11 ! which prints the character in A to the screen.
12 ! The subroutine WRCH is a special one provided by the BBC
13 ! microcomputer.
14
15
16 Mprint:
17         stx ADDR        ! start address of string (lowbyte)
18         sta ADDR+1      ! start address of string (highbyte)
19         ldy #0
20     1:  lda (ADDR),y    ! get ascii character
21         beq 2f
22         jsr WRCH        ! put it on the screen
23         iny
24         bne 1b
25     2:  rts
26
27
28 \0printhex.s\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ê\ 1.define Printhex
29 .sect .text
30 .sect .rom
31 .sect .data
32 .sect .bss
33 .sect .text
34
35 ! This subroutine print the contents of register A to the screen
36 ! in hexadecimal form.
37 ! The subroutine WRCH is a special one provided by the BBC
38 ! microcomputer.
39
40
41 Printhex:
42         pha             ! save A
43         lsr a
44         lsr a
45         lsr a
46         lsr a           ! get four high bits
47         jsr 1f
48         pla             ! restore A
49         and #0x0F       ! get four low bits
50         jsr 1f
51         rts
52     1:  sed             ! print in hex
53         clc
54         adc #0x90
55         adc #0x40
56         cld
57         jmp WRCH
58
59
60 printstack.s\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0µ\ 3.define Printstack
61 .sect .text
62 .sect .rom
63 .sect .data
64 .sect .bss
65 .sect .text
66
67 ! This a special subroutine which prints some things to the
68 ! monitorscreen for debugging.
69
70
71 Printstack:
72         ldy #0
73     2:  lda (hol0+4),y
74         beq 1f
75         jsr WRCH        ! print filename
76         iny
77         jmp 2b
78     1:  lda #32
79         jsr WRCH        ! print a space
80         lda hol0+1
81         jsr Printhex    ! print line number (highbyte)
82         lda hol0
83         jsr Printhex    ! print line number (lowbyte)
84         lda #32
85         jsr WRCH        ! print a space
86         lda SP+1
87         jsr Printhex    ! print stackpointer (highbyte)
88         lda SP+2
89         jsr Printhex    ! print stackpointer (lowbyte)
90         lda #32
91         jsr WRCH        ! print a space
92         lda LB+1
93         jsr Printhex    ! print real localbase (highbyte)
94         lda LB
95         jsr Printhex    ! print real localbase (lowbyte)
96         lda #32
97         jsr WRCH        ! print a space
98         lda LBl+1
99         jsr Printhex    ! print second lowerbase (highbyte)
100         lda LBl
101         jsr Printhex    ! print second lowerbase (lowbyte)
102         lda #10
103         jsr WRCH        ! print a newline
104         lda #13
105         jsr WRCH        ! print a carriagereturn
106         rts
107
108
109 \0mon.s\0tack.s\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ü\ 2.define Mon
110 .sect .text
111 .sect .rom
112 .sect .data
113 .sect .bss
114 .sect .text
115
116 ! This subroutine performs some monitor calls.
117 ! The exit call just resets the hardware_stackpointer so
118 ! this routine will return to the operating system.
119 ! The close call just returns a zero.
120 ! The ioctl call just pops its arguments and returns a zero.
121 ! The write routine is a real one.
122
123
124 Mon:
125         cpx #1
126         bne 1f          ! exit
127         ldx STACK       ! load stackpointer
128         dex
129         dex             ! adjust stackpointer
130         txs             ! set stackpointer
131         rts
132     1:  cpx #4
133         bne 1f
134         jmp Mwrite
135     1:  cpx #6          ! facked
136         bne 1f          ! close
137         lda #0
138         tax             ! return zero
139         rts
140     1:  cpx #54
141         jsr Pop         ! pop first argument (fildes)
142         jsr Pop         ! pop second argument (request)
143         jsr Pop         ! pop third argument (argp)
144         lda #0
145         tax             ! return zero
146         rts
147
148
149 read.s\0ack.s\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ú\ 2.define Mread
150 .sect .text
151 .sect .rom
152 .sect .data
153 .sect .bss
154 .sect .text
155
156 ! This subroutine reads characters from the standard input.
157 ! It ignores the filedes.
158 ! It reads atmost 255 characters. So the runtime system must
159 ! provide a way of dealing with this.
160 ! The subroutine RDCH is a special one provided by the BBC
161 ! microcomputer.
162
163
164 Mread:
165         jsr Pop         ! ignore filedescriptor
166         jsr Pop         ! bufptr
167         stx ADDR        ! address of character buffer (lowbyte)
168         sta ADDR+1      ! address of character buffer (highbyte)
169         jsr Pop         ! number of characters
170         ldy #0          ! <= 255
171         inx
172     1:  jsr RDCH        ! read a character from the current inputstream
173         bcs 8f
174         sta (ADDR),y
175         iny
176         dex
177         bne 1b
178     8:  tya
179         tax
180         lda #0
181         jsr Push        ! number of characters red.
182         tax             ! report a succesfull read.
183         rts
184
185
186 write.s\0ck.s\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0g\ 2.define Mwrite
187 .sect .text
188 .sect .rom
189 .sect .data
190 .sect .bss
191 .sect .text
192
193 ! This subroutine performs the monitor call write.
194 ! Writing is always done to standardoutput.
195 ! A zero is returned on exit.
196 ! The subroutine WRCH is a special routine of the BBC
197 ! microcomputer.
198
199
200 Mwrite:
201         jsr Pop         ! get fildes
202         jsr Pop         ! get address of characterbuffer
203         stx ADDR        ! bufferaddress (lowbyte)
204         sta ADDR+1      ! bufferaddress (highbyte)
205         jsr Pop         ! number of characters to be writen.
206         ldy #0
207     1:  lda (ADDR),y
208         cmp #10
209         bne 2f
210         pha
211         lda #13
212         jsr WRCH
213         pla
214     2:  jsr WRCH
215         iny
216         dex
217         bne 1b
218         tya
219         tax
220         lda #0
221         jsr Push
222         tax
223         rts
224
225 e