|
|
1.1 root 1: /*
2: * n2/i386/afield.c
3: * The functions in this file handle the management
4: * of address fields in the intermediate file.
5: * It converts the tree-like items into 'afield' structures.
6: * i386.
7: */
8:
9: #ifdef vax
10: #include "INC$LIB:cc2.h"
11: #else
12: #include "cc2.h"
13: #endif
14:
15: /*
16: * Read in an address field.
17: * The style of the address is determined by flag bits that
18: * hide in the address mode.
19: * These bits are cleared when the mode is stored in the afield.
20: */
21: getfield(opcode, afp) int opcode; register AFIELD *afp;
22: {
23: register int mode;
24:
25: mode = iget();
26: afp->a_mode = mode & ~A_FLAGS;
27: afp->a_sp = NULL;
28: afp->a_value = 0;
29: if ((mode & A_OFFS) != 0)
30: afp->a_value = iget();
31: if ((mode & A_LID) != 0)
32: afp->a_sp = llookup(iget(), 0);
33: else if ((mode & A_GID) != 0) {
34: sget(id, NCSYMB);
35: afp->a_sp = glookup(id, 0);
36: }
37: }
38:
39: /*
40: * Unassemble an address field.
41: * Output the unassembly to the output file
42: * in intermediate file format.
43: */
44: genfield(afp) register AFIELD *afp;
45: {
46: register SYM *sp;
47: register int mode;
48:
49: mode = afp->a_mode;
50: if (afp->a_value != 0 || (mode & A_AMOD)==A_IMM)
51: mode |= A_OFFS;
52: if ((sp = afp->a_sp) != NULL) {
53: if ((sp->s_flag & S_LABNO) != 0)
54: mode |= A_LID;
55: else
56: mode |= A_GID;
57: }
58: iput((ival_t)mode);
59: if ((mode & A_OFFS) != 0)
60: iput((ival_t)afp->a_value);
61: if ((mode & A_LID) != 0)
62: iput((ival_t)sp->s_labno);
63: else if ((mode & A_GID) != 0)
64: sput(sp->s_id);
65: }
66:
67: /*
68: * Compare the address field parts of two instructions.
69: */
70: cmpfield(ip1, ip2) INS *ip1, *ip2;
71: {
72: register AFIELD *afp1, *afp2;
73: register int n;
74:
75: if ((n = ip1->i_naddr) != 0) {
76: afp1 = &ip1->i_af[0];
77: afp2 = &ip2->i_af[0];
78: do {
79: if (afp1->a_mode != afp2->a_mode
80: || afp1->a_sp != afp2->a_sp
81: || afp1->a_value != afp2->a_value)
82: return 0;
83: ++afp1;
84: ++afp2;
85: } while (--n);
86: }
87: return 1;
88: }
89:
90: /* end of n2/i386/afield.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.