2021-05-09 21:34:53 +00:00
|
|
|
;
|
2021-06-07 02:28:03 +00:00
|
|
|
; Wayne Parham (wayne@parhamdata.com)
|
2021-05-09 21:34:53 +00:00
|
|
|
;
|
2021-06-16 21:24:26 +00:00
|
|
|
; int __fastcall__ write (int fd, const void* buf, int count);
|
2021-05-09 21:34:53 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
.include "sym1.inc"
|
|
|
|
|
|
|
|
.import popax, popptr1
|
2021-06-12 11:17:03 +00:00
|
|
|
.importzp ptr1, ptr2, ptr3
|
2021-05-09 21:34:53 +00:00
|
|
|
|
|
|
|
.export _write
|
|
|
|
|
|
|
|
.proc _write
|
2021-06-07 02:28:03 +00:00
|
|
|
|
2022-04-17 14:06:22 +00:00
|
|
|
sta ptr3
|
2021-05-09 21:34:53 +00:00
|
|
|
stx ptr3+1 ; Count in ptr3
|
|
|
|
inx
|
|
|
|
stx ptr2+1 ; Increment and store in ptr2
|
|
|
|
tax
|
|
|
|
inx
|
|
|
|
stx ptr2
|
|
|
|
jsr popptr1 ; Buffer address in ptr1
|
|
|
|
jsr popax
|
|
|
|
|
|
|
|
begin: dec ptr2
|
|
|
|
bne outch
|
|
|
|
dec ptr2+1
|
|
|
|
beq done
|
|
|
|
|
2021-06-12 11:17:03 +00:00
|
|
|
outch: ldy #0
|
2021-05-09 21:34:53 +00:00
|
|
|
lda (ptr1),y
|
|
|
|
jsr OUTCHR ; Send character using Monitor call
|
2021-06-12 11:17:03 +00:00
|
|
|
cmp #$07 ; Check for '\a'
|
|
|
|
bne chklf ; ...if BEL character
|
|
|
|
jsr BEEP ; Make beep sound
|
|
|
|
chklf: cmp #$0A ; Check for 'n'
|
|
|
|
bne next ; ...if LF character
|
|
|
|
lda #$0D ; Add a carriage return
|
2021-05-09 21:34:53 +00:00
|
|
|
jsr OUTCHR
|
|
|
|
|
|
|
|
next: inc ptr1
|
|
|
|
bne begin
|
|
|
|
inc ptr1+1
|
|
|
|
jmp begin
|
|
|
|
|
|
|
|
done: lda ptr3
|
|
|
|
ldx ptr3+1
|
|
|
|
rts ; Return count
|
2021-06-07 02:28:03 +00:00
|
|
|
|
2021-05-09 21:34:53 +00:00
|
|
|
.endproc
|