A2osX/BIN/SH.S.HIS.txt
2021-04-29 13:56:34 +02:00

150 lines
2.4 KiB
Plaintext
Raw 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
tax
inc
cmp #HIS.MAX
bne .1
lda #0
.1 >STA.G HIS.LRU
bra .7
.2 tax
>INC.G HIS.Count
.7 >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
beq .8
>STZ.G HIS.Index
.1 jsr HIS.GetIndex
bcs .9
>PUSHW L.MSG.HISTORY
>PUSHB.G HIS.Index
>PUSHW ZPCLBuf
>PUSHBI 3
>SYSCALL PrintF
bcs .9
>INC.G HIS.Index
>CMP.G HIS.Count
bne .1
>PUSHW L.MSG.HISTORYPROMPT
>PUSHBI 0
>SYSCALL PrintF
>SYSCALL GetChar
bcs HIS.Select.RTS
* >PUSHW L.MSG.ECHOCRLF
* >PUSHBI 0
* >SYSCALL PrintF
jsr CL.PrintPrompt
bcs .9
bra HIS.Reset
.8 clc
.9
HIS.Select.RTS rts
*--------------------------------------
HIS.GetPrev >LDA.G HIS.hBuf
beq HIS.Select.RTS
>LDA.G HIS.Count
beq HIS.Select.RTS empty history,nothing to do
>LDA.G HIS.Index
bne .1
>LDA.G HIS.Count
.1 dec
bra HIS.GetToCL
*--------------------------------------
HIS.GetNext >LDA.G HIS.hBuf
beq HIS.Select.RTS
>LDA.G HIS.Count
beq HIS.Select.RTS empty history,nothing to do
>LDA.G HIS.Index
inc
>CMP.G HIS.Count
bne HIS.GetToCL
HIS.Reset >STZ.G HIS.Index
jmp CL.CLR
*--------------------------------------
HIS.GetToCL >STA.G HIS.Index
jsr CL.CLR
jsr HIS.GetIndex
bcs .9
ldy #$ff
.1 iny
lda (ZPCLBuf),y
bne .1
tya
>STA.G CL.Ptr
>STA.G CL.Len
jmp CL.PrintCLBuf
.9 rts
*--------------------------------------
HIS.GetIndex >PUSHB.G HIS.hBuf
>PUSHBI 0
>PUSHB.G HIS.Index
>PUSHW ZPCLBuf
>SYSCALL StrVGet
rts
*--------------------------------------
MAN
SAVE usr/src/bin/sh.s.his
LOAD usr/src/bin/sh.s
ASM