Annotation of GNUtools/cctools/as/m98k-check.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "m98k-opcode.h"
        !             3: 
        !             4: static int bits(
        !             5:     unsigned long width);
        !             6: 
        !             7: static char *cond[] = { "lt", "gt", "eq", "un"};
        !             8: static char *pred[] = { "+", "-" };
        !             9: 
        !            10: void
        !            11: main(
        !            12: int argc,
        !            13: char *argv[],
        !            14: char *envp[])
        !            15: {
        !            16:     long i, j, x, d, p;
        !            17: 
        !            18:        for(i = 0; *(m98k_opcodes[i].name) != '\0'; i++){
        !            19:            printf("\t%s", m98k_opcodes[i].name);
        !            20:            if(IS_BRANCH_CONDITIONAL(m98k_opcodes[i].opcode)){
        !            21:                p = bits(5) & 1;
        !            22:                printf("%s", pred[p]);
        !            23:            }
        !            24:            if(m98k_opcodes[i].ops[0].type == NONE)
        !            25:                printf("\n");
        !            26:            else
        !            27:                printf("\t");
        !            28:            d = 0;
        !            29:            for(j = 0; j < 5 && m98k_opcodes[i].ops[j].type != NONE; j++){
        !            30:                switch(m98k_opcodes[i].ops[j].type){
        !            31:                case PCREL:
        !            32:                    printf("_relitive");
        !            33:                    break;
        !            34:                case BADDR:
        !            35:                    printf("_absolute");
        !            36:                    break;
        !            37:                case D:
        !            38:                    printf("0x%04x(", bits(16));
        !            39:                    d = 1;
        !            40:                    break;
        !            41:                case DS:
        !            42:                    printf("0x%04x(", bits(14) << 2);
        !            43:                    d = 1;
        !            44:                    break;
        !            45:                case SI:
        !            46:                case UI:
        !            47:                    printf("0x%04x", bits(16));
        !            48:                    break;
        !            49:                case GREG:
        !            50:                    printf("r%d", bits(5) );
        !            51:                    break;
        !            52:                case G0REG:
        !            53:                    printf("r%d", bits(5) | 0x1 );
        !            54:                    break;
        !            55:                case FREG:
        !            56:                    printf("f%d", bits(5) );
        !            57:                    break;
        !            58:                case SGREG:
        !            59:                    printf("sr%d", bits(4) );
        !            60:                    break;
        !            61:                case SPREG:
        !            62:                    printf("%d", bits(10) );
        !            63:                    break;
        !            64:                case BCND:
        !            65:                    printf("cr%d+%s", bits(3), cond[bits(2)] );
        !            66:                    break;
        !            67:                case CRF:
        !            68:                case CRFONLY:
        !            69:                    x = bits(3);
        !            70:                    printf("cr%d", x == 0 ? 1 : x);
        !            71:                    break;
        !            72:                case sh:
        !            73:                    printf("%d", bits(6) );
        !            74:                    break;
        !            75:                case mb:
        !            76:                    printf("%d", bits(6) );
        !            77:                    break;
        !            78:                case NUM0:
        !            79:                case NUM:
        !            80:                    if(j == 0 &&
        !            81:                       IS_BRANCH_CONDITIONAL(m98k_opcodes[i].opcode)){
        !            82:                        x = bits(m98k_opcodes[i].ops[j].width);
        !            83:                        if(m98k_opcodes[i].ops[2].type == PCREL)
        !            84:                            if(p == 0) /* + with negative disp */
        !            85:                                x &= 0xfffffffe; 
        !            86:                            else
        !            87:                                x |= 1; 
        !            88:                        else
        !            89:                            if(p == 0) /* + with positive disp */
        !            90:                                x |= 1; 
        !            91:                            else
        !            92:                                x &= 0xfffffffe; 
        !            93:                        if(x == 20)
        !            94:                            x = 0;
        !            95:                        printf("%d", x);
        !            96:                    }
        !            97:                    else
        !            98:                        printf("%d", bits(m98k_opcodes[i].ops[j].width) );
        !            99:                    break;
        !           100:                case NONE:
        !           101:                    break;
        !           102:                }
        !           103:                if(j == 5 || m98k_opcodes[i].ops[j+1].type == NONE){
        !           104:                    if(d == 1)
        !           105:                        printf(")\n");
        !           106:                    else
        !           107:                        printf("\n");
        !           108:                }
        !           109:                else{
        !           110:                    if(m98k_opcodes[i].ops[j].type != D &&
        !           111:                       m98k_opcodes[i].ops[j].type != DS)
        !           112:                        printf(",");
        !           113:                }
        !           114:            }
        !           115:        }
        !           116:        exit(0);
        !           117: }
        !           118: 
        !           119: static
        !           120: int
        !           121: bits(
        !           122: unsigned long width)
        !           123: {
        !           124:      static int x = 1;
        !           125: 
        !           126:        x = (x + 1) & ((1 << width) - 1);
        !           127:        return(x);
        !           128: }

unix.superglobalmegacorp.com

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