Annotation of coherent/b/bin/c/n2/i8086/afield.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * The functions in this file
                      3:  * handle the management of address fields
                      4:  * in the intermediate file. It converts the tree
                      5:  * like items into `afield' structures.
                      6:  */
                      7: #ifdef   vax
                      8: #include "INC$LIB:cc2.h"
                      9: #else
                     10: #include "cc2.h"
                     11: #endif
                     12: 
                     13: /*
                     14:  * Read in an address field. The style
                     15:  * of the address is determined by flag bits that
                     16:  * hide in the address mode. These bits are cleared away
                     17:  * when the mode is actually stored in the afield.
                     18:  */
                     19: getfield(opcode, afp)
                     20: register AFIELD        *afp;
                     21: {
                     22:        register int    mode;
                     23: 
                     24:        mode = iget();
                     25:        afp->a_mode = mode & (A_PREFX|A_AMOD|A_REGM);
                     26:        afp->a_sp = NULL;
                     27:        afp->a_value = 0;
                     28:        if ((mode&A_OFFS) != 0)
                     29:                afp->a_value = iget();
                     30:        if ((mode&A_LID) != 0)
                     31:                afp->a_sp = llookup(iget(), 0);
                     32:        else if ((mode&A_GID) != 0) {
                     33:                sget(id, NCSYMB);
                     34:                afp->a_sp = glookup(id, 0);
                     35:        }
                     36: }
                     37: 
                     38: /*
                     39:  * Unassemble an address field.
                     40:  * Output the unassembly to the output file
                     41:  * in intermediate file format.
                     42:  */
                     43: genfield(afp, flag)
                     44: 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(mode);
                     59:        if ((mode&A_OFFS) != 0)
                     60:                iput(afp->a_value);
                     61:        if ((mode&A_LID) != 0)
                     62:                iput(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
                     69:  * two instructions.
                     70:  */
                     71: cmpfield(ip1, ip2)
                     72: INS    *ip1, *ip2;
                     73: {
                     74:        register AFIELD *afp1, *afp2;
                     75:        register int    n;
                     76: 
                     77:        if ((n = ip1->i_naddr) != 0) {
                     78:                afp1 = &ip1->i_af[0];
                     79:                afp2 = &ip2->i_af[0];
                     80:                do {
                     81:                        if (afp1->a_mode != afp2->a_mode
                     82:                        ||  afp1->a_sp != afp2->a_sp
                     83:                        ||  afp1->a_value != afp2->a_value)
                     84:                                return (0);
                     85:                        ++afp1;
                     86:                        ++afp2;
                     87:                } while (--n);
                     88:        }
                     89:        return (1);
                     90: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.