Category : Assembly Language Source Code
Archive   : ABRD40.ZIP
Filename : ABSREAD.C

 
Output of file : ABSREAD.C contained in archive : ABRD40.ZIP
#pragma inline
/*
absread.c - Turbo C 2.0

absread / abswrite functions supporting DOS 4.x and COMPAQ 3.31
with partitions > 32 MB in addition to previous versions of DOS.

Christopher Blum CompuServe 76625,1041
1022 East Wayne Avenue
Wooster, Ohio 44691

*** prototypes in dos.h must be as follows: ***

int _Cdecl absread (int drive, int nsects, long lsect, void *buffer);
****

int _Cdecl abswrite(int drive, int nsects, long lsect, void *buffer);
****

*/

#include
#include

static struct { /* packet for DOS 4.0 */
long sect;
int cnt;
void far *buf;
} d_4;

int absread(int drive, int nsects, long lsect, void *buffer)
{
_AX = _version; /* check DOS version */
asm cmp al,3;
asm ja new;
asm jb old;
asm cmp ah,30;
asm ja new;

old: /* code for prior versions of DOS - use registers */

#if defined(__LARGE__) || defined (__COMPACT__) || defined (__HUGE__)
asm push ds;
asm lds bx,buffer;
#else
asm mov bx,buffer;
#endif
asm mov cx,nsects;
asm mov dx,lsect;
asm mov al,drive;
asm int 25h;
asm pop dx; /* discard saved flags */
#if defined(__LARGE__) || defined (__COMPACT__) || defined (__HUGE__)
asm pop ds;
#endif
asm jmp short done;

new: /* code for DOS 4.0 and Compaq 3.31 - use packet */

d_4.sect = lsect;
d_4.cnt = nsects;
#if defined(__LARGE__) || defined (__COMPACT__) || defined (__HUGE__)
d_4.buf = buffer;
#else
d_4.buf = MK_FP(_DS, buffer);
#endif
asm lea bx,d_4;
asm mov cx,-1;
asm mov al,drive;
asm int 25h;
asm pop dx; /* discard saved flags */

done:
asm jnc good; /* test carry for error */
#if defined (__HUGE__)
asm mov dx,ax; /* huge model trashes ax here */
errno = _DX;
#else
errno = _AX;
#endif
asm mov ax,-1; /* bad - set errno, return -1 */
asm jmp short ret;
asm cmp si,di; /* never executed - makes C save reg variables */
good:
asm xor ax,ax; /* good - return 0 */
ret:
return(_AX);
}

int abswrite(int drive, int nsects, long lsect, void *buffer)
{
_AX = _version; /* check DOS version */
asm cmp al,3;
asm ja new;
asm jb old;
asm cmp ah,30;
asm ja new;

old: /* code for prior versions of DOS - use registers */

#if defined(__LARGE__) || defined (__COMPACT__) || defined (__HUGE__)
asm push ds;
asm lds bx,buffer;
#else
asm mov bx,buffer;
#endif
asm mov cx,nsects;
asm mov dx,lsect;
asm mov al,drive;
asm int 26h;
asm pop dx; /* discard saved flags */
#if defined(__LARGE__) || defined (__COMPACT__) || defined (__HUGE__)
asm pop ds;
#endif
asm jmp short done;

new: /* code for DOS 4.0 and Compaq 3.31 - use packet */

d_4.sect = lsect;
d_4.cnt = nsects;
#if defined(__LARGE__) || defined (__COMPACT__) || defined (__HUGE__)
d_4.buf = buffer;
#else
d_4.buf = MK_FP(_DS, buffer);
#endif
asm lea bx,d_4;
asm mov cx,-1;
asm mov al,drive;
asm int 26h;
asm pop dx; /* discard saved flags */

done:
asm jnc good; /* test carry for error */
#if defined (__HUGE__)
asm mov dx,ax; /* huge model trashes ax here */
errno = _DX;
#else
errno = _AX;
#endif
asm mov ax,-1; /* bad - set errno, return -1 */
asm jmp short ret;
asm cmp si,di; /* never executed - makes C save reg variables */
good:
asm xor ax,ax; /* good - return 0 */
ret:
return(_AX);
}


  3 Responses to “Category : Assembly Language Source Code
Archive   : ABRD40.ZIP
Filename : ABSREAD.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/