home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
165
/
MOREDISK.ZIP
/
CHG10.ASM
next >
Wrap
Assembly Source File
|
1986-07-28
|
6KB
|
126 lines
page ,132
cseg segment
assume cs:cseg,ds:cseg,es:cseg
org 100h
start: jmp chg10
opt_char equ 'M' ; MODIFY option character
slash equ '/'
opt_flag db 0 ; Option flag storage
mod_tbl dw 08h ; Original Clusters per sector
dw 08h ; Original Sectors in FAT
dw 04h ; Modified Clusters per sector
dw 15h ; Modified Sectors in FAT
ok_msg db 0Ah,' : Altered--re-boot, re-format, and reload!',0Dh,0Ah,'$'
form_msg db 'Format: CHG10 d: /{M|R}',0Dh,0Ah,'$'
test1_msg db 'Sectors in FAT: $'
test2_msg db 'Sectors per Cluster: $'
test_msgs dw test2_msg
dw test1_msg
error_msg db 'Expected '
expected dw ?
db ', Found '
found dw ?
db 0Dh,0Ah,'$'
chg10 proc near
mov dl,byte ptr ds:[5Ch] ; Get drive id
cmp dl,3d ; If drive id < 3,
jl form_error ; then show correct form
mov si,2d ; Offset for original FAT
call miniopt ; Check for "M" option
je read_boot ; If found, read boot record
mov al,byte ptr [di] ; Get other option
and al,5Fh ; Insure uppercase
cmp al,'R' ; If not "R" option
jne form_error ; then show correct form
mov si,6d ; Offset for modified FAT
; Read boot record
read_boot: mov bx,offset alt_dta ; ES:BX=> alternate DTA
mov cx,0001h ; Cylinder/sector number
mov dh,01h ; Specify head 1
add dl,7Dh ; Compute drive number
mov ax,0201h ; Read 1 sector
int 13h ; *
; Validate changes
mov ax,[bx+16h] ; Get current FAT sectors
cmp ax,[mod_tbl+si] ; If not correct,
jne error ; then error off
sub si,2d ; Adjust for Clusters
mov al,[bx+0Dh] ; Get current cluster count
cmp al,byte ptr [mod_tbl+si] ; If not correct,
jne error ; then error off
; Modify values in DTA and re-write boot record
xor si,6d ; Modify pointer for changes
add si,offset mod_tbl ; *
std ; Decrement pointer (SI)
lodsw ; Get new FAT value
mov [bx+16h],ax ; Put in DTA
lodsw ; Get new cluster value
mov byte ptr [bx+0Dh],al ; Put in DTA
mov ax,0301h ; Write DTA back as boot record
int 13h ; *
mov al,byte ptr ds:[5Ch] ; Get drive id
or al,40h ; Convert to character
mov ok_msg+1,al ; Modify message
mov dx,offset ok_msg ; Tell user disk modified
mov ah,09h ; *
int 21h ; *
int 20h ; End of program
form_error: mov dx,offset form_msg ; Show correct format
mov ah,09h ; *
int 21h ; *
int 20h ; Terminate program
error: push ax ; Save value found
push si ; Save pointer
and si,2d ; Convert to word pointer
mov dx,[test_msgs+si] ; Get correct message to display
mov ah,09h ; Display string
int 21h ; *
pop si ; Restore registers
pop ax ; *
call dec2asc ; Convert AX to decimal
mov found,ax ; Put in message
mov ax,[mod_tbl+si] ; Get expected value
call dec2asc ; Convert to decimal
mov expected,ax ; Put in message
mov dx,offset error_msg ; Show what happened
mov ah,09h ; *
int 21h ; *
int 20h ; *
chg10 endp
miniopt proc near
cld ; Insure forward scan
mov al,slash ; Search for option start
xor ch,ch ; Clear upper CX
mov cl,ds:[80h] ; Get character count
jcxz set_zf ; Exit if no option
mov di,81h ; ES:DI=> comline
repne scasb ; Search for option
jnz mo_exit ; Exit if no option
mov al,byte ptr [di] ; Get option
and al,5Fh ; Insure uppercase
set_zf: cmp al,opt_char ; If correct option, set ZF
mo_exit: ret ; Exit routine
miniopt endp
; DEC2ASC--converts binary value (AL) into two digit, base 10, ASCII
; format number (AX). (Number assumed < 100.)
dec2asc proc near
xor ah,ah ; Clear for division
mov cl,10d ; Isolate ten's and one's
div cl ; with division by 10
or ax,3030h ; Convert to ASCII
ret ; Return to caller
dec2asc endp
alt_dta label byte ; First byte of alternate DTA
cseg ends
end start