Mov Word Ptr NumLF,DI
And Switch2,0FFh-Nodata
Mov ES,RecAddr
GetR2: Mov SI,Index
Mov AL,ES:[SI]
Cmp AL,Eof
Jne GetR3
Mov Reclen,DI
Or Switch1,Eor
Jmp GetR
GetR3: And AL,char_msk
Cmp AL,09h
Jne GetR4
Mov CX,DI
Add CX,8
And CX,0FFF8h
Sub CX,DI
GetR3b: Mov Work[DI],' '
Inc DI
Loop GetR3b
Inc Index
Jmp GetR2
GetR4:
Mov Work[DI],AL
Inc DI
Inc Index
Cmp AL,Cr
Jne GetR5
Inc NumCR
cmp ES:byte ptr[SI+1],LF
je GetR6
mov byte ptr work[di-1],LF
dec NumCR
Inc NumLF
Jmp GetR8
GetR5: Cmp AL,' '
Je GetR7
Cmp AL,Lf
Jne GetR6
Inc NumLF
Jmp GetR8
GetR6: Or Switch2,Nodata
GetR7: Cmp DI,255
Je GetR8
Jmp GetR2
GetR8: Mov Reclen,DI
Cmp Work,0Fh
Jne GetR9
Jmp GetR0
GetR9: Test Switch2,Nodata
Jnz GetRd
Jmp GetR0
GetRd: Pop DI
Pop SI
Pop CX
Pop ES
Ret
GetRec Endp
; Читает блок из файла
ReadBlk Proc Near
Mov Switch1,0
Mov BX,Handle
Mov CX,Blksize
Push DS
Mov DS,RecAddr
Sub DX,DX
Mov AH,3Fh
Int 21H
Pop DS
Or AX,AX
Jz ReadB2
Mov Last,AX
Mov Index,0
Mov First,0
Mov Current,0
Inc Blknum
Mov DI,Last
Mov ES,RecAddr
Mov Byte Ptr ES:[DI],1Ah
ReadB2: Ret
Readblk Endp
; Ввод текста после '/'
ReScan Proc
Push DI
Push SI
Push DS
Pop ES
Jmp Scan1
Scan: Push DI
Push SI
Push DS
Pop ES
Mov TextMax,32
Mov DX,Offset TextMax
Mov AH,0Ah
Int 21h
Scan1: Sub CX,CX
Or CL,TextLen
Jz NoMatch
Mov AX,First
Mov Index,AX
Call GetRec
Scan3: Call GetRec
Test Switch1,Eor
Jnz NoMatch
Mov AX,Index
Cmp AX,Last
Jae NoMatch
Mov CX,RecLen
Sub CL,TextLen
Jle Scan3
Mov AL,TextBuf
Mov DI,Offset Work
Repnz Scasb
Jne Scan3
Cmp TextLen,1
Je Match
Sub CH,CH
Mov CL,TextLen
Dec CL
Mov SI,Offset TextBuf+1
Repe Cmpsb
Jne Scan3
Or CX,CX
Jnz Scan3
Match: Call Set25
Mov Attr,Blink
Call UpOne
Jmp Scaned
NoMatch:Mov AX,First
Mov Index,AX
Call Set25
Mov SI,Offset TextMsg
Add Special,128
Call Msg25
Sub Special,128
Mov Switch1,0
Mov Col,1
Scaned: Pop SI
Pop DI
Ret
ReScan Endp
; Очищает экран
Clear Proc Near
Push AX
Push BX
Push CX
Push DX
Mov AX,0600h
Mov BH,Foregrd
Jmp Scroller
Scroll_Dn:
Push AX
Push BX
Push CX
Push DX
Mov AX,0601h
Mov BH,Foregrd
Jmp Scroller
Scroll_Up:
Push AX
Push BX
Push CX
Push DX
Mov AX,0701h
Mov BH,Foregrd
Scroller:
Mov CX,0100h
Mov DX,174Fh
Int 10h
Pop DX
Pop CX
Pop BX
Pop AX
Ret
Clear Endp
; Выводит строку 0
Set1 Proc Near
Mov AX,0600h
Sub BL,BL
Mov BH,Foregrd
Sub CX,CX
Mov DX,184Fh
Int 10h
Mov Word Ptr Work+5,0000h
Mov DH,1
Mov DL,DH
Mov SI,Offset Work
Mov CX,80
Mov BL,Special
Mov Attr,BL
Call Show
Ret
Set1 Endp
; Выводит строку 25
Set25 Proc Near
Push DI
Push SI
Mov DH,25
Mov DL,1
Mov CX,Pr_Len
Mov BL,Special
Mov Attr,BL
Mov SI,Offset Prompt
Call Show
Mov AH,2
Mov DX,1808h
Mov BX,0
Int 10H
Pop SI
Pop DI
Ret
Set25 Endp
; Выводит сообщение в строке 25
Msg25 Proc Near ;SI - указатель на текст
Mov DH,25
Mov DL,10
Mov CX,EofLen
Mov BL,Special
Mov Attr,BL
Call Show
Mov BL,Normal
Mov Attr,BL
Ret
Msg25 Endp
; Инициализация необходимых данных
InitCrt Proc Near
Push ES
Mov AX,Bios
Mov ES,AX
Mov CX,ES:Cols ;Количество столбцов
Mov Crt_Col,CX
Mov DX,ES:A6845 ;Порт состояния
Add DX,6
Mov Crt_Prt,DX
Mov Crt_Buf,0B800h ;Адрес видео буфера (color)
Mov BX,ES:Flag
And BX,30h
Cmp BX,30h
Jne CrtSet
Mov Crt_Buf,0B000h ;Адрес видео буфера (mono)
CrtSet: Pop ES
Ret
InitCrt Endp
; HELP - Выводит управляющие клавиши
Help Proc Near
Call Clear
Mov DX,0200h
Mov AH,2
Sub BH,BH
Mov BL,Foregrd
Int 10h
Mov DX,Offset HelpMsg
Mov AH,9
Int 21h
Mov AH,2
Mov DX,1808h
Sub BX,BX
Int 10H
Ret
Help Endp
; Извлекает имя файла с командной строки или из введенной
GetParm Proc Near
Xor AX,AX
Xor CX,CX
Mov AL,Byte Ptr DS:[80h]
Or CX,AX
Jz GetFile
Mov DI,Offset Filenm
Mov SI,81h
Blanks: Lodsb
Cmp AL,' '
Je Skipit
Stosb
Skipit: Loop Blanks
Ret
GetFile:
Mov DX,Offset AskFile
Mov AH,9
Int 21H
Mov AH,0AH
Mov DX,Offset Keyin
Int 21h
Sub BL,BL
Or BL,Keyout
Jz GetFile
Mov Filenm[BX],0
Ret
GetParm Endp
; Открывает файл
Open Proc Near
Mov OpenCod,0
Mov DX,Offset Filenm
Mov AL,0
Mov AH,3DH
Int 21H
Mov Handle,AX
Jnc Opened
Mov OpenCod,AX
Cmp AL,2
Jl Error
Cmp AL,5
Ja Error
Sub BX,BX
Mov BL,AL
Mov CL,4
Shl BX,CL
Lea DX,Code2-32[BX]
Jmp Error2
Error: Aam
Xchg AL,AH
Or OpenCod,AX
Mov DX,Offset OpenMsg
Error2: Mov AH,9
Int 21H
Opened: Cmp OpenCod,0
Ret
Open Endp
List Endp
PgmSize Equ ($-Cseg+16)/16 ;Размер программы в параграфах
Cseg Ends
End List