2021-04-11 19:47:48 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2021-06-05 15:48:54 +00:00
|
|
|
|
HIS.Init >LDYAI HISTORY.MAX Get a buffer for History
|
2021-04-29 11:56:34 +00:00
|
|
|
|
|
|
|
|
|
>SYSCALL StrVNew
|
2021-04-11 19:47:48 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STA.G HIS.hBuf
|
|
|
|
|
|
2021-06-05 15:48:54 +00:00
|
|
|
|
* >STZ.G HIS.Count
|
|
|
|
|
* >STA.G HIS.Index
|
|
|
|
|
* >STA.G HIS.LRU
|
2021-04-11 19:47:48 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
HIS.Add >LDA.G HIS.hBuf
|
|
|
|
|
beq .9
|
|
|
|
|
|
2021-06-05 15:48:54 +00:00
|
|
|
|
>LDA.G HIS.Count
|
|
|
|
|
cmp #HIS.MAX
|
|
|
|
|
bcc .2
|
|
|
|
|
|
|
|
|
|
>LDA.G HIS.LRU
|
|
|
|
|
cmp #HIS.MAX
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
.1 inc
|
|
|
|
|
>STA.G HIS.LRU
|
|
|
|
|
bra .7
|
|
|
|
|
|
|
|
|
|
.2 inc
|
|
|
|
|
>STA.G HIS.Count
|
|
|
|
|
|
|
|
|
|
.7 tax
|
|
|
|
|
>PUSHB.G HIS.hBuf
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
txa
|
2021-04-11 19:47:48 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHW ZPCLBuf
|
2021-04-29 11:56:34 +00:00
|
|
|
|
>SYSCALL StrVSet
|
2021-06-05 15:48:54 +00:00
|
|
|
|
|
|
|
|
|
>STZ.G HIS.Index Reset Index
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
HIS.Select >LDA.G HIS.Count
|
|
|
|
|
bne .10
|
2021-04-11 19:47:48 +00:00
|
|
|
|
|
2021-06-05 15:48:54 +00:00
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
|
|
|
|
|
|
|
|
|
.10 jsr CL.Reset
|
|
|
|
|
|
|
|
|
|
>STZ.G HIS.Index
|
|
|
|
|
|
|
|
|
|
.1 >INC.G HIS.Index
|
|
|
|
|
jsr HIS.GetIndex
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
>PUSHW L.MSG.HIS
|
|
|
|
|
>LDA.G HIS.Index
|
|
|
|
|
dec
|
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHW ZPCLBuf
|
|
|
|
|
>PUSHBI 3
|
|
|
|
|
>SYSCALL PrintF
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>LDA.G HIS.Index
|
|
|
|
|
>CMP.G HIS.Count
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
>PUSHW L.MSG.HISPROMPT
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL PrintF
|
|
|
|
|
|
|
|
|
|
>STZ.G HIS.Index
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPCLBuf)
|
|
|
|
|
|
|
|
|
|
>SYSCALL GetChar
|
|
|
|
|
bcs HIS.Select.RTS
|
|
|
|
|
|
|
|
|
|
cmp #'0'
|
|
|
|
|
bcc .7
|
|
|
|
|
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
bcs .7
|
|
|
|
|
|
|
|
|
|
and #$f
|
|
|
|
|
inc
|
|
|
|
|
|
|
|
|
|
>STA.G HIS.Index
|
|
|
|
|
|
|
|
|
|
.7 >PUSHW L.MSG.HISROMPTCLR
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL PrintF
|
|
|
|
|
|
|
|
|
|
jsr CL.PrintPrompt
|
|
|
|
|
bcc HIS.GetToCL1
|
2021-04-11 19:47:48 +00:00
|
|
|
|
.9
|
2021-06-05 15:48:54 +00:00
|
|
|
|
HIS.Select.RTS rts
|
2021-04-11 19:47:48 +00:00
|
|
|
|
*--------------------------------------
|
2021-06-05 15:48:54 +00:00
|
|
|
|
HIS.GetPrev >LDA.G HIS.Count
|
|
|
|
|
beq HIS.Select.RTS empty history,nothing to do
|
2021-04-11 19:47:48 +00:00
|
|
|
|
|
|
|
|
|
>LDA.G HIS.Index
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
>LDA.G HIS.Count
|
2021-06-05 15:48:54 +00:00
|
|
|
|
bra HIS.GetToCL
|
|
|
|
|
|
2021-04-11 19:47:48 +00:00
|
|
|
|
.1 dec
|
|
|
|
|
bra HIS.GetToCl
|
|
|
|
|
*--------------------------------------
|
2021-06-05 15:48:54 +00:00
|
|
|
|
HIS.GetNext >LDA.G HIS.Count
|
|
|
|
|
beq HIS.Select.RTS empty history,nothing to do
|
2021-04-11 19:47:48 +00:00
|
|
|
|
|
2021-06-05 15:48:54 +00:00
|
|
|
|
>EOR.G HIS.Index
|
|
|
|
|
beq HIS.GetToCL
|
2021-04-11 19:47:48 +00:00
|
|
|
|
|
|
|
|
|
>LDA.G HIS.Index
|
|
|
|
|
inc
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
HIS.GetToCl >STA.G HIS.Index
|
|
|
|
|
|
|
|
|
|
jsr CL.CLR
|
|
|
|
|
|
2021-06-05 15:48:54 +00:00
|
|
|
|
HIS.GetToCL1 >LDA.G HIS.Index
|
|
|
|
|
beq .9
|
2021-04-11 19:47:48 +00:00
|
|
|
|
|
2021-06-05 15:48:54 +00:00
|
|
|
|
jsr HIS.GetIndex
|
|
|
|
|
bcs .9
|
2021-04-11 19:47:48 +00:00
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPCLBuf),y
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
|
2021-04-29 11:56:34 +00:00
|
|
|
|
sta CL.Ptr
|
|
|
|
|
sta CL.Len
|
2021-06-05 15:48:54 +00:00
|
|
|
|
jmp CL.Print
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
HIS.GetIndex >PUSHB.G HIS.hBuf
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>PUSHB.G HIS.Index
|
|
|
|
|
>PUSHW ZPCLBuf
|
|
|
|
|
>SYSCALL StrVGet
|
|
|
|
|
rts
|
2021-04-11 19:47:48 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE usr/src/bin/forth.s.his
|
|
|
|
|
LOAD usr/src/bin/forth.s
|
|
|
|
|
ASM
|