Index: libcio/atoi.c
===================================================================
--- libcio/atoi.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/atoi.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -10,5 +10,5 @@
 int16_t atoi(int8_t *cp)
 {
-	register uint16_t i;
+	register int16_t i;
 	register int16_t sign;
 
Index: libcio/blkrd.c
===================================================================
--- libcio/blkrd.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/blkrd.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -70,5 +70,5 @@
 	if ((track NE _b_trak) OR (side NE _b_side)) {	/* track in buffer ? */
 
-		if (brc = BIOS(B_RDWR, 0, &_b_tbuf, _thebpb->dspt, _b_tsec, 0)) {
+		if ((brc = BIOS(B_RDWR, 0, &_b_tbuf, _thebpb->dspt, _b_tsec, 0))) {
 
 			_b_trak = -1;
@@ -111,5 +111,5 @@
 
 #if	TBUFFER
-		if (brc = _secrd(buf, (int16_t)fcp->curdsn)) {
+		if ((brc = _secrd(buf, (int16_t)fcp->curdsn))) {
 #else
 		if (brc = BIOS(B_RDWR, 0, buf, 1, (short)fcp->curdsn, 0)) {
@@ -121,5 +121,5 @@
 		}
 
-		if (rb = _nsic(fcp, _thebpb, _thefat)) {  /* find next sector */
+		if ((rb = _nsic(fcp, _thebpb, _thefat))) {  /* find next sector */
 
 			if (rb EQ -1)		/* see if we had an error */
Index: libcio/blkwr.c
===================================================================
--- libcio/blkwr.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/blkwr.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -100,5 +100,5 @@
 #endif
 
-				if (rc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0)) {
+				if ((rc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0))) {
 
 #if	DEBUGIT
@@ -150,5 +150,5 @@
 #endif
 
-				if (rc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0)) {
+				if ((rc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0))) {
 
 #if	DEBUGIT
@@ -184,5 +184,5 @@
 			}
 
-			fcp->de.bclust = micons(clustr);
+			fcp->de.bclust = micon16((uint16_t)clustr);
 			_ptcl12(_thefat, clustr, 0x0FF8);
 			_fatmod = TRUE;
@@ -201,5 +201,5 @@
 #endif
 
-			if (rc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0)) {
+			if ((rc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0))) {
 
 #if	DEBUGIT
Index: libcio/close.c
===================================================================
--- libcio/close.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/close.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -87,7 +87,10 @@
 */
 
-int16_t _filecl(struct fcb *fp)
+int16_t _filecl(io_arg arg)
 {
+	struct fcb *fp;
 	register int16_t rc;
+
+	fp = (struct fcb *)arg;
 
 	rc = ClsFile(fp);		/* close the FCB */
Index: libcio/close.x
===================================================================
--- libcio/close.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/close.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -8,4 +8,5 @@
 
 #include "biosdefs.h"
+#include "fspars.h"
 #include "stdint.h"
 
@@ -19,4 +20,4 @@
 extern	void		_clsfat(void);
 extern	void		_fd_cls(void);
-extern	int16_t		_filecl(struct fcb *fp);
+extern	int16_t		_filecl(io_arg arg);
 extern	int16_t		close(int16_t fd);
Index: libcio/clusmap.c
===================================================================
--- libcio/clusmap.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/clusmap.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -75,5 +75,5 @@
 
 	nc = 0;
-	clus = micons(fcp->de.bclust);
+	clus = (int16_t)micon16(fcp->de.bclust);
 
 	if (clus) {
@@ -173,12 +173,12 @@
 	printf("  modefl     0x%04x\n",	fcp->modefl);
 
-	printf("  crtime     0x%04x",	micons(fcp->de.crtime));
-	printf("  crdate     0x%04x\n",	micons(fcp->de.crdate));
+	printf("  crtime     0x%04x",	micon16(fcp->de.crtime));
+	printf("  crdate     0x%04x\n",	micon16(fcp->de.crdate));
 
 	printf("  asects   %8ld",	fcp->asects);
-	printf("  flen     %8ld",	miconl(fcp->de.flen));
+	printf("  flen     %8ld",	micon32(fcp->de.flen));
 	printf("  curlen   %8ld\n",	fcp->curlen);
 
-	printf("  bclust   %8d",	micons(fcp->de.bclust));
+	printf("  bclust   %8d",	micon16(fcp->de.bclust));
 	printf("  curcls   %8d",	fcp->curcls);
 	printf("  clsec    %8d\n",	fcp->clsec);
@@ -198,5 +198,5 @@
 */
 
-void MapFAT(int8_t *fat, int16_t ncl, int16_t stops)
+void MapFAT(uint8_t *fat, int16_t ncl, int16_t stops)
 {
 	register int16_t i;
Index: libcio/clusmap.x
===================================================================
--- libcio/clusmap.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/clusmap.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -21,5 +21,5 @@
 extern	FILE		*FILEfl(FILE *fp);
 extern	void		FILEpr(FILE *fp);
-extern	void		MapFAT(int8_t *fat, int16_t ncl, int16_t stops);
+extern	void		MapFAT(uint8_t *fat, int16_t ncl, int16_t stops);
 extern	struct	fcb	*SnapFCB(struct fcb *fcp);
 extern	struct	fcb	*fd2fcb(int16_t fd);
Index: libcio/conin.c
===================================================================
--- libcio/conin.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/conin.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -8,8 +8,8 @@
 #include "ram.h"
 
-int8_t _ConBuf[258];	/* console input buffer */
+uint8_t _ConBuf[258];	/* console input buffer */
 int16_t _CBused;
 
-int16_t _conin(io_arg arg, int8_t *buff, int16_t len)
+int16_t _conin(io_arg arg, void *buff, int16_t len)
 {
 	int16_t 	nbp;
@@ -23,5 +23,5 @@
 		_ConBuf[1] = _ConBuf[2] = 0;
 
-		readbuf(CON_DEV, _ConBuf);
+		readbuf(CON_DEV, (int8_t *)_ConBuf);
 		writeln(CON_DEV, "\r\n");
 
@@ -43,5 +43,5 @@
 	memcpy(buff, (_ConBuf + _CBused), l);
 	_CBused += l;
-	_ConBuf[1] -= l;
+	_ConBuf[1] = (uint8_t)(_ConBuf[1] - l);
 	return (l);
 }
Index: libcio/conin.x
===================================================================
--- libcio/conin.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/conin.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -17,5 +17,5 @@
 
 extern	int16_t		_CBused;
-extern	int8_t		_ConBuf[258];
+extern	uint8_t		_ConBuf[258];
 
 /*
@@ -25,3 +25,3 @@
 */
 
-extern	int16_t		_conin(io_arg arg, int8_t *buff, int16_t len);
+extern	int16_t		_conin(io_arg arg, void *buff, int16_t len);
Index: libcio/conwr.c
===================================================================
--- libcio/conwr.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/conwr.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,10 +16,15 @@
    ============================================================================
 */
-int16_t _conwr(int16_t kind, int8_t *buff, int16_t len)
+int16_t _conwr(io_arg arg, void *buff, int16_t len)
 {
+	struct devtabl *dp;
+	int8_t *buff8;
 	register int16_t count;
 
+	dp = (struct devtabl *)arg;
+	buff8 = buff;
+
 	for (count = 0; count < len; ++count)
-		BIOS(B_PUTC, kind, *buff++);
+		BIOS(B_PUTC, dp->d_kind, *buff8++);
 
 	return(count);
Index: libcio/conwr.x
===================================================================
--- libcio/conwr.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/conwr.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -15,3 +15,3 @@
 */
 
-extern	int16_t		_conwr(int16_t kind, int8_t *buff, int16_t len);
+extern	int16_t		_conwr(io_arg arg, void *buff, int16_t len);
Index: libcio/dirfns.c
===================================================================
--- libcio/dirfns.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/dirfns.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -72,10 +72,10 @@
 */
 
-int8_t *dtunpk(int16_t din, int16_t tin, int8_t *s, int16_t fmt)
+int8_t *dtunpk(uint16_t din, uint16_t tin, int8_t *s, int16_t fmt)
 {
-	register int16_t	ftm, fdt;
+	register uint16_t	ftm, fdt;
 
-	ftm = ((tin << 8) & 0xFF00) | ((tin >> 8) & 0x00FF);
-	fdt = ((din << 8) & 0xFF00) | ((din >> 8) & 0x00FF);
+	ftm = micon16(tin);
+	fdt = micon16(din);
 
 	switch (fmt) {
Index: libcio/dirfns.x
===================================================================
--- libcio/dirfns.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/dirfns.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,4 +16,4 @@
 
 extern	int8_t		*atrstr(int16_t atr, int8_t s[]);
-extern	int8_t		*dtunpk(int16_t din, int16_t tin, int8_t *s, int16_t fmt);
+extern	int8_t		*dtunpk(uint16_t din, uint16_t tin, int8_t *s, int16_t fmt);
 extern	int8_t		*mname(int16_t n);
Index: libcio/fgets.c
===================================================================
--- libcio/fgets.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fgets.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -40,5 +40,5 @@
 
 	while ((i = getchar()) NE EOF AND i NE '\n')
-		*cp++ = i;
+		*cp++ = (int8_t)i;
 
 	*cp = 0;	/* terminate the line */
@@ -55,9 +55,10 @@
 	register int8_t *cp;
 
+	c = 0;
 	cp = s;
 
 	while (--n > 0 AND (c = agetc(fp)) NE EOF) {
 
-		*cp++ = c;
+		*cp++ = (int8_t)c;
 
 		if (c EQ '\n')
Index: libcio/filesys.c
===================================================================
--- libcio/filesys.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/filesys.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -30,5 +30,5 @@
 struct	dirent	*_dptr;			/* internal directory pointer */
 
-uint16_t _thefat[MAXFAT * WDPSEC];	/* file allocation table */
+uint8_t _thefat[MAXFAT * BPSEC];	/* file allocation table */
 
 int16_t	_fatin;				/* FAT has been read */
@@ -47,5 +47,5 @@
 */
 
-uint16_t _cl2lsn(struct bpb *bpp, uint16_t clnum)
+int16_t _cl2lsn(struct bpb *bpp, int16_t clnum)
 {
 	return(bpp->datrec + (bpp->clsiz * (clnum - 2)) );
@@ -59,17 +59,18 @@
 */
 
-uint16_t _gtcl12(int8_t *fat, uint16_t cl)
-{
-	register uint16_t cla, clt;
+int16_t _gtcl12(uint8_t *fat, int16_t cl)
+{
+	int16_t cla;
+	uint16_t clt;
 
 	cla = cl + (cl >> 1);
-	clt = ((uint16_t)0xFF00 & (fat[cla+1] << 8))
-		| ((uint16_t)0x00FF & fat[cla]);
+	clt = (0xFF00u & ((uint16_t)fat[cla + 1] << 8))
+		| (0x00FFu & fat[cla]);
 
 	if (cl & 1)
 		clt >>= 4;
 
-	clt &= (uint16_t)0x0FFF;
-	return(clt);
+	clt &= 0x0FFFu;
+	return((int16_t)clt);
 }
 
@@ -81,10 +82,10 @@
 */
 
-uint16_t _getfat(uint16_t *bufad, struct bpb *bpp, uint16_t nfat)
-{
-	uint16_t fatsec;
+int32_t _getfat(uint8_t *bufad, struct bpb *bpp, int16_t nfat)
+{
+	int16_t fatsec;
 
 	fatsec = nfat ? bpp->fatrec : (bpp->fatrec - bpp->fsiz);
-	return(BIOS(B_RDWR, 0, (int8_t *)bufad, bpp->fsiz, fatsec, 0));
+	return(BIOS(B_RDWR, 0, bufad, bpp->fsiz, fatsec, 0));
 }
 
@@ -96,5 +97,5 @@
 */
 
-int16_t _rdfat(uint16_t *bufad, struct bpb *bpp)
+int16_t _rdfat(uint8_t *bufad, struct bpb *bpp)
 {
 	if (_getfat(bufad, bpp, 0)) {
@@ -116,7 +117,7 @@
 */
 
-int16_t _rdroot(uint16_t *buf, struct bpb *bpp)
-{
-	return(BIOS(B_RDWR, 0, (int8_t *)buf, bpp->rdlen,
+int32_t _rdroot(struct dirent *buf, struct bpb *bpp)
+{
+	return(BIOS(B_RDWR, 0, buf, bpp->rdlen,
 		(bpp->fatrec + bpp->fsiz), 0));
 }
@@ -131,7 +132,7 @@
 */
 
-int16_t _nsic(struct fcb *fcp, struct bpb *bpp, int8_t *fp)
-{
-	register uint16_t tfe;
+int16_t _nsic(struct fcb *fcp, struct bpb *bpp, uint8_t *fp)
+{
+	register int16_t tfe;
 
 	/* check the FCB flags */
@@ -220,9 +221,9 @@
 struct dirent *_dsrch(struct dirent *de)
 {
-	uint16_t i, dl;
+	int16_t i, dl;
 	register struct dirent *dp;
 
 	dp = _thedir;
-	dl = _thebpb->rdlen * (_thebpb->recsiz / DENTSIZE);
+	dl = _thebpb->rdlen * (_thebpb->recsiz / (int16_t)DENTSIZE);
 
 	for (i = 0; i < dl; i++) {		/* check each entry */
@@ -253,9 +254,9 @@
 struct dirent *_dsnew(void)
 {
-	uint16_t i, dl;
+	int16_t i, dl;
 	register struct dirent *dp;
 
 	dp = _thedir;
-	dl = _thebpb->rdlen * (_thebpb->recsiz / DENTSIZE);
+	dl = _thebpb->rdlen * (_thebpb->recsiz / (int16_t)DENTSIZE);
 
 	for (i = 0; i < dl; i++) {		/* check each entry */
@@ -304,6 +305,6 @@
 int16_t _seek(struct fcb *fcp)
 {
-	register uint16_t acls, rcls, nc;
-	uint16_t sic, spc;
+	register int16_t acls, rcls, nc;
+	int16_t sic, spc;
 
 	if (!(fcp->modefl & FC_OPN)) {		/* file must be open */
@@ -328,5 +329,5 @@
 	rcls = fcp->curlsn / spc;		/* calculate relative cluster */
 	sic = fcp->curlsn - (rcls * spc);	/* calculate sector in cluster */
-	acls = micons(fcp->de.bclust);		/* get first cluster */
+	acls = (int16_t)micon16(fcp->de.bclust);	/* get first cluster */
 	fcp->modefl &= ~FC_EOF;			/* turn off the EOF flag */
 
@@ -400,5 +401,5 @@
 int16_t _ftrnc(struct dirent *dp)
 {
-	register uint16_t acls, ncls;
+	register int16_t acls, ncls;
 
 #if	DEBUGIT
@@ -408,5 +409,5 @@
 #endif
 
-	acls = micons(dp->bclust);		/* get first cluster number */
+	acls = (int16_t)micon16(dp->bclust);	/* get first cluster number */
 
 	/* zap entries until EOF or bad cluster */
@@ -481,5 +482,5 @@
 #endif
 
-	if (nc = _newcls()) {			/* get a new cluster */
+	if ((nc = _newcls())) {			/* get a new cluster */
 
 #if	DEBUGIT
@@ -488,5 +489,5 @@
 
 		_ptcl12(_thefat, nc, FAT_EOF);	/* mark new cluster as EOF */
-		pc = micons(fcp->de.bclust);	/* get first cluster */
+		pc = (int16_t)micon16(fcp->de.bclust);	/* get first cluster */
 
 #if	DEBUGIT
@@ -689,5 +690,5 @@
 		/* create the file */
 
-		if(rc = _fmake(fcp)) {
+		if ((rc = _fmake(fcp))) {
 
 			_deadio(fcp, EIO);	/* couldn't create the file */
@@ -758,11 +759,11 @@
 	memcpy(&fcp->de, _dptr, DENTSIZE);
 	fcp->clsec = 0;
-	fcp->curcls = micons(fcp->de.bclust);
+	fcp->curcls = (int16_t)micon16(fcp->de.bclust);
 	fcp->offset = 0;
 	fcp->curlsn = 0L;
 	fcp->curdsn = fcp->de.bclust ? _cl2lsn(_thebpb, fcp->curcls) : 0;
-	fcp->curlen = miconl(fcp->de.flen);
-
-	fcp->asects = ((fcp->curlen / _thebpb->clsizb)
+	fcp->curlen = (int32_t)micon32(fcp->de.flen);
+
+	fcp->asects = ((int16_t)(fcp->curlen / _thebpb->clsizb)
 		+ ((fcp->curlen & (_thebpb->clsizb - 1)) ? 1 : 0))
 		* _thebpb->clsiz;
@@ -787,5 +788,5 @@
 */
 
-int16_t _inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, int16_t mode)
+int16_t _inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, uint16_t mode)
 {
 	int16_t	fl;
@@ -923,5 +924,5 @@
 		if (fcp->modefl & (FC_CR | FC_AP | FC_WR)) {	/* writing ? */
 
-			if (dp = _dsrch(&fcp->de)) {	/* locate the dirent */
+			if ((dp = _dsrch(&fcp->de))) {	/* locate the dirent */
 
 				/* update the directory entry if it changed */
@@ -1050,5 +1051,5 @@
 		return(FAILURE);
 
-	_dptr->fname[0] = 0xE5;		/* mark directory entry as free */
+	_dptr->fname[0] = (int8_t)0xE5;	/* mark directory entry as free */
 
 #if	DEBUGIT
Index: libcio/filesys.x
===================================================================
--- libcio/filesys.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/filesys.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -26,5 +26,5 @@
 extern	struct	bpb	*_thebpb;
 extern	struct	dirent	_thedir[MAXDIRNT];
-extern	uint16_t	_thefat[MAXFAT * WDPSEC];
+extern	uint8_t		_thefat[MAXFAT * BPSEC];
 
 /*
@@ -37,5 +37,5 @@
 extern	int16_t		DelFile(struct fcb *fcp);
 extern	int16_t		_alcnew(struct fcb *fcp);
-extern	uint16_t	_cl2lsn(struct bpb *bpp, uint16_t clnum);
+extern	int16_t		_cl2lsn(struct bpb *bpp, int16_t clnum);
 extern	void		_clsvol(void);
 extern	void		_deadio(struct fcb *fcp, int16_t err);
@@ -44,13 +44,13 @@
 extern	int16_t		_fmake(struct fcb *fcp);
 extern	int16_t		_ftrnc(struct dirent *dp);
-extern	uint16_t	_getfat(uint16_t *bufad, struct bpb *bpp, uint16_t nfat);
-extern	uint16_t	_gtcl12(int8_t *fat, uint16_t cl);
-extern	int16_t		_inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, int16_t mode);
+extern	int32_t		_getfat(uint8_t *bufad, struct bpb *bpp, int16_t nfat);
+extern	int16_t		_gtcl12(uint8_t *fat, int16_t cl);
+extern	int16_t		_inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, uint16_t mode);
 extern	int16_t		_newcls(void);
-extern	int16_t		_nsic(struct fcb *fcp, struct bpb *bpp, int8_t *fp);
+extern	int16_t		_nsic(struct fcb *fcp, struct bpb *bpp, uint8_t *fp);
 extern	int16_t		_opfcb(struct fcb *fcp);
 extern	int16_t		_opnvol(void);
-extern	int16_t		_rdfat(uint16_t *bufad, struct bpb *bpp);
-extern	int16_t		_rdroot(uint16_t *buf, struct bpb *bpp);
+extern	int16_t		_rdfat(uint8_t *bufad, struct bpb *bpp);
+extern	int32_t		_rdroot(struct dirent *buf, struct bpb *bpp);
 extern	int16_t		_seek(struct fcb *fcp);
 extern	int16_t		fcbinit(int8_t *name, struct fcb *fcp);
Index: libcio/filname.c
===================================================================
--- libcio/filname.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/filname.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -62,5 +62,5 @@
 	tp = p;
 
-	while (c = *s) {		/* scan the string */
+	while ((c = *s)) {		/* scan the string */
 
 		if (c EQ '.') {		/* ... until we hit the dot */
Index: libcio/flread.c
===================================================================
--- libcio/flread.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/flread.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -34,5 +34,5 @@
 		} else {
 
-			ilen = len;
+			ilen = (int16_t)len;
 
 			if (1 NE fread(buff, ilen, 1, fp))
Index: libcio/fopen.c
===================================================================
--- libcio/fopen.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fopen.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -8,5 +8,5 @@
 #include "ram.h"
 
-FILE *_opener(int8_t *name, int8_t *mode, int16_t aflag)
+FILE *_opener(int8_t *name, int8_t *mode, uint16_t rawflg)
 {
 	register FILE *fp;
@@ -26,10 +26,10 @@
 
 	case 'r':	/* read mode */
-		if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_RDONLY), aflag)) EQ -1)
+		if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_RDONLY) | rawflg)) EQ -1)
 			return(NULL);
 		break;
 
 	case 'w':	/* write mode */
-		if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|O_TRUNC, aflag)) EQ -1)
+		if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|O_TRUNC|rawflg)) EQ -1)
 			return(NULL);
 
@@ -37,5 +37,5 @@
 	
 	case 'a':	/* append mode */
-		if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT, aflag)) EQ -1)
+		if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|rawflg)) EQ -1)
 			return(NULL);
 
Index: libcio/fopen.x
===================================================================
--- libcio/fopen.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fopen.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,5 +16,5 @@
 */
 
-extern	FILE		*_opener(int8_t *name, int8_t *mode, int16_t aflag);
+extern	FILE		*_opener(int8_t *name, int8_t *mode, uint16_t aflag);
 extern	FILE		*fopen(int8_t *name, int8_t *mode);
 extern	FILE		*fopena(int8_t *name, int8_t *mode);
Index: libcio/fread.c
===================================================================
--- libcio/fread.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fread.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -15,8 +15,11 @@
 */
 
-int16_t fread(int8_t *buffer, uint16_t size, int16_t number, FILE *stream)
+int16_t fread(void *buffer, int16_t size, int16_t number, FILE *stream)
 {
+	uint8_t *buffer8;
 	int16_t total;
 	register int16_t c,i;
+
+	buffer8 = buffer;
 
 	for (total = 0; total < number; ++total) {
@@ -27,5 +30,5 @@
 				return(total);
 
-			*buffer++ = c;
+			*buffer8++ = (uint8_t)c;
 		}
 	}
Index: libcio/fread.x
===================================================================
--- libcio/fread.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fread.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,3 +16,3 @@
 */
 
-extern	int16_t		fread(int8_t *buffer, uint16_t size, int16_t number, FILE *stream);
+extern	int16_t		fread(void *buffer, int16_t size, int16_t number, FILE *stream);
Index: libcio/fseek.c
===================================================================
--- libcio/fseek.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fseek.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,5 +16,5 @@
 int16_t fseek(FILE *fp, int32_t pos, int16_t mode)
 {
-	register int16_t lr;
+	register int32_t lr;
 
 	if (fp->_flags & _DIRTY) {
@@ -30,5 +30,5 @@
 
 	fp->_bp = fp->_bend = NULL;
-	fp->_flags &= ~_EOF;
+	fp->_flags = (uint8_t)(fp->_flags & ~_EOF);
 
 	lr = lseek(fp->_unit, pos, mode);
Index: libcio/fsinit.c
===================================================================
--- libcio/fsinit.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fsinit.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -8,5 +8,5 @@
 #include "ram.h"
 
-int8_t	*Stdbufs;			/* buffer chain pointer */
+int32_t	*Stdbufs;			/* buffer chain pointer */
 
 int8_t	Wrkbuf[BPSEC];			/* sector work buffer */
@@ -39,5 +39,5 @@
 */
 
-int16_t _badfio(io_arg arg, int8_t *buff, int16_t len)
+int16_t _badfio(io_arg arg, void *buff, int16_t len)
 {
 	(void)arg;
@@ -69,9 +69,8 @@
 */
 
-int16_t _nopo(int8_t *name, int16_t flag, int16_t mode, struct channel *chp, struct devtabl *dp)
+int16_t _nopo(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp)
 {
 	(void)name;
 	(void)flag;
-	(void)mode;
 	(void)chp;
 	(void)dp;
@@ -99,5 +98,5 @@
 */
 
-void InitCH(struct channel *cp, int8_t rdi, int8_t wri, int8_t ioi, int8_t ski, chclo cfp, io_arg charg)
+void InitCH(struct channel *cp, int16_t rdi, int16_t wri, int16_t ioi, int16_t ski, chclo cfp, io_arg charg)
 {
 	cp->c_read  = rdi;
@@ -115,5 +114,5 @@
 */
 
-void Init_CB(FILE *fp, int8_t flags, int8_t unit, int32_t *bufad, int16_t bufsize)
+void Init_CB(FILE *fp, uint8_t flags, int16_t unit, int32_t *bufad, int16_t bufsize)
 {
 	fp->_bp     = (int8_t *)0L;
@@ -124,5 +123,5 @@
 	fp->_bytbuf = 0;
 	fp->_buflen = bufsize;
-};
+}
 
 /*
@@ -139,10 +138,10 @@
 	memsetw(Stdbuf, 0, sizeof Stdbuf / 2);		/* clear buffers */
 
-	Init_CB(stdin,  _BUSY, 0, (int8_t *)0L, BUFSIZ);	/* stdin */
-	Init_CB(stdout, _BUSY, 1, (int8_t *)0L, 1);	/* stdout */ 
-	Init_CB(stderr, _BUSY, 2, (int8_t *)0L, 1);	/* stderr */
+	Init_CB(stdin,  _BUSY, 0, NULL, BUFSIZ);	/* stdin */
+	Init_CB(stdout, _BUSY, 1, NULL, 1);		/* stdout */
+	Init_CB(stderr, _BUSY, 2, NULL, 1);		/* stderr */
 
 	for (i = 3; i < NSTREAMS; i++)
-		Init_CB(&Cbuffs[i], 0, 0, (int8_t *)0L, 0);
+		Init_CB(&Cbuffs[i], 0, 0, NULL, 0);
 
 	Stdbuf[0][0] = 0L;		/* initialize the buffer list */
Index: libcio/fsinit.x
===================================================================
--- libcio/fsinit.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fsinit.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -21,5 +21,5 @@
 extern	FILE		Cbuffs[NSTREAMS];
 extern	int32_t		Stdbuf[MAXDFILE][BUFSIZL];
-extern	int8_t		*Stdbufs;
+extern	int32_t		*Stdbufs;
 extern	int8_t		Wrkbuf[BPSEC];
 extern	int16_t		_b_sect;
@@ -37,12 +37,12 @@
 */
 
-extern	void		InitCH(struct channel *cp, int8_t rdi, int8_t wri, int8_t ioi, int8_t ski, chclo cfp, io_arg charg);
+extern	void		InitCH(struct channel *cp, int16_t rdi, int16_t wri, int16_t ioi, int16_t ski, chclo cfp, io_arg charg);
 extern	void		InitFS(void);
-extern	void		Init_CB(FILE *fp, int8_t flags, int8_t unit, int32_t *bufad, int16_t bufsize);
+extern	void		Init_CB(FILE *fp, uint8_t flags, int16_t unit, int32_t *bufad, int16_t bufsize);
 extern	int16_t		_badfd(void);
 extern	int16_t		_noper(void);
 
 extern	int16_t		_badfc(io_arg arg);
-extern	int16_t		_badfio(io_arg arg, int8_t *buff, int16_t len);
+extern	int16_t		_badfio(io_arg arg, void *buff, int16_t len);
 extern	int16_t		_nopc(io_arg arg);
-extern	int16_t		_nopo(int8_t *name, int16_t flag, int16_t mode, struct channel *chp, struct devtabl *dp);
+extern	int16_t		_nopo(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp);
Index: libcio/ftell.c
===================================================================
--- libcio/ftell.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/ftell.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -57,5 +57,5 @@
 	fcp = chp->c_arg;		/* point at the FCB */
 
-	dpos = fcp->offset + (fcp->curlsn << FILESHFT);
+	dpos = fcp->offset + ((int32_t)fcp->curlsn << FILESHFT);
 
 	if (fp->_flags & _DIRTY)	/* adjust for the buffering */
Index: libcio/fwrite.c
===================================================================
--- libcio/fwrite.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fwrite.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -19,7 +19,10 @@
 */
 
-int16_t fwrite(int8_t *buffer, int16_t size, int16_t number, FILE *stream)
+int16_t fwrite(void *buffer, int16_t size, int16_t number, FILE *stream)
 {
+	uint8_t *buffer8;
 	register int16_t i, j;
+
+	buffer8 = buffer;
 
 	if (size < 0)		/* check size for validity */
@@ -31,5 +34,5 @@
 	for (i = 0; i < number; ++i)
 		for (j = 0; j < size; ++j)
-			if (putc(*buffer++, stream) EQ EOF)
+			if (putc(*buffer8++, stream) EQ EOF)
 				return(i);
 
Index: libcio/fwrite.x
===================================================================
--- libcio/fwrite.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/fwrite.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,3 +16,3 @@
 */
 
-extern	int16_t		fwrite(int8_t *buffer, int16_t size, int16_t number, FILE *stream);
+extern	int16_t		fwrite(void *buffer, int16_t size, int16_t number, FILE *stream);
Index: libcio/getc.c
===================================================================
--- libcio/getc.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/getc.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -17,5 +17,5 @@
 			return(EOF);
 
-		ptr->_flags &= ~_DIRTY;		/* reset the dirty buffer bit */
+		ptr->_flags = (uint8_t)(ptr->_flags & ~_DIRTY);	/* reset the dirty buffer bit */
 
 		if (ptr->_buff EQ NULL)		/* get a buffer if none exists */
@@ -24,5 +24,5 @@
 		if ((len = read(ptr->_unit, ptr->_buff, ptr->_buflen)) LE 0) {
 
-			ptr->_flags |= ((len EQ 0) ? _EOF : _IOERR);
+			ptr->_flags = (uint8_t)(ptr->_flags | ((len EQ 0) ? _EOF : _IOERR));
 			return(EOF);
 		}
Index: libcio/getl.c
===================================================================
--- libcio/getl.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/getl.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -22,10 +22,10 @@
 	register int8_t *t;
 
-	t = &temp;
+	t = (int8_t *)&temp;
 
-	*t++ = fgetc(stream);
-	*t++ = fgetc(stream);
-	*t++ = fgetc(stream);
-	*t = fgetc(stream);
+	*t++ = (int8_t)fgetc(stream);
+	*t++ = (int8_t)fgetc(stream);
+	*t++ = (int8_t)fgetc(stream);
+	*t = (int8_t)fgetc(stream);
 
 	return(temp);
Index: libcio/getw.c
===================================================================
--- libcio/getw.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/getw.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -22,8 +22,8 @@
 	register int8_t *t;
 
-	t = &temp;
+	t = (int8_t *)&temp;
 
-	*t++ = fgetc(stream);
-	*t = fgetc(stream);
+	*t++ = (int8_t)fgetc(stream);
+	*t = (int8_t)fgetc(stream);
 
 	return(temp);
Index: libcio/lseek.c
===================================================================
--- libcio/lseek.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/lseek.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -45,5 +45,5 @@
 
 	case 1:				/* relative to current position */
-		pos += fp->offset + (fp->curlsn << FILESHFT);
+		pos += fp->offset + ((int32_t)fp->curlsn << FILESHFT);
 
 	case 0:				/* relative to start of file */
@@ -72,5 +72,5 @@
 
 		fp->offset = fp->curlen & (BPSEC -1);
-		fp->curlsn = fp->curlen >> FILESHFT;
+		fp->curlsn = (int16_t)(fp->curlen >> FILESHFT);
 		fp->modefl |= FC_ERR;
 
@@ -86,5 +86,5 @@
 
 	fp->offset = pos & ((int32_t)BPSEC - 1);	/* calculate sector offset */
-	fp->curlsn = pos >> FILESHFT;		/* calculate logical sector */
+	fp->curlsn = (int16_t)(pos >> FILESHFT);	/* calculate logical sector */
 
 	if (_seek(fp) < 0) {			/* position to the physical sector */
Index: libcio/open.c
===================================================================
--- libcio/open.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/open.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -19,8 +19,8 @@
 static struct devtabl devtabl[] = {
 
-	{ "con:", &condev,  &devtabl[0] },	/* console device */
-	{ "CON:", &condev,  &devtabl[1] },
-
-	{      0, &filedev,      NULL   }	/* this MUST be the last entry */
+	{ "con:", &condev,  &devtabl[0], CON_DEV },	/* console device */
+	{ "CON:", &condev,  &devtabl[1], CON_DEV },
+
+	{      0, &filedev,        NULL,      -1 }	/* this MUST be the last entry */
 };
 
@@ -34,10 +34,11 @@
 */
 
-int16_t open(int8_t *name, int16_t flag, int16_t mode)
+int16_t open(int8_t *name, uint16_t flag)
 {
 	register struct devtabl	*dp;
 	register struct channel	*chp;
 	register struct device	*dev;
-	int16_t	fd, mdmask;
+	int16_t	fd;
+	uint16_t mdmask;
 
 	/* search for a free channel */
@@ -84,5 +85,5 @@
 	chp->c_close = _nopc;
 
-	if ((*dev->d_open)(name, flag, mode, chp, dp) < 0) {	/* open */
+	if ((*dev->d_open)(name, flag, chp, dp) < 0) {	/* open */
 
 		chp->c_close = _badfc;	/* couldn't open for some reason */
@@ -102,7 +103,7 @@
 */
 
-int16_t opena(int8_t *name, int16_t flag, int16_t mode)
-{
-	return(open(name, flag, mode));
+int16_t opena(int8_t *name, uint16_t flag)
+{
+	return(open(name, flag));
 }
 
@@ -116,7 +117,7 @@
 */
 
-int16_t openb(int8_t *name, int16_t flag, int16_t mode)
-{
-	return(open(name, flag|O_RAW, mode));
+int16_t openb(int8_t *name, uint16_t flag)
+{
+	return(open(name, flag|O_RAW));
 }
 
@@ -131,7 +132,7 @@
 */
 
-int16_t creat(int8_t *name, int16_t mode)
-{
-	return(open(name, O_WRONLY|O_TRUNC|O_CREAT, mode));
+int16_t creat(int8_t *name)
+{
+	return(open(name, O_WRONLY|O_TRUNC|O_CREAT));
 }
 
@@ -146,7 +147,7 @@
 */
 
-int16_t creata(int8_t *name, int16_t mode)
-{
-	return(open(name, O_WRONLY|O_TRUNC|O_CREAT, mode));
+int16_t creata(int8_t *name)
+{
+	return(open(name, O_WRONLY|O_TRUNC|O_CREAT));
 }
 
@@ -161,7 +162,7 @@
 */
 
-int16_t creatb(int8_t *name, int16_t mode)
-{
-	return(open(name, O_WRONLY|O_TRUNC|O_CREAT|O_RAW, mode));
+int16_t creatb(int8_t *name)
+{
+	return(open(name, O_WRONLY|O_TRUNC|O_CREAT|O_RAW));
 }
 
@@ -174,10 +175,9 @@
 */
 
-int16_t _fileop(int8_t *name, int16_t flag, int16_t mode, struct channel *chp, struct devtabl *dp)
+int16_t _fileop(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp)
 {
 	register struct fcb *fp;
 	int8_t	tmpname[9], tmpext[4];
 
-	(void)mode;
 	(void)dp;
 
Index: libcio/open.x
===================================================================
--- libcio/open.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/open.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,9 +16,9 @@
 */
 
-extern	int16_t		_fileop(int8_t *name, int16_t flag, int16_t mode, struct channel *chp, struct devtabl *dp);
-extern	int16_t		creat(int8_t *name, int16_t mode);
-extern	int16_t		creata(int8_t *name, int16_t mode);
-extern	int16_t		creatb(int8_t *name, int16_t mode);
-extern	int16_t		open(int8_t *name, int16_t flag, int16_t mode);
-extern	int16_t		opena(int8_t *name, int16_t flag, int16_t mode);
-extern	int16_t		openb(int8_t *name, int16_t flag, int16_t mode);
+extern	int16_t		_fileop(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp);
+extern	int16_t		creat(int8_t *name);
+extern	int16_t		creata(int8_t *name);
+extern	int16_t		creatb(int8_t *name);
+extern	int16_t		open(int8_t *name, uint16_t flag);
+extern	int16_t		opena(int8_t *name, uint16_t flag);
+extern	int16_t		openb(int8_t *name, uint16_t flag);
Index: libcio/posit.c
===================================================================
--- libcio/posit.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/posit.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -14,5 +14,5 @@
 */
 
-int16_t posit(int16_t fd, uint16_t pos)
+int16_t posit(int16_t fd, int16_t pos)
 {
 	register struct fcb *fp;
@@ -27,5 +27,5 @@
 
 	if ((chantab[fd].c_seek EQ 0)
-	    OR ((pos << FILESHFT) > fp->curlen)) {
+	    OR (((int32_t)pos << FILESHFT) > fp->curlen)) {
 
 		errno = EINVAL;
Index: libcio/posit.x
===================================================================
--- libcio/posit.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/posit.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -15,3 +15,3 @@
 */
 
-extern	int16_t		posit(int16_t fd, uint16_t pos);
+extern	int16_t		posit(int16_t fd, int16_t pos);
Index: libcio/putc.c
===================================================================
--- libcio/putc.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/putc.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -59,5 +59,5 @@
 	if (data EQ -1) {	/* just flushing, not adding data */
 
-		ptr->_flags &= ~_DIRTY;
+		ptr->_flags = (uint8_t)(ptr->_flags & ~_DIRTY);
 		ptr->_bend = ptr->_bp = NULL;
 		return(0);
@@ -79,5 +79,5 @@
 	ptr->_flags |= _DIRTY;
 
-	return((*ptr->_bp++ = data) & 0x00FF);
+	return((*ptr->_bp++ = (int8_t)data) & 0x00FF);
 }
 
@@ -134,5 +134,5 @@
 		return(flush_(ptr, c & 0xFF));
 
-	return((*ptr->_bp++ = c) & 0xFF);
+	return((*ptr->_bp++ = (int8_t)c) & 0xFF);
 }
 
Index: libcio/putl.c
===================================================================
--- libcio/putl.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/putl.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -12,11 +12,11 @@
 void putl(int32_t w, FILE *stream)
 {
-	if (putc(((w >> 24) & 0xFF), stream) < 0 ) 
+	if (putc(((int16_t)(w >> 24) & 0xFF), stream) < 0)
 		return;
 
-	if (putc(((w >> 16) & 0xFF), stream) < 0 ) 
+	if (putc((int16_t)((w >> 16) & 0xFF), stream) < 0)
 		return;
 
-	if (putc(((w >> 8) & 0xFF), stream) < 0 ) 
+	if (putc((int16_t)((w >> 8) & 0xFF), stream) < 0)
 		return;
 
Index: libcio/putw.c
===================================================================
--- libcio/putw.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/putw.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -10,5 +10,5 @@
 #include "ram.h"
 
-void putw(uint16_t w, FILE *stream)
+void putw(int32_t w, FILE *stream)
 {
 	if (putc(((w >> 8) & 0xFF), stream) < 0 ) 
Index: libcio/putw.x
===================================================================
--- libcio/putw.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/putw.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,3 +16,3 @@
 */
 
-extern	void		putw(uint16_t w, FILE *stream);
+extern	void		putw(int32_t w, FILE *stream);
Index: libcio/read.c
===================================================================
--- libcio/read.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/read.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -38,5 +38,5 @@
 #include "ram.h"
 
-static int16_t (*t_read[])(io_arg arg, int8_t *buff, int16_t len) = {
+static int16_t (*t_read[])(io_arg arg, void *buff, int16_t len) = {
 
 	_badfio,	/* 0 - invalid type */
@@ -52,5 +52,5 @@
 */
 
-int16_t read(int16_t fd, int8_t *buff, uint16_t len)
+int16_t read(int16_t fd, void *buff, int16_t len)
 {
 	register struct channel *chp;
@@ -73,5 +73,5 @@
 */
 
-int16_t _getsec(struct fcb *fp, int8_t *buf, uint16_t len)
+int16_t _getsec(struct fcb *fp, void *buf, int16_t len)
 {
 	if ((errno = ReadRN(fp, Wrkbuf)) NE 0)	/* get current sector */
@@ -98,23 +98,28 @@
 */
 
-int16_t _filerd(struct fcb *fp, int8_t *buffer, uint16_t len)
+int16_t _filerd(io_arg arg, void *buffer, int16_t len)
 {
-	register uint16_t l;
-	register uint16_t j, k;
-	register int32_t curpos, newpos;
+	struct fcb *fp;
+	int8_t *buffer8;
+	register int16_t l;
+	register int16_t j, k;
+	register int32_t cpos, npos;
+
+	fp = (struct fcb *)arg;
+	buffer8 = buffer;
 
 	l = 0;
-	curpos = fp->offset + (fp->curlsn << FILESHFT);
-	newpos = curpos + len;
+	cpos = fp->offset + ((int32_t)fp->curlsn << FILESHFT);
+	npos = cpos + len;
 
 #if	DEBUGIT
 	if (fsdebug)
 		printf("_filerd():  len=%u, curpos=%ld, newpos=%ld, curlen=%ld\n",
-			len, curpos, newpos, fp->curlen);
+			len, cpos, npos, fp->curlen);
 #endif
 
-	if (newpos GT fp->curlen) {
+	if (npos GT fp->curlen) {
 
-		len = fp->curlen - curpos;
+		len = (int16_t)(fp->curlen - cpos);
 
 #if	DEBUGIT
@@ -129,16 +134,17 @@
 			l = len;
 
-		if (_getsec(fp, buffer, l))	/* read what we can */
+		if (_getsec(fp, buffer8, l))	/* read what we can */
 			return(len);	/* return if ERROR */
 	}
 
-	if (k = (len - l) / BPSEC)		/* see what we still need */
-			if ((j = blkrd(fp, buffer + l, k)) NE 0)
+	if ((k = (len - l) / BPSEC)) {		/* see what we still need */
+		if ((j = blkrd(fp, buffer8 + l, k)) NE 0)
 			return((k - j) * BPSEC + l);	/* return bytes read */
+	}
 
 	l += k * BPSEC;			/* adjust l by what we just read */
 
 	if (l < len)	/* see if we still need a partial sector */
-		if (_getsec(fp, buffer + l, len - l))	/* read partial sector */
+		if (_getsec(fp, buffer8 + l, len - l))	/* read partial sector */
 			return(l);		/* return if ERROR or EOF */
 
Index: libcio/read.x
===================================================================
--- libcio/read.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/read.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -8,4 +8,5 @@
 
 #include "biosdefs.h"
+#include "fspars.h"
 #include "stdint.h"
 
@@ -16,5 +17,5 @@
 */
 
-extern	int16_t		_filerd(struct fcb *fp, int8_t *buffer, uint16_t len);
-extern	int16_t		_getsec(struct fcb *fp, int8_t *buf, uint16_t len);
-extern	int16_t		read(int16_t fd, int8_t *buff, uint16_t len);
+extern	int16_t		_filerd(io_arg arg, void *buffer, int16_t len);
+extern	int16_t		_getsec(struct fcb *fp, void *buf, int16_t len);
+extern	int16_t		read(int16_t fd, void *buff, int16_t len);
Index: libcio/readrn.c
===================================================================
--- libcio/readrn.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/readrn.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -30,5 +30,5 @@
 	int32_t	brc;		/* bios return code */
 
-	if (sv = _seek(fcp))		/* try to find the sector we want */
+	if ((sv = _seek(fcp))) {		/* try to find the sector we want */
 		if (sv < 0) {
 
@@ -41,4 +41,5 @@
 			return(1);		/* return:  EOF */
 		}
+	}
 
 #if	DEBUGIT
@@ -49,5 +50,5 @@
 
 #if	TBUFFER
-	if (brc = _secrd(buf, (int16_t)fcp->curdsn)) {
+	if ((brc = _secrd(buf, (int16_t)fcp->curdsn))) {
 #else
 	if (brc = BIOS(B_RDWR, 0, buf, 1, (short)fcp->curdsn, 0)) {
Index: libcio/scan.c
===================================================================
--- libcio/scan.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/scan.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -38,5 +38,5 @@
 	while (maxwide--) {
 
-		if ((cp = index(list, (*gsub)(0))) EQ NULL) {
+		if ((cp = index(list, (int8_t)(*gsub)(0))) EQ NULL) {
 
 			(*gsub)(1);
@@ -106,5 +106,5 @@
 	gsub = getsub;
 
-	while (c = *fmt++) {
+	while ((c = *fmt++)) {
 
 		if (c EQ '%') {
@@ -180,5 +180,5 @@
 						*(int32_t *)(*args++) = lv;
 					else
-						**args++ = lv;
+						**args++ = (int16_t)lv;
 					++count;
 				}
@@ -220,5 +220,5 @@
 
 				for (cp = tlist ; (c = *fmt++) != ']' ; )
-					*cp++ = c;
+					*cp++ = (int8_t)c;
 
 				*cp = 0;
@@ -236,5 +236,7 @@
 
 				if (!dontdo)
-					cp = *args++;
+					cp = (int8_t *)*args++;
+				else
+					cp = NULL;	/* fix compiler warning */
 
 				while (maxwide--) {
@@ -244,6 +246,6 @@
 
 					if (lflag ?
-					     (index(tlist, c) NE 0) :
-					     (index(tlist, c) EQ 0)) {
+					     (index(tlist, (int8_t)c) NE 0) :
+					     (index(tlist, (int8_t)c) EQ 0)) {
 
 						(*gsub)(1);	/* unget last character */
@@ -252,5 +254,5 @@
 
 					if (!dontdo)
-						*cp++ = c;
+						*cp++ = (int8_t)c;
 				}
 
@@ -269,5 +271,5 @@
 				if (!dontdo) {
 
-					*(int8_t *)(*args++) = c;
+					*(int8_t *)(*args++) = (int8_t)c;
 					++count;
 				}
Index: libcio/ungetc.c
===================================================================
--- libcio/ungetc.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/ungetc.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -13,5 +13,5 @@
 		return(EOF);
 
-	*--ptr->_bp = c;
+	*--ptr->_bp = (int8_t)c;
 
 	return(c);
Index: libcio/write.c
===================================================================
--- libcio/write.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/write.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -12,5 +12,5 @@
 /* write routine dispatch table */
 
-static	int16_t	(*wr_tab[])(io_arg arg, int8_t *buff, int16_t len) = {
+static	int16_t	(*wr_tab[])(io_arg arg, void *buff, int16_t len) = {
 
 	_badfio,	/* 0 - invalid entry */
@@ -25,5 +25,5 @@
 */
 
-int16_t _putsec(struct fcb *fp, int8_t *buf, uint16_t len)
+int16_t _putsec(struct fcb *fp, void *buf, int16_t len)
 {
 #if DEBUGIT
@@ -92,11 +92,16 @@
 */
 
-int16_t _filewr(struct fcb *fp, int8_t *buffer, uint16_t len)
+int16_t _filewr(io_arg arg, void *buffer, int16_t len)
 {
-	register uint16_t j, k, l;
+	struct fcb *fp;
+	int8_t *buffer8;
+	register int16_t j, k, l;
 	int16_t clustr;
-	register int32_t curpos;
-
-	curpos = fp->offset + (fp->curlsn << FILESHFT);	/* get position */
+	register int32_t cpos;
+
+	fp = (struct fcb *)arg;
+	buffer8 = buffer;
+
+	cpos = fp->offset + ((int32_t)fp->curlsn << FILESHFT);	/* get position */
 
 	if (fp->de.bclust EQ 0) {	/* see if we need to allocate */
@@ -104,7 +109,7 @@
 #if DEBUGIT
 	if (fsdebug)
-		if (curpos)
+		if (cpos)
 			printf("_filewr():  ERROR - bclust EQ 0 and curpos (%ld) NE 0\n",
-				curpos);
+				cpos);
 #endif
 
@@ -115,5 +120,5 @@
 		}
 
-		fp->de.bclust = micons(clustr);		/* update FCB */
+		fp->de.bclust = micon16((uint16_t)clustr);	/* update FCB */
 		_ptcl12(_thefat, clustr, 0x0FF8);	/* update FAT */
 		_fatmod = TRUE;
@@ -137,5 +142,5 @@
 	if (fsdebug)
 		printf("_filewr():  init pos=%ld, len=%u, curcls=%u, offset=%u\n",
-			curpos, len, fp->curcls, fp->offset);
+			cpos, len, fp->curcls, fp->offset);
 #endif
 
@@ -145,16 +150,16 @@
 			l = len;
 
-		if (_putsec(fp, buffer, l))	/* fill up the sector */
+		if (_putsec(fp, buffer8, l))	/* fill up the sector */
 			return(-1);
 	}
 
-	if (k = (len - l) / BPSEC) {	/* write out any full sectors */
-
-		if ((j = blkwr(fp, buffer + l, k)) NE 0) {
+	if ((k = (len - l) / BPSEC)) {	/* write out any full sectors */
+
+		if ((j = blkwr(fp, buffer8 + l, k)) NE 0) {
 
 			l += (k - j) * BPSEC;	/* update amount written */
 
-			if ((curpos + l) > fp->curlen) 	/* udpate file length */
-				fp->de.flen = miconl(fp->curlen = curpos + l);
+			if ((cpos + l) > fp->curlen) 	/* udpate file length */
+				fp->de.flen = micon32((uint32_t)(fp->curlen = cpos + l));
 
 #if DEBUGIT
@@ -172,8 +177,8 @@
 	if (l < len) {			/* write out partial sector at end */
 
-		if (_putsec(fp, buffer + l, len - l)) {
-
-			if ((curpos + l) > fp->curlen)	/* update file length */
-				fp->de.flen = miconl(fp->curlen = curpos + l);
+		if (_putsec(fp, buffer8 + l, len - l)) {
+
+			if ((cpos + l) > fp->curlen)	/* update file length */
+				fp->de.flen = micon32((uint32_t)(fp->curlen = cpos + l));
 
 #if DEBUGIT
@@ -187,6 +192,6 @@
 	}
 
-	if ((curpos + len) > fp->curlen) 		/* update file length */
-		fp->de.flen = miconl(fp->curlen = curpos + len);
+	if ((cpos + len) > fp->curlen) 		/* update file length */
+		fp->de.flen = micon32((uint32_t)(fp->curlen = cpos + len));
 
 #if DEBUGIT
@@ -205,5 +210,5 @@
 */
 
-int16_t write(int16_t fd, int8_t *buff, uint16_t len)
+int16_t write(int16_t fd, void *buff, int16_t len)
 {
 	register struct channel *chp;
Index: libcio/write.x
===================================================================
--- libcio/write.x	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/write.x	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -8,4 +8,5 @@
 
 #include "biosdefs.h"
+#include "fspars.h"
 #include "stdint.h"
 
@@ -16,5 +17,5 @@
 */
 
-extern	int16_t		_filewr(struct fcb *fp, int8_t *buffer, uint16_t len);
-extern	int16_t		_putsec(struct fcb *fp, int8_t *buf, uint16_t len);
-extern	int16_t		write(int16_t fd, int8_t *buff, uint16_t len);
+extern	int16_t		_filewr(io_arg arg, void *buffer, int16_t len);
+extern	int16_t		_putsec(struct fcb *fp, void *buf, int16_t len);
+extern	int16_t		write(int16_t fd, void *buff, int16_t len);
Index: libcio/writern.c
===================================================================
--- libcio/writern.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ libcio/writern.c	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -30,5 +30,5 @@
 	int32_t	brc;		/* bios return code */
 
-	if (sv = _seek(fcp)) {		/* try to find the sector we want */
+	if ((sv = _seek(fcp))) {		/* try to find the sector we want */
 
 		if (sv < 0) {			/* seek error ? */
@@ -67,5 +67,5 @@
 	/* write the sector */
 
-	if (brc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0)) {
+	if ((brc = BIOS(B_RDWR, 1, buf, 1, (int16_t)fcp->curdsn, 0))) {
 
 #if DEBUGIT
