home *** CD-ROM | disk | FTP | other *** search
- DOSSEG
- .MODEL medium
-
- PUBLIC _SetBase, _ResBase, _SctrSz
-
- ;========================================================
- ; Copy the diskette parameters and set the sector and
- ; track size. The usage is:
- ;
- ; push <sectors> ;number of sectors per track
- ; push <bytes> ;number of bytes per sector
- ; call _SetBase ;set new parameters
- ;
- ; To restore the diskette parameters:
- ;
- ; call _ResBase ;restore parameters
- ;
- ; DOS might not be able to read diskettes while the new
- ; parameters are in effect, thus the parameters should
- ; be reset before any DOS disk routines are called. The
- ; stack is cleared on exit and all registers are
- ; preserved.
-
- BASE_SIZE EQU 11 ;size of disk parameters
-
- .DATA?
-
- Old_DBase dd ? ;old disk base
- Disk_Parms db BASE_SIZE DUP (?) ;new disk base data
-
- .CODE
-
- SetBasStk STRUC
- registers dw 9 DUP (?)
- retaddr dw 2 DUP (?)
- bytes dw ?
- sectors dw ?
- SetBasStk ENDS
-
- ;routine to set diskette parameters
-
- ASSUME ds:NOTHING, es:@DATA, ss:NOTHING
-
- _SetBase PROC
- push ax
- push bx
- push cx
- push dx
- push di
- push si
- push bp
- push ds
- push es
- mov bp, sp
-
- mov ax, 351eH ;get interrupt and disk pointer
- int 21h ;execute
-
- mov ax, es
- mov ds, ax ;segement of disk parameters
- mov si, bx ;offset
- mov ax, @DATA
- mov es, ax ;data segment
-
- mov word ptr Old_DBase[0], si ;save original offset
- mov word ptr Old_DBase[2], ds ; segment
-
- lea di, Disk_Parms ;parameter location
- mov cx, BASE_SIZE ;size of parameter data
- rep movsb ;copy data
-
- ASSUME ds:@DATA
- mov ax, es
- mov ds, ax ;set main data segment
- lea bx, Disk_Parms ;location of local parameters
-
- mov ax, [bp].bytes ;get the bytes per sector
- call far ptr _SctrSz ;get the sector size
- mov [bx][3], al ;save it
-
- mov al, byte ptr [bp].sectors ;get the sectors per track
- mov [bx][4], al ;save it
-
- mov ax, 251eH ;set interrupt and disk pointer
- mov dx, bx ;load offset, segment (DS) already loaded
- int 21h ;execute
-
- pop es
- pop ds
- pop bp
- pop si
- pop di
- pop dx
- pop cx
- pop bx
- pop ax
- ret 4
- _SetBase ENDP
-
- ;routine to restore diskette parameters
-
- ASSUME ds:@DATA
-
- _ResBase PROC
- push ax
- push dx
- push ds
- mov ax, @DATA
- mov ds, ax ;set data segment
- lds dx, Old_DBase ;load old parameter base
- mov ax, 251eH ;set interrupt and disk pointer
- int 21h ;execute
- pop ds
- pop dx
- pop ax
- ret
- _ResBase ENDP
-
- ; routine to solve X for (AX = 128*2^X), AL returns result
-
- _SctrSz PROC
- push dx
- mov dl, 128 ;divisor
- div dl ;divide
-
- sub ah, ah ;default minimum
- or al, al ;check if zero
- jz Scsz2
-
- mov ah, 8 ;starting number
- Scsz1: dec ah ;decrement power
- shl al, 1 ;check if high bit set
- jnc Scsz1 ;jump if not
-
- Scsz2: mov al, ah
- sub ah, ah
- pop dx
- ret
- _SctrSz ENDP
-
- END
-