A2osX/BIN/FORTH.S.HIS.txt

163 lines
2.5 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
HIS.Init >LDYAI HISTORY.MAX Get a buffer for History
>SYSCALL StrVNew
bcs .9
>STA.G HIS.hBuf
* >STZ.G HIS.Count
* >STA.G HIS.Index
* >STA.G HIS.LRU
.9 rts
*--------------------------------------
HIS.Add >LDA.G HIS.hBuf
beq .9
>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
>PUSHA
>PUSHW ZPCLBuf
>SYSCALL StrVSet
>STZ.G HIS.Index Reset Index
.9 rts
*--------------------------------------
HIS.Select >LDA.G HIS.Count
bne .10
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
.9
HIS.Select.RTS rts
*--------------------------------------
HIS.GetPrev >LDA.G HIS.Count
beq HIS.Select.RTS empty history,nothing to do
>LDA.G HIS.Index
bne .1
>LDA.G HIS.Count
bra HIS.GetToCL
.1 dec
bra HIS.GetToCl
*--------------------------------------
HIS.GetNext >LDA.G HIS.Count
beq HIS.Select.RTS empty history,nothing to do
>EOR.G HIS.Index
beq HIS.GetToCL
>LDA.G HIS.Index
inc
*--------------------------------------
HIS.GetToCl >STA.G HIS.Index
jsr CL.CLR
HIS.GetToCL1 >LDA.G HIS.Index
beq .9
jsr HIS.GetIndex
bcs .9
ldy #$ff
.1 iny
lda (ZPCLBuf),y
bne .1
tya
sta CL.Ptr
sta CL.Len
jmp CL.Print
.9 rts
*--------------------------------------
HIS.GetIndex >PUSHB.G HIS.hBuf
>PUSHBI 0
>PUSHB.G HIS.Index
>PUSHW ZPCLBuf
>SYSCALL StrVGet
rts
*--------------------------------------
MAN
SAVE usr/src/bin/forth.s.his
LOAD usr/src/bin/forth.s
ASM