The source can be downloaded as a file.
;******************************************************************
;* Disk Editor for PCs by TANEL, September 1993 *
;* It can recognize two floppy drives ,<A> and <B>, and *
;* two physical hard drives,<C> and <D> *
;* (There is no size limitation for drives.) *
;******************************************************************
;
.8086
code segment para public 'code'
assume cs:code,ds:code,es:code,ss:code
;
org 100h
;
begin: jmp view
;
dos_flag db 0f0h
temp db ?
src_temp db 0
adres dw 0
src_adres dw 0
part_msg db 0ffh
counter db 10
len dw 77
pos label word
row db 23
col db 00
video_page db 00
cursor_cfg dw 0000
work_area label word
left_lim db ?
right_lim db ?
read_wrt db 00
digit label word
count db 0
divider db 0
src_sector label dword
src_sec_l dw 0000h
src_sec_h dw 0000h
abs_sector label dword
abs_sec_l dw 0000h
abs_sec_h dw 0000h
drv_type db 'X'-'A'
dsk_prm label dword
sec_track dw 1h
head_sec dw 2h
max_sector label dword
max_sec_l dw 0
max_sec_h dw 0
boot_sector label dword
boot_l dw 0
boot_h dw 0
fat1_sector label dword
fat_1_l dw 0
fat_1_h dw 0
fat2_sector label dword
fat_2_l dw 0
fat_2_h dw 0
root_sector label dword
root_l dw 0
root_h dw 0
data_sector label dword
data_l dw 0
data_h dw 0
part1_sector label dword
part_1_l dw 0
part_1_h dw 0
part2_sector label dword
part_2_l dw 0
part_2_h dw 0
part3_sector label dword
part_3_l dw 0
part_3_h dw 0
part4_sector label dword
part_4_l dw 0
part_4_h dw 0
part1_no_sec label dword
part_1_l1 dw 0
part_1_h1 dw 0
part2_no_sec label dword
part_2_l1 dw 0
part_2_h1 dw 0
part3_no_sec label dword
part_3_l1 dw 0
part_3_h1 dw 0
part4_no_sec label dword
part_4_l1 dw 0
part_4_h1 dw 0
adres_line db 1,13,47,'-0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F'
info_line db 19,1,78,'Drive: Logical Sector: of ; H of H'
part_info db 'Par1Par2Par3Par4'
auth_line db 0,25,25,13,18,28,20,52,14,13,18,29,24,27,52,31,1,53,0,52,11,34,52,29,10,23,14,21
msg_view db 21,0,77,'<ESC>:Exit <PgUp>:Backward <PgDn>:Forward Ctrl x:Drive selection'
msg_view1 db 23,0,78,'F1:Edit F2:Jump to sector F3:Boot F4:Fat1 F5:Fat2 F6:Root F7:Data'
msg_view1_hd db 23,0,78,'F1:Edit F2:Jump to sector F3:Part.1 F4:Part.2 F5:Part.3 F6:Part.4 F7:DOS'
msg_edit db 21,0,72,'<ESC>:Cancel <PgUp>:Backward <PgDn>:Forward <-, ->, ^, v Cursor'
msg_edit1 db 23,0,78,'F1:Update F2:Write F3:Fill File;[F4:Write F5:Read] F6:Mode F7:Search F8:Next'
msg_conf db 23,14,49,'.............. ARE YOU SURE ? [Y/N] .............'
msg_read db 23,21,20,'RELATIVE SECTOR NO :'
msg_search db 23,21,8,'String :'
msg_find_next db 23,21,11,'Searching !'
msg_not_found db 23,25,21,'String is not found !'
msg_fill db 23,31,10,'Constant :'
msg_file db 23,24,25,'File Name : .BIN',0
not_ready_msg db 23,25,26,'!!! Drive is not ready !!!'
wrt_protec_msg db 23,25,31,'!!! Disk is write-protected !!!'
bad_sec_msg db 23,25,18,'!!! Bad sector !!!'
new_disk_msg db 23,25,33,'!!! Diskette has been changed !!!'
no_sector_msg db 23,25,24,'!!! Sector not found !!!'
invalid_media_msg db 23,25,21,'!!! Invalid media !!!'
crc_error_msg db 23,25,17,'!!! CRC error !!!'
bad_drv_msg db 23,25,30,'!!! Drive is not avaliable !!!'
gen_bad_drv_msg db 23,25,34,'!!! General Drive/Disket Error !!!'
valid_codes db 48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70
db 71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90
db 94,95,123,125,126,33,35,36,37,38,39,40,41,45,64,96,32,"."
inp_buffer db 512 dup (0)
scr_buffer db 80 dup (20h)
even
src_buffer db 16 dup ('find')
;
inp_buffer1 equ offset inp_buffer-58
scr_start equ 0302h ;3rd row, 4rd column
scr_left equ 3 ;starts from 0
scr_right equ 58 ;maximum 79
scr_top equ 2 ;starts from 0
scr_bottom equ 17 ;maximum 23
F1 equ 59
F2 equ 60
F3 equ 61
F4 equ 62
F5 equ 63
F6 equ 64
F7 equ 65
F8 equ 66
Ctrl_key equ 0
Ctrl_A equ 1
Ctrl_B equ 2
Ctrl_C equ 3
Ctrl_D equ 4
Escape equ 27
PgUp equ 73
PgDn equ 81
Left_arrow equ 75
Right_arrow equ 77
Up_arrow equ 72
Down_arrow equ 80
;
view proc near
call video_def
call frame
call invalid_data
call cursor_disab
jmp view_msg_ret
view1: mov [read_wrt],2
call rd_wrt_sec
view_msg_ret: mov si,offset msg_view+3
call wrt_msg
mov si,offset msg_view1+3
cmp [dos_flag],0ffh
jnz dos_msg
mov si,offset msg_view1_hd+3
dos_msg: call wrt_msg
go_back: mov [adres],0
next_scr: call dump_scr
view_wait: mov ah,0
int 16h
cmp al,Escape
jz bye
cmp al,Ctrl_A
jnz view_ctrl_b
call sel_drv
view_ctrl_b: cmp al,Ctrl_B
jnz view_ctrl_c
call sel_drv
view_ctrl_c: cmp al,Ctrl_C
jnz view_ctrl_d
call sel_h_drv
view_ctrl_d: cmp al,Ctrl_D
jnz view_ctrl_key
call sel_h_drv
view_ctrl_key:cmp al,Ctrl_key
jnz view_wait
cmp ah,F3
jnz view_f4
call boot
view_f4: cmp ah,F4
jnz view_f5
call fat1
view_f5: cmp ah,F5
jnz view_f6
call fat2
view_f6: cmp ah,F6
jnz view_f7
call root
view_f7: cmp ah,F7
jnz view_f1
call datum
view_f1: cmp ah,F1
jnz view_f2
call edit
view_f2: cmp ah,F2
jnz view_pgu
call jump_sec
view_pgu: cmp ah,PgUp
jnz view_pgd
call view_pgup
view_pgd: cmp ah,PgDn
jnz view_wait
call view_pgdn
bye: mov cx,[cursor_cfg]
mov ah,01h
int 10h
call cls
mov ah,4ch
int 21h
view endp
;
edit proc near
pop ax
mov ax,offset view1
push ax
mov [work_area],380ah
mov si,offset msg_edit+3
call wrt_msg
fill_ret: mov si,offset msg_edit1+3
call wrt_msg
call cursor_type
page_ret: sub [adres],100h
mov [row],scr_top
mov ah,[left_lim]
mov [counter],ah
search_ret: mov [col],scr_left
call wrt_line
mov ah,02h
mov bh,[video_page]
mov dh,[row]
mov dl,[counter]
add dl,scr_left
int 10h
edit_wait: mov ah,0
int 16h
cmp al,Escape
jnz edit_ctrl_key
edit_bye: call cursor_disab
ret
edit_ctrl_key:cmp al,Ctrl_key
jz edit_f1
call enter
edit_f1: cmp ah,F1
jnz edit_f2
call update
edit_f2: cmp ah,F2
jnz edit_f3
call write_to
edit_f3: cmp ah,F3
jnz edit_f4
call fill
edit_f4: cmp ah,F4
jnz edit_f5
mov [read_wrt],1
call file_rd_wrt
edit_f5: cmp ah,F5
jnz edit_f6
mov [read_wrt],0
call file_rd_wrt
edit_f6: cmp ah,F6
jnz edit_f7
call toggle_mode
edit_f7: cmp ah,F7
jnz edit_f8
call search
edit_f8: cmp ah,F8
jnz edit_pgu
call find_next
edit_pgu: cmp ah,PgUp
jnz edit_pgd
call edit_pgup
edit_pgd: cmp ah,PgDn
jnz edit_left
call edit_pgdn
edit_left: cmp ah,Left_arrow
jnz edit_right
stc
call arrows
edit_right: cmp ah,Right_arrow
jnz edit_up
clc
call arrows
edit_up: cmp ah,Up_arrow
jnz edit_down
call edit_up_arrow
jmp search_ret
edit_down: cmp ah,Down_arrow
jz edit_down_arr
jmp edit_wait
edit_down_arr:call edit_dn_arrow
jmp search_ret
edit endp
;
edit_pgup proc near
cmp [adres],100h
jb edit_pg_ret
mov [adres],0
jmp edit_pg_com
edit_pgup endp
;
edit_pgdn proc near
cmp [adres],100h
jge edit_pg_ret
mov [adres],100h
edit_pg_com: call dump_scr
pop ax
mov ax,offset page_ret
push ax
edit_pg_ret: ret
edit_pgdn endp
;
edit_up_arrow proc near
cmp [row],scr_top
jz edit_up_ret
dec [row]
sub [adres],10h
edit_up_ret: ret
edit_up_arrow endp
;
edit_dn_arrow proc near
cmp [row],scr_bottom
jz edit_dn_ret
inc [row]
add [adres],10h
edit_dn_ret: ret
edit_dn_arrow endp
;
arrows proc near
jc left_arrow1
mov al,[right_lim]
cmp [counter],al
jz next_line
mov bl,01h
jmp arrow_common
left_arrow1: mov al,[left_lim]
cmp [counter],al
jz prev_line
mov bl,0ffh
arrow_common: add [counter],bl
cmp [left_lim],58
jz arrow_ret
mov al,[counter]
mov ah,0
mov bh,3
idiv bh
cmp ah,0
jnz arrow_ret
add [counter],bl
arrow_ret: pop ax
mov ax,offset search_ret
push ax
ret
next_line: cmp [row],scr_bottom
jz arrow_ret
mov [col],scr_left
call wrt_line
mov al,[left_lim]
mov [counter],al
mov ah,Down_arrow
ret
prev_line: cmp [row],scr_top
jz arrow_ret
mov al,[right_lim]
mov [counter],al
mov ah,Up_arrow
ret
arrows endp
;
toggle_mode proc near
pop ax
mov ax,offset search_ret
push ax
mov bh,3
mov ah,0
mov al,[counter]
sub al,[left_lim]
cmp [left_lim],10
jz ascii_mode
mov [work_area],380ah
mul bh
add al,10
mov [counter],al
ret
ascii_mode: mov [work_area],493ah
div bh
add al,3ah
mov [counter],al
ret
toggle_mode endp
;
file_rd_wrt proc near
call get_file_name
jc file_rd_wr_rt
mov ax,3d00h
sub ah,[read_wrt]
int 21h
push ax
mov bx,ax
mov dx,offset inp_buffer
mov cx,512
mov ah,3fh
add ah,[read_wrt]
int 21h
pop bx
mov ah,3eh
int 21h
file_rd_wr_rt:mov [adres],0
call dump_scr
pop ax
mov ax,offset fill_ret
push ax
ret
file_rd_wrt endp
;
get_file_name proc near
mov si,offset msg_file+3
call wrt_msg
mov di,offset scr_buffer+35
mov si,offset scr_buffer+43
mov [digit],52
call read_str
jnc fname_end
ret
fname_end: mov dx,offset scr_buffer+36
xor cx,cx
ret
get_file_name endp
;
find_next proc near
mov si,offset msg_find_next+3
call wrt_msg
mov ax,[src_sec_l]
xchg [abs_sec_l],ax
mov [src_sec_l],ax
mov ax,[src_sec_h]
xchg [abs_sec_h],ax
mov [src_sec_h],ax
inc [src_adres]
cmp [src_adres],512
jz find_next_go
jmp do_search
find_next_go: mov [src_adres],0
jmp sorry
find_next endp
;
search proc near
no_nibble: mov ax,[abs_sec_l]
mov [src_sec_l],ax
mov ax,[abs_sec_h]
mov [src_sec_h],ax
mov ax,[adres]
mov [src_adres],ax
mov si,offset msg_search+3
call wrt_msg
cmp [left_lim],10
jnz ascii_search
mov si,offset scr_buffer+48
mov [digit],16
call read_str
jc search_end
mov bp,di
shr di,1
jnc no_nibble
mov [src_temp],0
mov di,offset src_buffer
mov si,offset scr_buffer+30
src_loop: lodsw
xchg ah,al
call ascii_hex
inc [src_temp]
mov [di],ah
inc di
cmp si,bp
jb src_loop
jmp do_search
not_found: mov si,offset msg_not_found+3
call wrt_msg
mov ah,0
int 16h
search_end: mov ax,[src_sec_l]
mov [abs_sec_l],ax
mov ax,[src_sec_h]
mov [abs_sec_h],ax
mov [read_wrt],2
call rd_wrt_sec
mov [adres],0
call dump_scr
pop ax
mov ax,offset fill_ret
push ax
ret
ascii_search: mov si,offset scr_buffer+24
mov [digit],0fffh
call read_str
jc search_end
mov cx,di
mov si,offset scr_buffer+30
mov di,offset src_buffer
sub cx,si
mov [src_temp],cl
rep movsb
do_search: mov bp,offset inp_buffer
add bp,[src_adres]
src_reset: mov di,bp
mov si,offset src_buffer
lodsb
check_next: scasb
jz do_rest
cmp di,offset inp_buffer+512
jnz check_next
mov ah,1
int 16h
jz sorry
cmp al,escape
jz search_end
sorry: mov ax,[max_sec_h]
cmp [abs_sec_h],ax
jnz can_be_found
mov ax,[max_sec_l]
cmp [abs_sec_l],ax
jz not_found
can_be_found: add [abs_sec_l],1
jnz get_new_sec
inc [abs_sec_h]
get_new_sec: mov [read_wrt],2
mov [src_adres],0
call rd_wrt_sec
jnc do_search
cmp al,escape
jnz lets_go
jmp search_end
is_single: dec ah
jz sorry
jmp short single_byte
lets_go: mov si,offset msg_find_next+3
call wrt_msg
jmp do_search
do_rest: mov ah,[src_temp]
mov bp,di
cmp di,offset inp_buffer+512
jz is_single
dec ah
jz single_byte
do_rest_loop: lodsb
scasb
jnz src_reset
dec ah
jnz do_rest_loop
single_byte: mov ax,bp
sub ax,offset inp_buffer+1
push ax
and ax,0f00h
mov [adres],ax
call dump_scr
mov si,offset msg_edit1+3
call wrt_msg
call cursor_type
pop ax
mov [adres],ax
mov [src_adres],ax
and [adres],0fff0h
xor dx,dx
mov bx,16
div bx
and al,0fh
add al,scr_top
mov [row],al
xchg al,dl
mov bl,3
cmp [left_lim],10
jnz asc_hex
mul bl
asc_hex: add al,[left_lim]
mov [counter],al
mov ax,[abs_sec_l]
mov [src_sec_l],ax
mov ax,[abs_sec_h]
mov [src_sec_h],ax
pop ax
mov ax,offset search_ret
push ax
ret
search endp
;
read_str proc near
call cursor_type
rd_str_wait: call cursor_pos
mov ah,0
int 16h
cmp al,27
jnz rd_str_cont
call cursor_disab
stc
ret
rd_str_cont: cmp al,10
jz rd_str_end
cmp al,13
jz rd_str_end
cmp al,08h
jz back
cmp [digit],0fffh
jnz is_not_ascii
call make_it_hex
cmp ah,al
jnz rd_str_wait
jmp is_ascii
is_not_ascii: call is_it_valid
jnz rd_str_wait
is_ascii: cmp di,si
jz rd_str_wait
inc di
mov [di],al
call disp
jmp rd_str_wait
rd_str_end: call cursor_disab
clc
ret
back: cmp di,si
jz rd_str_wait
mov byte ptr [di],20h
dec di
call disp
jmp rd_str_wait
read_str endp
;
is_it_valid proc near
push di
cmp al,'a'
jl not_lower
cmp al,'z'
jg not_lower
sub al,'a'-'A'
not_lower: mov di,offset valid_codes
mov cx,[digit]
repnz scasb
pop di
ret
is_it_valid endp
;
enter proc near
cmp [left_lim],10
jnz ascii_enter
mov [digit],16
call is_it_valid
jz it_is_hex
not_ascii: pop ax
mov ax,offset edit_wait
push ax
ret
ascii_enter: call make_it_hex
cmp ah,al
jnz not_ascii
mov si,[adres]
mov bl,[counter]
mov bh,0
mov inp_buffer1[si+bx],al
jmp enter_ret
it_is_hex: mov si,offset scr_buffer
mov bl,[counter]
mov bh,0
add si,bx
mov [si],al
mov ax,bx
mov bl,3
idiv bl
cmp ah,1
jz enter1
dec si
enter1: mov bx,[si]
sub al,3
mov ah,0
mov si,[adres]
xchg ax,bx
xchg ah,al
call ascii_hex
mov inp_buffer[si+bx],ah
enter_ret: mov ah,77
ret
enter endp
;
write_to proc near
call get_hexadec
jc do_not_wrt
push ax
call confirm
pop ax
jc do_not_wrt
mov [abs_sec_l],ax
jmp do_wrt
write_to endp
;
update proc near
call confirm
jc do_not_wrt
do_wrt: mov [read_wrt],3
call rd_wrt_sec
do_not_wrt: pop ax
mov ax,offset edit_bye
push ax
ret
update endp
;
fill proc near
mov si,offset msg_fill+3
call wrt_msg
cmp [left_lim],10
jnz ascii_fill
mov si,offset scr_buffer+43
mov [digit],16
call read_str
jc fill_end
cmp di,si
jnz fill_it
mov di,offset scr_buffer+42
mov ax,[di]
xchg ah,al
jmp fill_comm
ascii_fill: mov si,offset scr_buffer+42
mov [digit],0fffh
call read_str
jc fill_end
mov di,offset scr_buffer+42
mov ax,[di]
mov ah,al
jmp ascii_fill_1
fill_it: mov di,offset scr_buffer+42
mov ax,[di]
fill_comm: call ascii_hex
ascii_fill_1: mov cx,256
mov di,offset inp_buffer
mov al,ah
rep stosw
fill_end: mov [adres],0
call dump_scr
pop ax
mov ax,offset fill_ret
push ax
ret
fill endp
;
get_hexadec proc near
mov si,offset msg_read+3
call wrt_msg
mov si,offset scr_buffer+49
mov [digit],16
call read_str
jnc get_hex_end
ret
get_hex_end: mov cx,di
sub cx,offset scr_buffer+41
mov si,offset scr_buffer+42
xor ax,ax
calc_sec: mov bx,16
mul bx
mov bl,byte ptr [si]
cmp bl,'A'
jl num
sub bl,37h
num: and bl,0fh
clc
add ax,bx
adc dx,0
inc si
loop calc_sec
cmp dx,[max_sec_h]
jg no_valid_sec
jnz valid_sec
cmp ax,[max_sec_l]
jbe valid_sec
no_valid_sec: mov si,offset no_sector_msg+3
call wrt_msg
mov ah,0
int 16h
stc
ret
valid_sec: clc
ret
get_hexadec endp
;
confirm proc near
mov si,offset msg_conf+3
call wrt_msg
conf_wait: mov ah,0
int 16h
cmp al,'y'
jz positive
cmp al,'Y'
jz positive
cmp al,'n'
jz negative
cmp al,'N'
jnz conf_wait
negative: stc
ret
positive: clc
ret
confirm endp
;
sel_h_drv proc near
sub al,3
or al,80h
mov [temp],al
mov dl,al
mov ah,15h
int 13h
jnc no_hd_error
drv_not_exist:call dsk_error
not_hd: pop ax
mov ax,offset view_msg_ret
push ax
ret
no_hd_error: or ah,ah
jz drv_not_exist
cmp ah,3
jnz not_hd
push es
push ds
mov al,[temp]
mov [drv_type],al
and al,0fh
mov ah,14h
mul ah
mov bx,ax
xor ax,ax
mov es,ax
mov si,es:[0104h+bx]
mov ds,es:[0106h+bx]
mov ax,[si]
xor cx,cx
xor bx,bx
mov bl,2[si]
mov cl,0eh[si]
mul bx
mul cx
pop ds
sub ax,1
sbb dx,0
mov [max_sec_l],ax
mov [max_sec_h],dx
xor dx,dx
mov ax,cx
mul bx
mov [head_sec],ax
mov [sec_track],cx
pop es
xor ax,ax
mov [abs_sec_l],ax
mov [abs_sec_h],ax
mov [read_wrt],2
call rd_wrt_sec
; jc hd_error ; *********************
mov si,offset inp_buffer+1beh+08h
mov di,offset part1_sector
mov cx,4
part_table: movsw
movsw
mov ax,[si]
mov 12[di],ax
mov ax,2[si]
mov 14[di],ax
add si,0ch
loop part_table
mov [dos_flag],0ffh
mov [part_msg],0ffh
pop ax
mov ax,offset view_msg_ret
push ax
ret
sel_h_drv endp
;
sel_drv proc near
dec al
xchg [drv_type],al
mov [temp],al
pop ax
mov ax,offset view_msg_ret
push ax
mov [read_wrt],2
xor ax,ax
mov [abs_sec_l],ax
mov [abs_sec_h],ax
call rd_wrt_sec
jnc drv_ready
mov al,[temp]
mov [drv_type],al
ret
drv_ready: xor bx,bx
mov [boot_l],bx
mov [boot_h],bx
mov [dos_flag],0f0h
hd_entry: mov si,offset inp_buffer+11
mov ax,8[si]
xor dx,dx
or ax,ax
jnz maximum_sec
mov ax,15h[si]
mov dx,17h[si]
maximum_sec: add ax,[boot_l]
adc dx,[boot_h]
sub ax,1
sbb dx,0
mov [max_sec_l],ax
mov [max_sec_h],dx
mov ax,13[si]
mov [sec_track],ax
mov cx,15[si]
xor dx,dx
mul cx
mov [head_sec],ax
mov ax,[boot_l]
mov dx,[boot_h]
add ax,1
adc dx,0
mov [fat_1_l],ax
mov [fat_1_h],dx
add ax,11[si]
adc dx,0
mov [fat_2_l],ax
mov [fat_2_h],dx
xor bh,bh
mov bl,byte ptr 5[si]
xor dx,dx
mov ax,11[si]
mul bx
add ax,[fat_1_l]
adc dx,[fat_1_h]
mov [root_l],ax
mov [root_h],dx
mov ax,6[si]
xor dx,dx
mov bx,32
mov cx,512
mul bx
div cx
add ax,[root_l]
adc dx,[root_h]
mov [data_l],ax
mov [data_h],dx
mov [adres],0
ret
sel_drv endp
;
view_pgup proc near
pop ax
cmp [adres],200h
jnz view_pgup1
mov ax,offset go_back
push ax
ret
view_pgup1: cmp [abs_sec_h],0
jnz view_pgup2
cmp [abs_sec_l],0
jnz view_pgup2
mov ax,offset view_wait
push ax
ret
view_pgup2: sub [abs_sec_l],1
sbb [abs_sec_h],0
cmp [abs_sec_h],0ffffh
jnz view_pgup3
inc [abs_sec_h]
view_pgup3: mov [read_wrt],2
call rd_wrt_sec
mov [adres],100h
mov ax,offset next_scr
push ax
ret
view_pgup endp
;
view_pgdn proc near
pop ax
cmp [adres],100h
jnz view_pgdn1
mov ax,offset next_scr
push ax
ret
view_pgdn1: mov ax,[max_sec_h]
cmp [abs_sec_h],ax
mov bx,offset view_wait
jnz view_pgdn1_2
mov ax,[max_sec_l]
cmp [abs_sec_l],ax
jz view_pgdn2
view_pgdn1_2: add [abs_sec_l],1
jnz view_pgdn1_3
inc [abs_sec_h]
view_pgdn1_3: mov bx,offset view1
view_pgdn2: push bx
ret
view_pgdn endp
;
boot proc near
cmp [dos_flag],0ffh
jz partit
mov ax,[boot_l]
mov dx,[boot_h]
jmp view_com_ret
boot endp
;
fat1 proc near
cmp [dos_flag],0ffh
jz partit
mov ax,[fat_1_l]
mov dx,[fat_1_h]
jmp view_com_ret
fat1 endp
;
fat2 proc near
cmp [dos_flag],0ffh
jz partit
mov ax,[fat_2_l]
mov dx,[fat_2_h]
jmp view_com_ret
fat2 endp
;
root proc near
cmp [dos_flag],0ffh
jz partit
mov ax,[root_l]
mov dx,[root_h]
jmp view_com_ret
root endp
;
datum proc near
cmp [dos_flag],0ffh
jz find_dos
mov ax,[data_l]
mov dx,[data_h]
jmp view_com_ret
partit: sub ah,61
shl ah,1
shl ah,1
mov bl,ah
xor bh,bh
mov ax,offset part1_sector+0[bx]
mov dx,offset part1_sector+2[bx]
push ax
or ax,dx
pop ax
jz not_good_part
push ax
push dx
add ax,offset part1_no_sec+0[bx]
adc dx,offset part1_no_sec+2[bx]
mov [max_sec_l],ax
mov [max_sec_h],dx
pop dx
pop ax
mov [part_msg],bl
jmp view_com_ret
not_good_part:pop ax
mov ax,offset go_back
push ax
ret
find_dos: mov bl,[part_msg]
cmp bl,0ffh
jz not_good_part
xor bh,bh
mov ax,offset part1_sector+0[bx]
mov dx,offset part1_sector+2[bx]
this_time: mov [abs_sec_l],ax
mov [abs_sec_h],dx
mov [boot_l],ax
mov [boot_h],dx
push ax
push dx
mov [read_wrt],2
inc bl
add [dos_flag],bl
call rd_wrt_sec
pop dx
pop ax
cmp [inp_buffer+21],0f8h
jz it_is_boot
mov si,offset inp_buffer+1beh+08h
add ax,[si]
adc dx,2[si]
jmp short this_time
it_is_boot: pop ax
mov ax,offset view_msg_ret
push ax
jmp hd_entry
datum endp
;
jump_sec proc near
call get_hexadec
jc jump_sec_ret
view_com_ret: mov [abs_sec_l],ax
mov [abs_sec_h],dx
jump_sec_ret: pop ax
mov ax,offset view1
push ax
ret
jump_sec endp
;
dump_scr proc near
mov [pos],scr_start
dump_scr1: call wrt_line
inc [row]
add [adres],10h
cmp [row],scr_bottom
jle dump_scr1
call info
ret
dump_scr endp
;
wrt_line proc near
call clr_line
mov ax,ds
mov bx,[adres]
mov cl,4
shr bx,cl
add ax,bx
push es
mov es,ax
mov si,0fh
mov di,offset scr_buffer+56
mov [digit],1002h
trf1: mov al,es:inp_buffer[si]
call make_it_hex
mov offset scr_buffer+58[si],ah
call hex_dec_ascii
dec di
dec si
jns trf1
mov [digit],1004h
mov ax,[adres]
call hex_dec_ascii
mov byte ptr [di],')'
dec di
mov [digit],0a03h
mov ax,[adres]
call hex_dec_ascii
mov byte ptr [di],'('
pop es
mov [len],74
call disp
ret
wrt_line endp
;
make_it_hex proc near
cmp al,20h
jl make_it
cmp al,127
jg make_it
mov ah,al
ret
make_it: mov ah,2eh
ret
make_it_hex endp
;
clr_line proc near
mov cx,40
mov ax,2020h
mov di,offset scr_buffer
rep stosw
ret
clr_line endp
;
rd_wrt_sec proc near
mov ax,[abs_sec_l]
mov dx,[abs_sec_h]
mov cx,[head_sec]
mov bx,[sec_track]
div cx
ror ah,1
ror ah,1
mov ch,al
mov cl,ah
mov ax,dx
xor dx,dx
div bx
inc dl
or cl,dl
mov dh,al
mov dl,[drv_type]
mov al,01h
mov ah,[read_wrt]
mov bx,offset inp_buffer
int 13h
jnc rd_wrt_sec_rt
cmp ah,6
jz rd_wrt_sec
call dsk_error
rd_wrt_sec_rt:ret
rd_wrt_sec endp
;
disp proc near
mov ax,1300h
mov bl,0fh
mov bh,[video_page]
mov cx,[len]
mov dx,[pos]
xchg dh,dl
mov bp,offset scr_buffer
int 10h
ret
disp endp
;
ascii_hex proc near
mov cl,4
sub ax,3030h
cmp ah,0ah
jl num1
sub ah,7
num1: cmp al,0ah
jl num2
sub al,7
num2: shl ah,cl
or ah,al
ret
ascii_hex endp
;
hex_dec_ascii proc near
push si
mov cx,[digit]
xor bx,bx
xchg bl,ch
hex_d_a_loop: xor dx,dx
convert_com: div bx
mov si,dx
mov dl,[offset valid_codes+si]
numeric: mov [di],dl
dec di
loop hex_d_a_loop
pop si
ret
hex_dec_ascii endp
;
hex_dec_asc proc near
mov cx,[digit]
digit_loop: push ax
xor ax,ax
mov bh,2
mov cl,4
dword_loop: mov bl,4
word_loop: mov al,dh
shr ax,cl
div ch
shl dx,cl
or dl,al
dec bl
jnz word_loop
pop bp
push dx
mov dx,bp
dec bh
jnz dword_loop
mov bx,offset valid_codes
mov al,ah
xlat
mov byte ptr [di],al
pop ax
dec di
dec [count]
jnz digit_loop
ret
hex_dec_asc endp
;
cls proc near
mov ax,0600h
mov bh,7
xor cx,cx
mov dx,1850h
int 10h
ret
cls endp
;
info proc near
mov si,offset info_line+3
call wrt_msg_1
mov al,[drv_type]
cmp al,80h
jb floppy
rol al,1
rol al,1
floppy: add al,65
mov di,offset scr_buffer+7
mov [di],al
mov ax,[abs_sec_l]
mov dx,[abs_sec_h]
mov di,offset scr_buffer+41
mov [digit],0a07h
call hex_dec_asc
mov ax,[max_sec_l]
mov dx,[max_sec_h]
mov di,offset scr_buffer+52
mov [count],07h
call hex_dec_asc
mov [digit],1008h
mov di,offset scr_buffer+63
mov ax,[abs_sec_l]
mov dx,[abs_sec_h]
call hex_dec_asc
mov di,offset scr_buffer+76
mov ax,[max_sec_l]
mov dx,[max_sec_h]
mov [count],08h
call hex_dec_asc
mov bl,[part_msg]
cmp bl,0ffh
jz no_part_msg
mov bh,0
mov si,offset part_info
add si,bx
mov di,offset scr_buffer+11
movsw
movsw
no_part_msg: call disp
ret
info endp
;
frame proc near
call clr_line
mov [col],0
mov [len],80
mov cx,23
mov di,offset scr_buffer
mov byte ptr [di],0bah
mov byte ptr 79[di],0bah
frame_loop: mov [row],cl
push cx
call disp
pop cx
loop frame_loop
mov di,offset scr_buffer
push di
mov byte ptr [di],0c9h
inc di
mov ax,0cdcdh
mov cx,39
rep stosw
mov byte ptr [di],0bbh
mov [row],0
call disp
xor di,di
mov byte ptr offset scr_buffer+0[di],0cch
mov byte ptr offset scr_buffer+79[di],0b9h
mov [row],22
call disp
mov [row],20
call disp
mov [row],18
call disp
pop di
mov byte ptr [di],0c8h
mov [row],24
dec [len]
call disp
mov di,offset scr_buffer+4dh
call cursor_pos
mov ax,09bch
mov bl,0fh
mov bh,[video_page]
mov cx,1
int 10h
lea bx,valid_codes
lea si,auth_line+3
lea di,auth_line+3
cld
mov cx,(length auth_line)-3
auth: lodsb
xlat
stosb
loop auth
mov si,offset auth_line+3
call wrt_msg_1
call disp
mov si,offset adres_line+3
call wrt_msg_1
call disp
ret
frame endp
;
cursor_pos proc near
mov ah,02
mov bh,[video_page]
mov dx,di
sub dx,offset scr_buffer-2
mov dh,[row]
int 10h
ret
cursor_pos endp
;
cursor_type proc near
mov ah,1
mov ch,0
mov cl,0fh
int 10h
ret
cursor_type endp
;
cursor_disab proc near
mov ah,1
mov cx,[cursor_cfg]
mov ch,20h
int 10h
ret
cursor_disab endp
;
video_def proc near
mov ah,0fh
int 10h
mov [video_page],bh
mov ah,03
int 10h
mov [cursor_cfg],cx
ret
video_def endp
;
wrt_msg_1 proc near
mov cx,[si-3]
mov [pos],cx
xor ch,ch
mov cl,[si-1]
mov [len],cx
mov di,offset scr_buffer
rep movsb
ret
wrt_msg_1 endp
;
wrt_msg proc near
call clr_line
xor ch,ch
mov cl,[si-2]
mov di,offset scr_buffer
add di,cx
mov cl,[si-3]
mov [row],cl
mov [col],1
mov cl,[si-1]
mov [len],78
rep movsb
call disp
ret
wrt_msg endp
;
invalid_data proc near
mov di,offset inp_buffer
mov cx,64
clr_inp_buf: mov si,offset invalid_media_msg+7
movsw
movsw
movsw
movsw
loop clr_inp_buf
ret
invalid_data endp
;
dsk_reset proc near
mov ah,0
mov dl,[drv_type]
int 13h
ret
dsk_reset endp
;
dsk_error proc near
cmp ah,80h ;drive not ready
jnz dsk_error1
mov si,offset not_ready_msg+3
jmp dsk_err_com
dsk_error1: cmp ah,10h ;CRC error on disk read
jnz dsk_error2
mov si,offset crc_error_msg+3
jmp dsk_err_com1
dsk_error2: cmp ah,0ch ;invalid media
jnz dsk_error3
mov si,offset invalid_media_msg+3
jmp dsk_err_com1
dsk_error3: cmp ah,06h ;diskette change line is active
jnz dsk_error4
mov si,offset new_disk_msg+3
jmp dsk_err_com
dsk_error4: cmp ah,04h ;sector not found
jnz dsk_error5
mov si,offset no_sector_msg+3
jmp dsk_err_com1
dsk_error5: cmp ah,03h ;write-protected disk
jnz dsk_error6
mov si,offset wrt_protec_msg+3
jmp dsk_err_com
dsk_error6: cmp ah,02h ;bad sector
jnz dsk_error7
mov si,offset bad_sec_msg+3
jmp dsk_err_com1
dsk_error7: cmp ah,00h ;drive is not avaliable
jnz dsk_error8
mov si,offset bad_drv_msg+3
jmp dsk_err_com
dsk_error8: mov si,offset gen_bad_drv_msg+3
dsk_err_com1: push si
call invalid_data
pop si
dsk_err_com: call wrt_msg
call dsk_reset
mov ah,0
int 16h
stc
ret
dsk_error endp
;
code ends
;
end begin