2016-01-19 17:21:53 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2016-01-19 17:21:53 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.TF /A2OSX.BUILD/BIN/NSCUTIL
|
2016-01-19 17:21:53 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
2016-01-19 17:21:53 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-19 22:09:26 +00:00
|
|
|
|
ZPPtr1 .EQ ZPBIN
|
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
|
|
|
|
|
.DA CS.END-CS.START
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.MSG.READ.KO .DA MSG.READ.KO
|
|
|
|
|
L.MSG.READ.OK1 .DA MSG.READ.OK1
|
2016-01-19 22:09:26 +00:00
|
|
|
|
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.READ.OK4 .DA MSG.READ.OK4
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
2016-01-19 17:21:53 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2017-02-21 17:01:30 +00:00
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN >SYSCALL GetArgC
|
2016-10-07 20:48:49 +00:00
|
|
|
|
cmp #1
|
2017-02-21 17:01:30 +00:00
|
|
|
|
bne CS.RUN.SET
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
2017-02-21 17:01:30 +00:00
|
|
|
|
CS.RUN.READ jsr NSC.Init
|
2016-01-19 17:21:53 +00:00
|
|
|
|
jsr NSC.Read
|
2016-02-21 20:43:53 +00:00
|
|
|
|
|
2016-01-19 17:21:53 +00:00
|
|
|
|
ldx #7
|
2016-02-21 20:43:53 +00:00
|
|
|
|
|
|
|
|
|
.1 lda DS1216E.DETECT,x
|
|
|
|
|
eor DS1216E.DATA,x
|
|
|
|
|
bne .8
|
2016-01-19 17:21:53 +00:00
|
|
|
|
dex
|
2016-02-21 20:43:53 +00:00
|
|
|
|
bpl .1
|
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
>LDYA L.MSG.READ.KO
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
2017-02-21 17:01:30 +00:00
|
|
|
|
lda #MLI.ERR.NODEV
|
2016-02-21 20:43:53 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 jsr NSC.Dump
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.USAGE
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2016-02-21 20:43:53 +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
|
|
|
|
|
2017-02-21 17:01:30 +00:00
|
|
|
|
CS.RUN.SET lda #1
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetArgA
|
2016-01-19 22:09:26 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #17
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
|
|
|
|
|
stz DS1216E.DATA+7
|
|
|
|
|
|
|
|
|
|
jsr GetBCD
|
|
|
|
|
bcs .9
|
|
|
|
|
sta DS1216E.DATA+2
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .9
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
jsr GetBCD
|
|
|
|
|
bcs .9
|
|
|
|
|
sta DS1216E.DATA+1
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .9
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
jsr GetBCD
|
2016-01-19 17:21:53 +00:00
|
|
|
|
bcs .9
|
2016-01-19 22:09:26 +00:00
|
|
|
|
sta DS1216E.DATA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp #' '
|
|
|
|
|
bne .9
|
|
|
|
|
iny
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
jsr GetBCD
|
|
|
|
|
bcs .9
|
|
|
|
|
sta DS1216E.DATA+4
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp #':'
|
|
|
|
|
bne .9
|
|
|
|
|
iny
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
jsr GetBCD
|
|
|
|
|
bcs .9
|
|
|
|
|
sta DS1216E.DATA+5
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp #':'
|
|
|
|
|
bne .9
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
jsr GetBCD
|
|
|
|
|
bcs .9
|
|
|
|
|
sta DS1216E.DATA+6
|
|
|
|
|
stz DS1216E.DATA+7
|
|
|
|
|
|
|
|
|
|
jsr NSC.Write
|
|
|
|
|
|
|
|
|
|
lda #0 tell TSKMGR that all done ok, but
|
|
|
|
|
sec we do not want to stay in memory
|
|
|
|
|
rts
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
|
|
|
|
.9 lda #SYSMGR.ERRSYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-21 17:01:30 +00:00
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-19 22:09:26 +00:00
|
|
|
|
CS.QUIT clc
|
2016-01-19 17:21:53 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-02-21 20:43:53 +00:00
|
|
|
|
NSC.Init php
|
2016-01-19 17:21:53 +00:00
|
|
|
|
sei
|
2016-02-21 20:43:53 +00:00
|
|
|
|
lda $CFFF
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldx #7
|
|
|
|
|
|
|
|
|
|
.1 ldy #8
|
|
|
|
|
.2 lda $C304
|
|
|
|
|
|
|
|
|
|
lsr
|
|
|
|
|
ror DS1216E.DETECT,x
|
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
pla
|
|
|
|
|
bmi .99
|
2016-01-19 22:09:26 +00:00
|
|
|
|
sta $CFFF
|
2016-02-21 20:43:53 +00:00
|
|
|
|
.99 plp
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
NSC.Select sta $C300
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda $C304 Reset DS1216E comparison register with READ A2=1
|
|
|
|
|
|
|
|
|
|
ldx #7 Read 8 bytes...
|
|
|
|
|
|
|
|
|
|
.3 lda DS1216E.PATTERN,x
|
|
|
|
|
phx
|
|
|
|
|
ldx #8 ....of 8 bits
|
|
|
|
|
|
|
|
|
|
.4 ldy #0
|
|
|
|
|
lsr
|
|
|
|
|
bcc .5
|
|
|
|
|
iny
|
2016-02-21 20:43:53 +00:00
|
|
|
|
.5 pha
|
|
|
|
|
lda $C300,y Write Pattern bit in A0, with A2=0
|
|
|
|
|
pla
|
2016-01-19 17:21:53 +00:00
|
|
|
|
dex
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
plx
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
NSC.Read php
|
|
|
|
|
sei
|
2016-02-21 20:43:53 +00:00
|
|
|
|
lda $CFFF
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
jsr NSC.Select
|
2016-01-19 17:21:53 +00:00
|
|
|
|
|
|
|
|
|
ldx #7
|
|
|
|
|
|
|
|
|
|
.1 ldy #8
|
|
|
|
|
.2 lda $C304
|
|
|
|
|
|
|
|
|
|
lsr
|
|
|
|
|
ror DS1216E.DATA,x
|
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
2016-02-21 20:43:53 +00:00
|
|
|
|
pla
|
|
|
|
|
bmi .99
|
|
|
|
|
sta $CFFF
|
|
|
|
|
.99 plp
|
2016-01-19 17:21:53 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-19 22:09:26 +00:00
|
|
|
|
NSC.Write php
|
|
|
|
|
sei
|
2016-02-21 20:43:53 +00:00
|
|
|
|
lda $CFFF
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
jsr NSC.Select
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
|
|
|
|
ldx #7
|
|
|
|
|
|
|
|
|
|
.3 lda DS1216E.DATA,x
|
|
|
|
|
phx
|
|
|
|
|
ldx #8 ....of 8 bits
|
|
|
|
|
|
|
|
|
|
.4 ldy #0
|
|
|
|
|
lsr
|
|
|
|
|
bcc .5
|
|
|
|
|
iny
|
2016-02-21 20:43:53 +00:00
|
|
|
|
.5 pha
|
|
|
|
|
lda $C300,y Write Pattern bit in A0, with A2=0
|
|
|
|
|
pla
|
2016-01-19 22:09:26 +00:00
|
|
|
|
dex
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
plx
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
2016-02-21 20:43:53 +00:00
|
|
|
|
pla
|
|
|
|
|
bmi .99
|
|
|
|
|
sta $CFFF
|
|
|
|
|
.99 plp
|
2016-01-19 22:09:26 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
NSC.Dump ldx #1
|
|
|
|
|
ldy #1
|
2016-02-21 20:43:53 +00:00
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
lda DS1216E.DATA+3
|
|
|
|
|
bit #%00010000
|
|
|
|
|
beq .1
|
|
|
|
|
dex
|
|
|
|
|
|
|
|
|
|
.1 bit #%00100000
|
|
|
|
|
beq .2
|
|
|
|
|
dey
|
|
|
|
|
|
|
|
|
|
.2 txa
|
|
|
|
|
>PUSHA
|
|
|
|
|
tya
|
|
|
|
|
>PUSHA
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.READ.OK1
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.READ.OK2.24
|
|
|
|
|
bit DS1216E.DATA+4
|
|
|
|
|
bpl .3
|
|
|
|
|
>LDYA L.MSG.READ.OK2.12
|
2016-11-03 16:27:43 +00:00
|
|
|
|
.3 >SYSCALL CPrintFYA
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.READ.OK3
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA+2
|
|
|
|
|
jsr PrintBCD
|
|
|
|
|
lda #'/'
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA+1
|
|
|
|
|
jsr PrintBCD
|
|
|
|
|
lda #'/'
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA
|
|
|
|
|
jsr PrintBCD
|
|
|
|
|
|
2016-01-19 22:09:26 +00:00
|
|
|
|
>LDYA L.MSG.READ.OK4
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2016-01-19 22:09:26 +00:00
|
|
|
|
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA+4
|
2016-01-19 22:09:26 +00:00
|
|
|
|
bpl .4
|
2016-01-19 17:21:53 +00:00
|
|
|
|
and #$1F
|
2016-01-19 22:09:26 +00:00
|
|
|
|
.4 and #$3F
|
2016-01-19 17:21:53 +00:00
|
|
|
|
jsr PrintBCD
|
|
|
|
|
lda #':'
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA+5
|
|
|
|
|
jsr PrintBCD
|
|
|
|
|
lda #':'
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA+6
|
|
|
|
|
jsr PrintBCD
|
|
|
|
|
lda #'.'
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
lda DS1216E.DATA+7
|
|
|
|
|
jsr PrintBCD
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintBCD pha
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
ora #$30
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
pla
|
|
|
|
|
and #$0f
|
|
|
|
|
ora #$30
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>SYSCALL PutCA
|
2016-01-19 17:21:53 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2016-01-19 22:09:26 +00:00
|
|
|
|
GetBCD lda (ZPPtr1),y
|
|
|
|
|
iny
|
|
|
|
|
jsr IsDigit
|
|
|
|
|
bcs .9
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
sta TmpByte
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
iny
|
|
|
|
|
jsr IsDigit
|
|
|
|
|
bcs .9
|
|
|
|
|
and #$0f
|
|
|
|
|
ora TmpByte
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IsDigit cmp #'0'
|
|
|
|
|
bcc .9
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
and #$0f
|
|
|
|
|
rts cc if ok, cs if not
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-19 17:21:53 +00:00
|
|
|
|
CS.END
|
2017-02-28 16:58:36 +00:00
|
|
|
|
MSG.READ.KO >CSTR "DS1216E Not Detected.\r\n"
|
2016-10-24 15:54:43 +00:00
|
|
|
|
MSG.READ.OK1 >CSTR "DS1216E Detected:/OSC=%d,/RST=%d,mode="
|
|
|
|
|
MSG.READ.OK2.12 >CSTR "am/pm"
|
|
|
|
|
MSG.READ.OK2.24 >CSTR "24h"
|
2017-02-28 16:58:36 +00:00
|
|
|
|
MSG.READ.OK3 >CSTR "\r\nDate:"
|
|
|
|
|
MSG.READ.OK4 >CSTR "\r\nTime:"
|
|
|
|
|
MSG.USAGE >CSTR "\r\n\r\nTo Reset the chip and set clock, type:\r\nNSCUTIL DD/MM/YY hh:mm:ss\r\n"
|
2016-01-19 22:09:26 +00:00
|
|
|
|
TmpByte .BS 1
|
2016-01-19 17:21:53 +00:00
|
|
|
|
DS1216E.PATTERN .HS 5CA33AC55CA33AC5 Reverted 7->0
|
2016-02-21 20:43:53 +00:00
|
|
|
|
DS1216E.DETECT .BS 8
|
|
|
|
|
DS1216E.DATA .BS 8 Reverted YY MM DD Day HH mm SS CS
|
2016-01-19 17:21:53 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
DS.START
|
|
|
|
|
DS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/BIN/NSCUTIL.S
|
2016-01-19 17:21:53 +00:00
|
|
|
|
ASM
|