Annotation of coherent/d/bin/cc/c/n2/i8086/unasm.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * The unassembler; this routine converts
                      3:  * the internal form of a machine instruction into
                      4:  * an intermediate form printable by cc3.  The output can
                      5:  * be made to look a lot like any assembler format by rewriting cc3.
                      6:  * This is the new VAX base, including
                      7:  * all edits up to revision 48.
                      8:  */
                      9: #ifdef   vax
                     10: #include "INC$LIB:cc2.h"
                     11: #else
                     12: #include "cc2.h"
                     13: #endif
                     14: 
                     15: unassemble(ip1)
                     16: register INS   *ip1;
                     17: {
                     18:        register INS    *ip2;
                     19:        register int    rel;
                     20:        register int    i, lab;
                     21:        register int    nlf;
                     22:        register int    opflag;
                     23: 
                     24:        switch (ip1->i_type) {
                     25: 
                     26:        case LLLINK:
                     27:                genone(ZWORD, A_LID|A_DIR, ip1->i_labno);
                     28:                break;
                     29: 
                     30:        case ENTER:
                     31:                genseg(ip1->i_seg);
                     32:                break;
                     33: 
                     34:        case ALIGN:
                     35:                bput(ALIGN); bput(0);
                     36:                break;
                     37: 
                     38:        case BLOCK:
                     39:                bput(BLOCK); zput(ip1->i_len);
                     40:                break;
                     41: 
                     42:        case LLABEL:
                     43:                bput(LLABEL); iput(ip1->i_labno);
                     44:                break;
                     45: 
                     46:        case JUMP:
                     47:                if ((rel=ip1->i_rel) == ZJMP) {
                     48:                        genone(ZJMP, A_LID|A_DIR, ip1->i_labno);
                     49:                        break;
                     50:                }
                     51:                if (ip1->i_long != 0) {
                     52:                        nlf = 0;
                     53:                        ip2 = ip1->i_fp;
                     54:                        if (ip2!=NULL && ip2!=&ins && ip2->i_type==LLABEL)
                     55:                                lab = ip2->i_labno;
                     56:                        else {
                     57:                                lab = newlab();
                     58:                                ++nlf;
                     59:                        }
                     60:                        genone(revrel(rel), A_LID|A_DIR, lab);
                     61:                        genone(ZJMP, A_LID|A_DIR, ip1->i_labno);
                     62:                        if (nlf != 0)
                     63:                                bput(LLABEL), iput(lab);
                     64:                        break;
                     65:                }
                     66:                genone(rel, A_LID|A_DIR, ip1->i_labno);
                     67:                break;
                     68: 
                     69:        case LINE:
                     70:                bput(LINE), iput(ip1->i_line);
                     71:                break;
                     72: 
                     73:        case CODE:
                     74:                if (isvariant(VEMU87)) {
                     75:                        /*
                     76:                         * Under the VEMU87 emulation option, the assembler
                     77:                         * precedes 8087 opcodes with emulator calls.
                     78:                         */
                     79:                        i = opinfo[ip1->i_op].op_style;
                     80:                        if (is8087op(i))
                     81:                                genone(ZCALL, A_GID|A_DIR, "emu87");
                     82:                }
                     83:                bput(CODE); bput(ip1->i_op);
                     84:                opflag = opinfo[ip1->i_op].op_flag;
                     85:                for (i=0; i<ip1->i_naddr; ++i)
                     86:                        genfield(&ip1->i_af[i], opflag);
                     87:                break;
                     88:        }
                     89: }
                     90: 
                     91: static short   revtab[] = {
                     92:        ZJBE,
                     93:        ZJB,
                     94:        ZJAE,
                     95:        ZJA,
                     96:        -1,
                     97:        ZJNE,
                     98:        ZJLE,
                     99:        ZJL,
                    100:        ZJGE,
                    101:        ZJG,
                    102:        -1,
                    103:        ZJE,
                    104:        ZJO,
                    105:        ZJS,
                    106:        ZJNO,
                    107:        ZJPO,
                    108:        ZJPE,
                    109:        ZJNS
                    110: };
                    111: 
                    112: revrel(rel)
                    113: register rel;
                    114: {
                    115:        if (rel<ZJA || rel>ZJS || (rel=revtab[rel-ZJA])<0)
                    116:                cbotch("bad rev");
                    117:        return (rel);
                    118: }

unix.superglobalmegacorp.com

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