[comp.lang.pascal] INT 25 & 26 under DOS 4.01

maoursler@miavx0.ham.muohio.edu (08/09/90)

Hiya,

	I hope someone out there can help me.  I am trying to
	modify a program I wrote before.  The program reads and
	writes information to the boot sector.  No problem.  Works
	just fine.  However... Now I need to read and write from
	a hard disk under DOS 4.01 with a partition > 32MB.

	I have the info on 'how' to do it.  I know I am supposed to
	alter the way INT 25 and 26 work by using a control block structure.
	Problem is, it doesn't work.  I obviously am messing this up.

	If anyone out there has examples of how to do this, I would
	really love to see them.  Thanks in advance.

						- Miles -

	Replies to this newsgroup please.

andyross@ddsw1.MCS.COM (Andrew Rossmann) (08/10/90)

In article <219.26c03934@miavx0.ham.muohio.edu> maoursler@miavx0.ham.muohio.edu writes:
>Hiya,
>
>	I hope someone out there can help me.  I am trying to
>	modify a program I wrote before.  The program reads and
>	writes information to the boot sector.  No problem.  Works
>	just fine.  However... Now I need to read and write from
>	a hard disk under DOS 4.01 with a partition > 32MB.
>
>	I have the info on 'how' to do it.  I know I am supposed to
>	alter the way INT 25 and 26 work by using a control block structure.
>	Problem is, it doesn't work.  I obviously am messing this up.
>
>	If anyone out there has examples of how to do this, I would
>	really love to see them.  Thanks in advance.
>
>						- Miles -
>
>	Replies to this newsgroup please.

  This is the method used in my Infoplus program. It should work fine,
although it will not recognize the large partitions used under the various
DOS 3.31's.
  I should also point out that you only need to use the revised method if a
disk is using a 'large' partition. It is mandatory then, otherwise you can
use either the new or old methods.

  Andrew Rossmann
  andyross@ddsw1.MCS.COM

----cut here-----
;Read sector(s) from a disk under (most) any DOS version. From Infoplus
; 1.21 by Andrew Rossmann

        public  DISKREAD

;--------------------------------------------------------------------
CODE	segment byte

DISKREAD        proc    near

assume cs:CODE, ds:DATA, es:nothing
; Pascal format:
;{$L diskread}
;function diskread(drive: byte; starting_sector, number_of_sectors: word;
;           var buffer): word; external;
;
;       On entry:
;
;               BP
;       SP =>   near return address
;               offset  of disk buffer
;               segment "   "     "
;               number of sectors to read
;               starting logical sector number
;               drive number (0=A, 1=B, etc.)
;
;       On exit:
;
;               AX      = function result
;                       00      - function successful
;                       01..FF  - DOS INT 25H error result

        drive                   equ     [bp + 12]
        starting_sector         equ     [bp + 10]
        number_of_sectors       equ     [bp + 8]
        buffer                  equ     [bp + 4]

        push    bp
        mov     bp,sp
        mov     ax,3000h                ;get DOS version
        int     21h
        cmp     al,4                    ;DOS 4?
        jb      read3                   ;Read assuming DOS 3.x
        mov     al,drive
        mov     bx,starting_sector      ;copy info into parameter block
        mov     extd_starting_sector_lo,bx
        mov     extd_starting_sector_hi,0       ;We're only using lower part
        mov     bx,number_of_sectors
        mov     extd_number_of_sectors,bx
        les     bx,buffer               ;get seg:ofs of buffer in ES:BX
        mov     extd_bufofs,bx          ;put into block
        mov     extd_bufseg,es
        mov     bx,offset dos4_block    ;DS:BX points to block
        mov     cx,-1                   ;-1 means extended read
        push    ds                      ;save DS (not really needed, but lets
                                        ;me share code with DOS 3 read.)
        jmp     short readit

read3:  mov     al,drive
        mov     dx,starting_sector
        mov     cx,number_of_sectors
        push    ds
        lds     bx,buffer               ;get seg:ofs of buffer in DS:BX
readit: int     25H
        inc     sp                      ; fix broken stack
        inc     sp
        pop     ds
        jc      short diskread_01
        xor     ax,ax

diskread_01:

        pop     bp
        ret     10

DISKREAD        endp

CODE	ends

DATA	segment byte

; DOS 4.0 extended read parameter block
dos4_block                      label   byte
extd_starting_sector_lo         dw      ?
extd_starting_sector_hi         dw      ?
extd_number_of_sectors          dw      ?
extd_bufofs                     dw      ?
extd_bufseg                     dw      ?

DATA    ends

        end

--cut here---