[comp.lang.pascal] sector RW with INT 25/

chris.chambers@rose.uucp (CHRIS CHAMBERS) (04/12/91)

>>Hi, DOS Int. 25/26 (dec 37 and 38) do not clean up the stack.  Instead
>>they finish and return to the program with one word left on the stack.
>>This is probably the cause for my following code hanging. I tried to
>>follow intr() with and POP DX but this won't do it.  Can anyone
>>provide a solution (assembly, inline code, ...) to achieve what is
>>intended here.  I do want to use Int 25 instead of 13 hex.

You should be able to adapt the following:

 { -------------------------------------------------------- }
 {  readsector - absolute disk read for sectors             }
 { -------------------------------------------------------- }
 Function ReadSector(Segment, Offset: word; drivecd: byte;
                     Sector, Number: word): integer;
 begin
 Inline(
  $1E/                 {    push ds                 ;save TP's ds}
  $55/                 {    push bp                 ;save TP's bp}
  $8B/$46/<segment/    {    mov  ax,[bp]<segment    ;buffer segment to ax}
  $8E/$D8/             {    mov  ds,ax              ;shift to ds}
  $8B/$5E/<offset/     {    mov  bx,[bp]<offset     ;buffer offset to bx}
  $8A/$46/<drivecd/    {    mov  al,[bp]<drivecd    ;drive code}
  $8B/$56/<sector/     {    mov  dx,[bp]<sector     ;logical sector number}
  $8B/$4E/<number/     {    mov  cx,[bp]<number     ;number sectors to read}
  $CD/$25/             {    int  25h                ;read the sector(s)}
  $BB/>$0000/          {    mov  bx,0               ;clear bx}
  $73/$02/             {    jnc  l1                 ;test for error}
  $8A/$DC/             {    mov  bl,ah              ;error code to bl}
  $59/                 {l1: pop  cx                 ;drop extra stack entry}
  $5D/                 {    pop  bp                 ;restore TP's bp}
  $1F/                 {    pop  ds                 ;restore TP's ds}
  $89/$5E/<readsector);{    mov  [bp]<readsector,bx ;set return code}
 end;

Chris Chambers
---