A2osX/BIN/NSCUTIL.S.txt

443 lines
6.9 KiB
Plaintext
Raw Normal View History

2016-01-19 17:21:53 +00:00
NEW
2020-08-17 20:47:31 +00:00
AUTO 3,1
2016-01-19 17:21:53 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2020-08-17 20:47:31 +00:00
.TF bin/nscutil
*--------------------------------------
NSC.IOBASE .EQ $C300
2016-01-19 17:21:53 +00:00
*--------------------------------------
2020-08-17 20:47:31 +00:00
.INB inc/macros.i
2021-05-30 20:34:03 +00:00
.INB inc/io.i
2020-08-17 20:47:31 +00:00
.INB inc/a2osx.i
.INB inc/mli.e.i
2016-01-19 17:21:53 +00:00
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
DS121x.DATA0 .BS 8
DS121x.DATA1 .BS 8 Reverted YY MM DD Day HH mm SS CS
ZPPtr1 .BS 2
TmpByte .BS 1
ZS.END .ED
2016-01-19 17:21:53 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
2018-11-21 07:09:22 +00:00
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
2016-01-19 17:21:53 +00:00
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
2021-05-30 20:34:03 +00:00
.DA CS.DOEVENT
2016-01-19 17:21:53 +00:00
.DA CS.QUIT
L.MSG.READ.KO .DA MSG.READ.KO
L.MSG.READ.OK1 .DA MSG.READ.OK1
L.MSG.READ.OK2.12 .DA MSG.READ.OK2.12
L.MSG.READ.OK2.24 .DA MSG.READ.OK2.24
L.MSG.READ.OK3 .DA MSG.READ.OK3
L.MSG.USAGE .DA MSG.USAGE
2019-12-07 09:54:33 +00:00
L.MSG.CRLF .DA MSG.CRLF
2016-01-19 17:21:53 +00:00
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
CS.RUN ldy #S.PS.ARGC
2020-02-28 07:21:46 +00:00
lda (pPS),y
2018-11-23 16:20:19 +00:00
cmp #1
2018-11-21 07:09:22 +00:00
bcs CS.RUN.SET
2021-05-30 20:34:03 +00:00
CS.RUN.READ jsr NSC.Init
2016-01-19 17:21:53 +00:00
jsr NSC.Read
ldx #7
2021-05-30 20:34:03 +00:00
.1 lda DS121x.DATA0,x
eor DS121x.DATA1,x
2016-02-21 20:43:53 +00:00
bne .8
2021-05-30 20:34:03 +00:00
2016-01-19 17:21:53 +00:00
dex
2016-02-21 20:43:53 +00:00
bpl .1
2020-05-19 13:00:17 +00:00
>PUSHW L.MSG.READ.KO
2018-11-21 07:09:22 +00:00
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
lda #MLI.E.NODEV
2016-02-21 20:43:53 +00:00
sec
rts
2019-12-07 09:54:33 +00:00
2016-02-21 20:43:53 +00:00
.8 jsr NSC.Dump
2020-05-19 13:00:17 +00:00
>PUSHW L.MSG.USAGE
2018-11-21 07:09:22 +00:00
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2021-05-30 20:34:03 +00:00
lda #0 tell TSKMGR that all done ok, but
2016-01-19 17:21:53 +00:00
sec we do not want to stay in memory
rts
2016-02-21 20:43:53 +00:00
CS.RUN.SET lda #1
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
>STYA ZPPtr1
2020-08-17 20:47:31 +00:00
>SYSCALL StrLen
2018-11-21 13:08:11 +00:00
cpy #17
bne .9
2021-05-30 20:34:03 +00:00
2018-11-21 13:08:11 +00:00
ldy #0
stz DS121x.DATA1+7
jsr GetBCD
bcs .9
2021-05-30 20:34:03 +00:00
sta DS121x.DATA1
lda (ZPPtr1),y
cmp #'/'
bne .9
2021-05-30 20:34:03 +00:00
iny
jsr GetBCD
bcs .9
2021-05-30 20:34:03 +00:00
sta DS121x.DATA1+1
lda (ZPPtr1),y
cmp #'/'
bne .9
2021-05-30 20:34:03 +00:00
iny
jsr GetBCD
2016-01-19 17:21:53 +00:00
bcs .9
2021-05-30 20:34:03 +00:00
sta DS121x.DATA1+2
2016-01-19 17:21:53 +00:00
lda (ZPPtr1),y
2018-11-21 13:08:11 +00:00
cmp #','
bne .9
2021-05-30 20:34:03 +00:00
iny
2021-05-30 20:34:03 +00:00
jsr GetBCD
bcs .9
sta DS121x.DATA1+4
lda (ZPPtr1),y
cmp #':'
bne .9
2021-05-30 20:34:03 +00:00
iny
2016-01-19 17:21:53 +00:00
jsr GetBCD
bcs .9
2021-05-30 20:34:03 +00:00
sta DS121x.DATA1+5
lda (ZPPtr1),y
cmp #':'
bne .9
2021-05-30 20:34:03 +00:00
iny
jsr GetBCD
bcs .9
2021-05-30 20:34:03 +00:00
sta DS121x.DATA1+6
stz DS121x.DATA1+7
jsr NSC.Write
2021-05-30 20:34:03 +00:00
lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
2019-12-07 09:54:33 +00:00
2018-10-21 20:54:07 +00:00
.9 lda #E.SYN
2016-01-19 17:21:53 +00:00
sec
2019-10-03 06:25:27 +00:00
rts
2016-01-19 17:21:53 +00:00
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT clc
2016-01-19 17:21:53 +00:00
rts
*--------------------------------------
2021-05-31 10:10:53 +00:00
NSC.Init php
2016-01-19 17:21:53 +00:00
sei
2021-05-30 20:34:03 +00:00
2021-06-03 17:43:28 +00:00
lda RDCXROM
2021-05-31 10:10:53 +00:00
php
2021-06-03 17:43:28 +00:00
sta SETCXROM
2021-05-30 20:34:03 +00:00
2021-05-31 10:10:53 +00:00
ldx #8
2021-05-30 20:34:03 +00:00
2016-02-21 20:43:53 +00:00
.1 ldy #8
2021-05-30 20:34:03 +00:00
.2 lda NSC.IOBASE+4
2016-02-21 20:43:53 +00:00
lsr
ror DS121x.DATA0-1,x
2016-02-21 20:43:53 +00:00
dey
bne .2
2021-05-30 20:34:03 +00:00
2016-02-21 20:43:53 +00:00
dex
2021-05-31 10:10:53 +00:00
bne .1
2021-05-30 20:34:03 +00:00
plp
2021-06-03 17:43:28 +00:00
bmi .8
2021-05-30 20:34:03 +00:00
2021-06-03 17:43:28 +00:00
sta CLRCXROM
2021-05-30 20:34:03 +00:00
2021-05-31 10:10:53 +00:00
.8 plp
rts
2016-01-19 17:21:53 +00:00
*--------------------------------------
NSC.Read php
sei
2021-05-30 20:34:03 +00:00
2021-06-03 17:43:28 +00:00
lda RDCXROM
2021-05-30 20:34:03 +00:00
php
2021-06-03 17:43:28 +00:00
sta SETCXROM
2021-05-30 20:34:03 +00:00
2016-02-21 20:43:53 +00:00
jsr NSC.Select
2016-01-19 17:21:53 +00:00
2021-06-06 19:06:49 +00:00
ldx #8 Read 8 bytes...
2021-05-30 20:34:03 +00:00
2016-01-19 17:21:53 +00:00
.1 ldy #8
2021-05-30 20:34:03 +00:00
.2 lda NSC.IOBASE+4
2016-01-19 17:21:53 +00:00
lsr
ror DS121x.DATA1-1,x
2016-01-19 17:21:53 +00:00
dey
bne .2
2021-05-30 20:34:03 +00:00
2016-01-19 17:21:53 +00:00
dex
2021-06-06 19:06:49 +00:00
bne .1
2021-05-30 20:34:03 +00:00
plp
2021-06-03 17:43:28 +00:00
bmi .8
2021-05-30 20:34:03 +00:00
2021-06-03 17:43:28 +00:00
sta CLRCXROM
2021-05-30 20:34:03 +00:00
.8 plp
2016-01-19 17:21:53 +00:00
rts
*--------------------------------------
NSC.Write php
sei
2021-05-30 20:34:03 +00:00
2021-06-03 17:43:28 +00:00
lda RDCXROM
2021-05-30 20:34:03 +00:00
php
2021-06-03 17:43:28 +00:00
sta SETCXROM
2021-05-30 20:34:03 +00:00
2016-02-21 20:43:53 +00:00
jsr NSC.Select
2021-06-06 19:06:49 +00:00
ldx #8 Write 8 bytes...
2021-05-30 20:34:03 +00:00
.3 lda DS121x.DATA1-1,x
phx
2021-06-06 19:06:49 +00:00
ldx #8 ....of 8 bits
2021-05-30 20:34:03 +00:00
.4 ldy #0
lsr
bcc .5
2021-05-30 20:34:03 +00:00
iny
2021-05-30 20:34:03 +00:00
2016-02-21 20:43:53 +00:00
.5 pha
lda NSC.IOBASE,y Write Pattern bit in A0, with A2=0
2016-02-21 20:43:53 +00:00
pla
dex
bne .4
2021-05-30 20:34:03 +00:00
plx
dex
2021-06-06 19:06:49 +00:00
bne .3
2021-05-30 20:34:03 +00:00
plp
2021-06-03 17:43:28 +00:00
bmi .8
2021-05-30 20:34:03 +00:00
2021-06-03 17:43:28 +00:00
sta CLRCXROM
2021-05-30 20:34:03 +00:00
.8 plp
rts
*--------------------------------------
NSC.Select sta NSC.IOBASE
2021-07-24 20:42:23 +00:00
* lda $C00B Workaround for Ultrawarp bug
2021-05-30 20:34:03 +00:00
lda NSC.IOBASE+4 Reset DS1216E comparison register with READ A2=1
2021-05-30 20:34:03 +00:00
2021-06-22 18:59:02 +00:00
ldy #8 Read 8 bytes...
2021-06-06 19:06:49 +00:00
.3 lda DS121x.SIG-1,y
2021-06-22 18:59:02 +00:00
phy
ldy #8 ....of 8 bits
2021-05-30 20:34:03 +00:00
2021-06-22 18:59:02 +00:00
.4 ldx #0
2021-05-30 20:34:03 +00:00
lsr
bcc .5
2021-06-22 18:59:02 +00:00
inx
2021-05-30 20:34:03 +00:00
.5 bit NSC.IOBASE,x Write Pattern bit in A0, with A2=0
2021-06-22 18:59:02 +00:00
dey
2021-05-30 20:34:03 +00:00
bne .4
2021-06-22 18:59:02 +00:00
ply
dey
2021-06-06 19:06:49 +00:00
bne .3
2021-05-30 20:34:03 +00:00
rts
*--------------------------------------
2020-05-19 13:00:17 +00:00
NSC.Dump >PUSHW L.MSG.READ.OK1
ldx #1
ldy #1
lda DS121x.DATA1+3
bit #%00010000
beq .1
2020-05-19 13:00:17 +00:00
dex
.1 bit #%00100000
2020-05-19 13:00:17 +00:00
beq .2
dey
2020-05-19 13:00:17 +00:00
.2 tya
>PUSHA
2020-05-19 13:00:17 +00:00
txa
>PUSHA
2020-05-19 13:00:17 +00:00
2018-11-21 07:09:22 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-05-19 13:00:17 +00:00
>LDYA L.MSG.READ.OK2.24
bit DS121x.DATA1+4
bpl .3
2021-05-30 20:34:03 +00:00
>LDYA L.MSG.READ.OK2.12
2019-12-07 09:54:33 +00:00
2020-05-19 13:00:17 +00:00
.3 >SYSCALL PutS
2020-06-11 21:04:56 +00:00
>PUSHW L.MSG.READ.OK3
2018-11-21 07:09:22 +00:00
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
lda DS121x.DATA1
2016-01-19 17:21:53 +00:00
jsr PrintBCD
2020-05-19 13:00:17 +00:00
2016-01-19 17:21:53 +00:00
lda #'/'
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2020-05-19 13:00:17 +00:00
lda DS121x.DATA1+1
2016-01-19 17:21:53 +00:00
jsr PrintBCD
2020-05-19 13:00:17 +00:00
2016-01-19 17:21:53 +00:00
lda #'/'
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2020-05-19 13:00:17 +00:00
lda DS121x.DATA1+2
2016-01-19 17:21:53 +00:00
jsr PrintBCD
2019-12-07 09:54:33 +00:00
lda #','
>SYSCALL PutChar
lda DS121x.DATA1+4
bpl .4
2016-01-19 17:21:53 +00:00
and #$1F
2019-12-07 09:54:33 +00:00
.4 and #$3F
2016-01-19 17:21:53 +00:00
jsr PrintBCD
2020-05-19 13:00:17 +00:00
2016-01-19 17:21:53 +00:00
lda #':'
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2020-05-19 13:00:17 +00:00
lda DS121x.DATA1+5
2016-01-19 17:21:53 +00:00
jsr PrintBCD
2020-05-19 13:00:17 +00:00
2016-01-19 17:21:53 +00:00
lda #':'
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2020-05-19 13:00:17 +00:00
lda DS121x.DATA1+6
2016-01-19 17:21:53 +00:00
jsr PrintBCD
2020-05-19 13:00:17 +00:00
2020-06-11 21:04:56 +00:00
lda #'.'
>SYSCALL PutChar
lda DS121x.DATA1+7
2020-06-11 21:04:56 +00:00
jsr PrintBCD
2021-05-30 20:34:03 +00:00
2020-05-19 13:00:17 +00:00
>PUSHW L.MSG.CRLF
2019-12-07 09:54:33 +00:00
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2016-01-19 17:21:53 +00:00
rts
*--------------------------------------
PrintBCD pha
lsr
lsr
lsr
lsr
ora #$30
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2021-05-30 20:34:03 +00:00
2016-01-19 17:21:53 +00:00
pla
and #$0f
ora #$30
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2021-05-30 20:34:03 +00:00
rts
2016-01-19 17:21:53 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
GetBCD lda (ZPPtr1),y
iny
jsr IsDigit
bcs .9
2021-05-30 20:34:03 +00:00
asl
asl
asl
asl
sta TmpByte
2021-05-30 20:34:03 +00:00
lda (ZPPtr1),y
iny
jsr IsDigit
bcs .9
2021-05-30 20:34:03 +00:00
and #$0f
ora TmpByte
2021-05-30 20:34:03 +00:00
2019-10-03 06:25:27 +00:00
.9 rts
*--------------------------------------
IsDigit cmp #'0'
bcc .9
2021-05-30 20:34:03 +00:00
cmp #'9'+1
and #$0f
rts cc if ok, cs if not
2021-05-30 20:34:03 +00:00
.9 sec
rts
*--------------------------------------
2016-01-19 17:21:53 +00:00
CS.END
MSG.READ.KO .AZ "DS1216E Not Detected.\r\n"
2019-12-07 09:54:33 +00:00
MSG.READ.OK1 .AZ "DS1216E Detected : /OSC=%d, /RST=%d, mode="
MSG.READ.OK2.12 .AZ "am/pm"
MSG.READ.OK2.24 .AZ "24h"
2020-05-19 13:00:17 +00:00
MSG.READ.OK3 .AZ "\r\nCurrent Date/Time : "
2019-12-07 09:54:33 +00:00
MSG.USAGE .AS "\r\nTo Reset the chip and set clock, type:\r\nNSCUTIL YY/MM/DD,hh:mm:ss"
MSG.CRLF .AZ "\r\n"
DS121x.SIG .HS 5CA33AC55CA33AC5 Reverted 7->0
2016-01-19 17:21:53 +00:00
*--------------------------------------
DS.START
DS.END
*--------------------------------------
MAN
2020-08-17 20:47:31 +00:00
SAVE usr/src/bin/nscutil.s
2016-01-19 17:21:53 +00:00
ASM