xref: /csrg-svn/old/as.vax/asscan.h (revision 19827)
1603Sbill /*
2*19827Sdist  * Copyright (c) 1982 Regents of the University of California.
3*19827Sdist  * All rights reserved.  The Berkeley software License Agreement
4*19827Sdist  * specifies the terms and conditions for redistribution.
5*19827Sdist  *
6*19827Sdist  *	@(#)asscan.h	5.1 (Berkeley) 04/30/85
75830Srrh  */
8*19827Sdist 
95830Srrh /*
10603Sbill  *	The character scanner is called to fill up one token buffer
11603Sbill  *
12603Sbill  *	However, once the tokens are filled up by the
13603Sbill  *	character scanner, they are used in both the first and the second
14603Sbill  *	pass.  Holes created by .stab removal are replaced
15603Sbill  *	with 'skip' tokens that direct the second pass to ignore the
16603Sbill  *	following tokens.
17603Sbill  */
18603Sbill 
199695Slinton #define TOKBUFLG		4096
20603Sbill #define MAXVAX			32
21603Sbill #define SAFETY			16
22603Sbill 
23603Sbill #define AVAILTOKS		TOKBUFLG -\
24603Sbill 		sizeof(int) -\
25603Sbill 		sizeof (struct tokbufdesc *) -\
26603Sbill 		MAXVAX - SAFETY
27603Sbill 
28603Sbill struct tokbufdesc{
29603Sbill 	int		tok_count;		/*absolute byte length*/
30603Sbill 	struct		tokbufdesc *tok_next;
31603Sbill 	char		toks[AVAILTOKS];
32603Sbill 	char		bufovf[MAXVAX + SAFETY];
33603Sbill };
34603Sbill /*
35603Sbill  *	Definitions for handling tokens in the intermediate file
36603Sbill  *	buffers.
37603Sbill  *
38603Sbill  *	We want to have the compiler produce the efficient auto increment
39603Sbill  *	instruction for stepping through the buffer of tokens.  We must
40603Sbill  *	fool the type checker into thinking that a pointer can point
41603Sbill  *	to various size things.
42603Sbill  */
43603Sbill 
445830Srrh typedef int inttoktype;
455830Srrh typedef char bytetoktype;
46603Sbill 
47603Sbill typedef char *ptrall;			/*all uses will be type cast*/
4813449Srrh typedef u_short lgtype;			/*for storing length of strings or skiping*/
49603Sbill /*
50603Sbill  *	defintions for putting various typed values
51603Sbill  *	into the intermediate buffers
52603Sbill  *	ptr will ALWAYS be of type ptrall
53603Sbill  */
54603Sbill 
55603Sbill #define	pchar(ptr,val)		*ptr++  = val
56603Sbill #define	puchar(ptr,val)		*ptr++  = val
57603Sbill 
58603Sbill #define	pshort(ptr,val)		*(short *)ptr=val,	ptr += sizeof(short)
5913449Srrh #define	plgtype(ptr,val)	*(lgtype *)ptr=val,	ptr += sizeof(lgtype)
605830Srrh #define	pushort(ptr,val)	*(u_short *)ptr=val,	ptr += sizeof(short)
61603Sbill #define	pint(ptr,val)		*(int *)ptr  = val,	ptr += sizeof(int)
625830Srrh #define	puint(ptr,val)		*(u_int int *)ptr=val,	ptr += sizeof(int)
63603Sbill #define	plong(ptr,val)		*(long *)ptr  = val,	ptr += sizeof(long)
645830Srrh #define	pulong(ptr,val)		*(u_int long *)ptr=val,	ptr += sizeof(long)
655830Srrh #define	pnumber(ptr,val)	*(Bignum*)ptr=val,	ptr += sizeof(Bignum)
665830Srrh #define	popcode(ptr,val)	*(struct Opcode*)ptr=val,	ptr += sizeof(struct Opcode)
675830Srrh 
68603Sbill #define	pptr(ptr,val)		*(int *)ptr  = (val),	ptr += sizeof(ptrall)
69603Sbill #define	ptoken(ptr,val)		*ptr++  = val
70603Sbill #define	pskiplg(ptr,val)	*(lgtype *)ptr  = val,	ptr += sizeof(short)
71603Sbill 
72603Sbill #define	gchar(val, ptr)		val = *ptr++
73603Sbill #define	guchar(val, ptr)	val = *ptr++
74603Sbill 
75603Sbill #define	gshort(val, ptr)	val = *(short *)ptr , ptr += sizeof (short)
7613449Srrh #define	glgtype(val, ptr)	val = *(lgtype *)ptr , ptr += sizeof (lgtype)
775830Srrh #define	gushort(val, ptr)	val = *(u_short *)ptr , ptr += sizeof (short)
78603Sbill #define	gint(val, ptr)		val = *(int *)ptr, ptr += sizeof (int)
795830Srrh #define	guint(val, ptr)		val = *(u_int *)ptr, ptr += sizeof (int)
80603Sbill #define	glong(val, ptr)		val = *(long *)ptr, ptr += sizeof (long)
815830Srrh #define	gulong(val, ptr)	val = *(u_int *)ptr, ptr += sizeof (long)
825830Srrh #define	gnumber(val, ptr)	val = *(Bignum *)ptr, ptr += sizeof(Bignum)
835830Srrh #define	gopcode(val, ptr)	val = *(struct Opcode *)ptr, ptr += sizeof(struct Opcode)
845830Srrh 
85603Sbill #define	gptr(val, ptr)		val = *(int *)ptr, ptr += sizeof (ptrall)
86603Sbill #define	gtoken(val, ptr)	val = *ptr++
87603Sbill #define	gskiplg(val, ptr)	val = *(lgtype *)ptr, ptr += sizeof (short)
88603Sbill 
89603Sbill extern	ptrall tokptr;	/*the next token to consume, call by copy*/
90603Sbill extern	ptrall tokub;	/*current upper bound in the current buffer*/
91