cmp al,0
jne name_s
sub bx,2
mov ah,byte ptr fs:[bx]
mov al,byte ptr fs:[bx+1]
cmp ax,6578h ;HEX
jne other1
mov byte ptr fs:[filetype],1
jmp typ_exit
other1:
cmp ax,696eh ;BIN
jne other2
mov byte ptr fs:[filetype],0
jmp typ_exit
other2:
mov byte ptr fs:[filetype],2 ;TXT
typ_exit:
popa
ret
getfilename endp
;==================================
readfile proc
pusha
;open
mov ah,3dh
xor al,al
push fs
pop ds
mov dx,offset filename
int 21h
jc read_error
mov bx,ax
;read
mov ah,3fh
mov cx,32767
push fs
pop ds
mov dx,offset file
int 21h
jc read_error
mov word ptr fs:[filelength],ax
;close
mov ah,3eh
mov bx,word ptr fs:[handle]
int 21h
popa
ret
read_error:
push fs
pop ds
mov dx,offset errmsg
mov ah,9
int 21h
popa
mov ah,4ch
int 21h
readfile endp
;==================================
begin:
xor ah,ah
mov al,3
int 10h
mov ax,seg handle
mov fs,ax
call getfilename
call readfile
mov ah,5
mov ch,48h
int 16h
work:
mov ah,0
int 16h
mov bl,byte ptr fs:[filetype]
cmp ah,50h
jne work_1
cmp bl,0
jne d1
call scroll_downbin
jmp work
d1: cmp bl,1
jne d2
call scroll_downhex
jmp work
d2:
call scroll_downtxt
jmp work
work_1:
cmp ah,48h
jne work_2
cmp bl,0
jne u1
call scroll_upbin
jmp work
u1: cmp bl,1
jne u2
call scroll_uphex
jmp work
u2:
call scroll_uptxt
jmp work
work_2:
cmp ah,51h
jne work_3
cmp bl,0
jne pd1
call scroll_pgdnbin
jmp work
pd1: cmp bl,1
jne pd2
call scroll_pgdnhex
jmp work
pd2:
call scroll_pgdntxt
jmp work
work_3:
cmp ah,49h
jne work_4
cmp bl,0
jne pu1
call scroll_pgupbin
jmp work
pu1: cmp bl,1
jne pu2
call scroll_pguphex
jmp work
pu2:
call scroll_pguptxt
jmp work
work_4:
cmp ah,1
jne work
mov ah,4ch
int 21h
end start
Блок-схема алгоритму