💾 Archived View for uscoffings.net › retro-computing › systems › TI994a › assemblers › tiasm › src ›… captured on 2022-06-04 at 01:13:54.

View Raw

More Information

-=-=-=-=-=-=-

/* Some absolutely RUDE macros for doing portable (buffered) reads and writes.
 * The open routine should be a macro but is just too large.
 * The ideas behind these is that they will look EXACTLY like
 * the UNIX primitives read, write and open but do their stuff
 * buffered to keep us from going to the kernel too often.
 * Close must be a routine as it must return something.
 */

extern int fread(), fwrite();
#define	read(fd,bf,sz)	fread((char *)&(bf),1,(sz),Sdvec[(fd)])
#define write(fd,bf,sz) fwrite((char *)&(bf),1,(sz),Sdvec[(fd)])
#define lseek(fd,x,w)	fseek(Sdvec[(fd)],(x),(w))

/* Macros to do error checking */
#define	xwrite(fd,bf,sz) if(Ferror == FALSE)if(write(fd,bf,sz) != sz)\
				aabort("Write error")
#define	xseek(fd,x,w)	if(Ferror == FALSE)if(lseek((fd),(x),(w)) == -1)\
				aabort("Seek error")

/* Is arg (integer) an odd number */
#define	odd(x)	((x) % 2)