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

View Raw

More Information

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

#include "TI.out.h"

/* Size of vector for internal symbol table
 * Not only is this a magic number but it SHOULD be the lower of twin
 * primes and large enough to make the lists of buckets small.
 */
#define	SYMVECSIZ	1103

/* Maximum number of files that can be assembled */
#define	NFILES		50

/* Template for temp file names */
#define	TFILNM		"/tmp/TiXXXXXX"

/* Location of pass1 */
#define	PASS1		"/usr/local/lib/tiasm1"

#ifdef	DEBUG
#undef	DEBUG
#define	DEBUG(l,s,a)	if (Debug > (l)) fprintf (stderr, (s), (a))
#else	DEBUG
#define	DEBUG(l,s,a)
#endif	DEBUG

#define	TRUE		1
#define	FALSE		0

typedef	short	flag;

/* Types of entries in the symbol table */
#define	TYRSRVD		0x1
#define	TYLCLID		0x2
#define	TYEXTID		0x4
#define	TYRSLVD		0x8
#define	TYDIR		0x10

/* A member of the list of addresses referencing an identifier */
struct a_lst {
	short	a_addr;				/* address of opnd making ref */
	struct a_lst *a_next;			/* next member of list */
};

/* A symbol table entry */
struct stab {
	char	st_symnm[IDENTSIZ + 1];		/* Identifier/keyword name */
	short	st_type;			/* Type of this entry */
	union st_ent {
		struct op_info {
			unsigned short	op_cod;		/* opcode */
			unsigned char op_fmt;		/* Format code */
		} en_op;
		struct r_info {
			struct a_lst *ri_lst;	/* List of references */
			struct j_lst *ri_jl;	/* Jumps having this target */
			short	ri_addr;	/* Resolution address */
		} en_rinf;
	}	st_ent;
 struct stab *st_next;			/* Next bucket */
};

#define	st_opc		st_ent.en_op.op_cod
#define	st_fmt		st_ent.en_op.op_fmt
#define	en_lst		st_ent.en_rinf.ri_lst
#define	en_addr		st_ent.en_rinf.ri_addr
#define	en_jl		st_ent.en_rinf.ri_jl

/* A structure to store info about a symbol (absolute address or
 * pointer to symbol table entry.
 */

struct symb  {
	short	sy_tag;				/* Tag */
	union {
		struct stab *sy_stb;
		short	sy_loc;
	} sy_un;
};

#define	SYMTAG		0x1		/* Operand is indexed */
#define	RELOCATABLE	0x2		/* Relocatable as opposed to absolute */

/* Information about an operand specifier */
struct infop {
	int	t;				/* T code */
	int	r;				/* register */
	struct symb sy_info;
};

#define	in_stb		sy_info.sy_un.sy_stb
#define	in_loc		sy_info.sy_un.sy_loc
#define	in_tag		sy_info.sy_tag

/* A member of the list of addresses and targets necessary to resolve jumps */
struct j_lst {
	short	j_addr;				/* Word address for patch */
	struct j_lst *j_next;			/* Next member in list */
};

#define	j_tag	j_trgt.sy_tag
#define	j_loc	j_trgt.sy_un.sy_loc
#define	j_stb	j_trgt.sy_un.sy_stb

/* Structure for the initialization tables.
 * op_fmt is for machine type formats 1 through 9
 * op_fmt of zero is reserved to this program.
 * op_code would be the opcode to plug in to the object file providing
 * it is a valid machine format.
 */

struct ops {
	char *op_name;
	unsigned short op_code;
	unsigned char op_fmt;
};

/* The following is used to reclaim space in the list of forward referencing
 * jumps. It, obviously, will need to be changed if another storage method
 * is used.
 */

#define	rmjinf(x)	(free((x)))

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