Synertek Systems Sym-1 machine-specific files
This commit is contained in:
24
libsrc/sym1/beep.s
Normal file
24
libsrc/sym1/beep.s
Normal file
@@ -0,0 +1,24 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; beep.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
|
||||
.export _beep
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _beep: near
|
||||
; ---------------------------------------------------------------------------
|
||||
jsr BEEP ; Beep
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
230
libsrc/sym1/bitio.s
Normal file
230
libsrc/sym1/bitio.s
Normal file
@@ -0,0 +1,230 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; bitio.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
|
||||
.export _set_DDR1A, _get_DDR1A, _set_IOR1A, _get_IOR1A
|
||||
.export _set_DDR1B, _get_DDR1B, _set_IOR1B, _get_IOR1B
|
||||
.export _set_DDR2A, _get_DDR2A, _set_IOR2A, _get_IOR2A
|
||||
.export _set_DDR2B, _get_DDR2B, _set_IOR2B, _get_IOR2B
|
||||
.export _set_DDR3A, _get_DDR3A, _set_IOR3A, _get_IOR3A
|
||||
.export _set_DDR3B, _get_DDR3B, _set_IOR3B, _get_IOR3B
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _set_DDR1A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DDR1A ; Write data direction register for port 1A
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_DDR1A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DDR1A ; Read data direction register for port 1A
|
||||
ldx #$00 ;
|
||||
rts ; Return DDR1A
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _set_IOR1A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta OR1A ; Write I/O register for port 1A
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_IOR1A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda OR1A ; Read I/O register for port 1A
|
||||
ldx #$00 ;
|
||||
rts ; Return OR1A
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_DDR1B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DDR1B ; Write data direction register for port 1B
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_DDR1B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DDR1B ; Read data direction register for port 1B
|
||||
ldx #$00 ;
|
||||
rts ; Return DDR1B
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _set_IOR1B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta OR1B ; Write I/O register for port 1B
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_IOR1B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda OR1B ; Read I/O register for port 1B
|
||||
ldx #$00 ;
|
||||
rts ; Return OR1B
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_DDR2A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DDR2A ; Write data direction register for port 2A
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_DDR2A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DDR2A ; Read data direction register for port 2A
|
||||
ldx #$00 ;
|
||||
rts ; Return DDR2A
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _set_IOR2A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta OR2A ; Write I/O register for port 2A
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_IOR2A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda OR2A ; Read I/O register for port 2A
|
||||
ldx #$00 ;
|
||||
rts ; Return OR2A
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_DDR2B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DDR2B ; Write data direction register for port 2B
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_DDR2B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DDR2B ; Read data direction register for port 2B
|
||||
ldx #$00 ;
|
||||
rts ; Return DDR2B
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _set_IOR2B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta OR2B ; Write I/O register for port 2B
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_IOR2B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda OR2B ; Read I/O register for port 2B
|
||||
ldx #$00 ;
|
||||
rts ; Return OR2B
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_DDR3A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DDR3A ; Write data direction register for port 3A
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_DDR3A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DDR3A ; Read data direction register for port 3A
|
||||
ldx #$00 ;
|
||||
rts ; Return DDR3A
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _set_IOR3A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta OR3A ; Write I/O register for port 3A
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_IOR3A: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda OR3A ; Read I/O register for port 3A
|
||||
ldx #$00 ;
|
||||
rts ; Return OR3A
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_DDR3B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DDR3B ; Write data direction register for port 3B
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_DDR3B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DDR3B ; Read data direction register for port 3B
|
||||
ldx #$00 ;
|
||||
rts ; Return DDR3B
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _set_IOR3B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta OR3B ; Write I/O register for port 3B
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_IOR3B: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda OR3B ; Read I/O register for port 3B
|
||||
ldx #$00 ;
|
||||
rts ; Return OR3B
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
65
libsrc/sym1/crt0.s
Normal file
65
libsrc/sym1/crt0.s
Normal file
@@ -0,0 +1,65 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; crt0.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.export _init, _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
|
||||
.import _main
|
||||
.import initlib, donelib, copydata, zerobss
|
||||
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||
.import __STACKSIZE__ ; Linker generated
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "sym1.inc"
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Place the startup code in a special segment
|
||||
|
||||
.segment "STARTUP"
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; A little light housekeeping
|
||||
|
||||
_init: jsr ACCESS ; Unlock System RAM
|
||||
cld ; Clear decimal mode
|
||||
; ---------------------------------------------------------------------------
|
||||
; Turn off console echo
|
||||
|
||||
lda TECHO
|
||||
and #$7F
|
||||
sta TECHO
|
||||
; ---------------------------------------------------------------------------
|
||||
; Set cc65 argument stack pointer
|
||||
|
||||
lda #<(__RAM_START__ + __RAM_SIZE__)
|
||||
sta sp
|
||||
lda #>(__RAM_START__ + __RAM_SIZE__)
|
||||
sta sp+1
|
||||
; ---------------------------------------------------------------------------
|
||||
; Initialize memory storage
|
||||
|
||||
jsr zerobss ; Clear BSS segment
|
||||
jsr copydata ; Initialize DATA segment
|
||||
jsr initlib ; Run constructors
|
||||
; ---------------------------------------------------------------------------
|
||||
; Call main()
|
||||
|
||||
jsr _main
|
||||
; ---------------------------------------------------------------------------
|
||||
; Back from main (this is also the _exit entry)
|
||||
|
||||
_exit: jsr donelib ; Run destructors
|
||||
lda TECHO
|
||||
ora #$80 ; Re-enable console echo
|
||||
sta TECHO
|
||||
jsr NACCES ; Lock System RAM
|
||||
rts ; Re-enter Sym-1 monitor
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
154
libsrc/sym1/display.s
Normal file
154
libsrc/sym1/display.s
Normal file
@@ -0,0 +1,154 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; display.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
|
||||
.export _fdisp, _set_D0, _get_D0
|
||||
.export _set_D1, _get_D1, _set_D2, _get_D2
|
||||
.export _set_D3, _get_D3, _set_D4, _get_D4
|
||||
.export _set_D5, _get_D5, _set_D6, _get_D6
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _fdisp: near
|
||||
; ---------------------------------------------------------------------------
|
||||
jsr SCAND ; Flash Display
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D0: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF0 ; Write Digit 0
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D0: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF0 ; Read Digit 0
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF0
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D1: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF1 ; Write Digit 1
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D1: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF1 ; Read Digit 1
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF1
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D2: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF2 ; Write Digit 2
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D2: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF2 ; Read Digit 2
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF2
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D3: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF3 ; Write Digit 3
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D3: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF3 ; Read Digit 3
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF3
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D4: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF4 ; Write Digit 4
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D4: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF4 ; Read Digit 4
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF4
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D5: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF5 ; Write Digit 5
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D5: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF5 ; Read Digit 5
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF5
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _set_D6: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta DISBUF6 ; Write byte to the right of display
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _get_D6: near
|
||||
; ---------------------------------------------------------------------------
|
||||
lda DISBUF6 ; Read byte to the right of display
|
||||
ldx #$00 ;
|
||||
rts ; Return DISBUF6
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
21
libsrc/sym1/getchar.s
Normal file
21
libsrc/sym1/getchar.s
Normal file
@@ -0,0 +1,21 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; getchar.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
.export _getchar
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _getchar: near
|
||||
; ---------------------------------------------------------------------------
|
||||
jsr INTCHR ; Get character using Monitor ROM call
|
||||
and #$7F ; Strip off top bit
|
||||
ldx #$00 ;
|
||||
rts ; Return char
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
3
libsrc/sym1/libref.s
Normal file
3
libsrc/sym1/libref.s
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
.import _exit
|
||||
|
||||
23
libsrc/sym1/putchar.s
Normal file
23
libsrc/sym1/putchar.s
Normal file
@@ -0,0 +1,23 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; putchar.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
.export _putchar
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _putchar: near
|
||||
; ---------------------------------------------------------------------------
|
||||
jsr OUTCHR ; Send character using Monitor ROM call
|
||||
lda #$00 ;
|
||||
ldx #$00 ;
|
||||
rts ; Return 0000
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
54
libsrc/sym1/read.s
Normal file
54
libsrc/sym1/read.s
Normal file
@@ -0,0 +1,54 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; read.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
|
||||
.import popax, popptr1
|
||||
.importzp ptr1, ptr2, ptr3
|
||||
|
||||
.export _read
|
||||
|
||||
.proc _read
|
||||
; ---------------------------------------------------------------------------
|
||||
sta ptr3
|
||||
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 getch
|
||||
dec ptr2+1
|
||||
beq done ; If buffer full, return
|
||||
|
||||
getch: jsr INTCHR ; Get character using Monitor ROM call
|
||||
jsr OUTCHR ; Echo it
|
||||
and #$7F ; Clear hi bit and check for '\r'
|
||||
cmp #$0D
|
||||
bne putch
|
||||
lda #$0A ; Replace with '\n' and set count to zero
|
||||
|
||||
putch: ldy #$00 ; Put char into return buffer
|
||||
sta (ptr1),y
|
||||
inc ptr1 ; Increment pointer
|
||||
bne begin
|
||||
inc ptr1+1
|
||||
bne begin
|
||||
|
||||
done: lda ptr3
|
||||
ldx ptr3+1
|
||||
rts ; Return count
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
58
libsrc/sym1/tapeio.s
Normal file
58
libsrc/sym1/tapeio.s
Normal file
@@ -0,0 +1,58 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; tapeio.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
|
||||
.import popax
|
||||
|
||||
.export _loadt, _dumpt
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _loadt: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta P1L ; Tape record ID to P1L
|
||||
ldx #$00
|
||||
stx P1H
|
||||
ldy #$80
|
||||
jsr LOADT ; Read data from tape
|
||||
bcs error
|
||||
lda #$00
|
||||
ldx #$00 ; Return 0000 if successful
|
||||
jmp done
|
||||
error: ldx #$00
|
||||
lda #$FF ; or 00FF if not
|
||||
done: rts
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
.proc _dumpt: near
|
||||
; ---------------------------------------------------------------------------
|
||||
sta P3L ; End address
|
||||
stx P3H
|
||||
jsr popax
|
||||
sta P2L ; Start address
|
||||
stx P2H
|
||||
jsr popax
|
||||
sta P1L ; Tape Record ID
|
||||
ldx #$00
|
||||
stx P1H
|
||||
ldy #$80
|
||||
jsr DUMPT ; Write data to tape
|
||||
bcs error
|
||||
lda #$00
|
||||
ldx #$00 ; Return 0000 if successful
|
||||
jmp done
|
||||
error: ldx #$00
|
||||
lda #$FF ; or 00FF if not
|
||||
done: rts
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
53
libsrc/sym1/write.s
Normal file
53
libsrc/sym1/write.s
Normal file
@@ -0,0 +1,53 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; write.s
|
||||
;
|
||||
; for Sym-1
|
||||
;
|
||||
; Wayne Parham
|
||||
;
|
||||
; wayne@parhamdata.com
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
.include "sym1.inc"
|
||||
|
||||
.import popax, popptr1
|
||||
.importzp ptr1, ptr2, ptr3, tmp1
|
||||
|
||||
.export _write
|
||||
|
||||
.proc _write
|
||||
; ---------------------------------------------------------------------------
|
||||
sta ptr3
|
||||
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
|
||||
|
||||
outch : ldy #0
|
||||
lda (ptr1),y
|
||||
jsr OUTCHR ; Send character using Monitor call
|
||||
cmp #$0A
|
||||
bne next
|
||||
lda #$0D ; If it is LF, add CR
|
||||
jsr OUTCHR
|
||||
|
||||
next: inc ptr1
|
||||
bne begin
|
||||
inc ptr1+1
|
||||
jmp begin
|
||||
|
||||
done: lda ptr3
|
||||
ldx ptr3+1
|
||||
rts ; Return count
|
||||
; ---------------------------------------------------------------------------
|
||||
.endproc
|
||||
|
||||
Reference in New Issue
Block a user