Annotation of cci/d/entry/movs.c, revision 1.1

1.1     ! root        1: #define error_hdl1 error
        !             2: #define error_str error
        !             3: 
        !             4: #define C      0x1
        !             5: #define V      0x2
        !             6: #define Z      0x4
        !             7: #define N      0x8
        !             8: 
        !             9: extern long scoplp;
        !            10: extern long force_lp;
        !            11: 
        !            12: /*     MOVS2, MOVS3 instruction        */
        !            13: 
        !            14: #define MAXLINE        500
        !            15: #define MAXBYTE        95
        !            16: #define NULL   (char)0
        !            17: 
        !            18: /* Some global variables       */
        !            19: static long flag_msk, psl, len, r2;
        !            20: static char *s_str, srcstr[MAXLINE], d_str[MAXLINE], *r0, *r1;
        !            21: 
        !            22: movstr()
        !            23: {
        !            24:        asm("movl       $3,_no_opr");
        !            25:        movs2();
        !            26:        movs3();
        !            27:        asm("jmp *return");
        !            28: }
        !            29: 
        !            30: 
        !            31: static movs2()
        !            32: {
        !            33:        long no_op,  exp_psw, ix, dummy;
        !            34:        char *exp_r0, *exp_r1, *cptr;
        !            35: 
        !            36:        no_op = 2;
        !            37:        len = 0;
        !            38:        dummy = 0;
        !            39: 
        !            40:        setjmp();
        !            41:        asm("m1:        movab   m1,_stpc");
        !            42:        asm("movl       $1,_subtst");
        !            43:        flag_msk = exp_psw = 0;
        !            44:        flag_msk = exp_psw = N|V|C;
        !            45:        s_str = "** this is a test of string copy **";
        !            46:        exp_r0 = s_str + 35;
        !            47:        exp_r1 = d_str + 35;
        !            48:        movs(no_op,exp_r0,exp_r1,dummy,exp_psw);
        !            49: 
        !            50:        setjmp();
        !            51:        asm("m2:        movab   m2,_stpc");
        !            52:        asm("movl       $2,_subtst");
        !            53:        cptr = srcstr;
        !            54:        for(ix=0;ix<95;ix++) 
        !            55:                *cptr++ = ' ' + ix; /* make a long string */
        !            56:        *cptr = '\0';
        !            57:        s_str = srcstr;
        !            58:        flag_msk = exp_psw = 0;
        !            59:        flag_msk = exp_psw = N|Z|V|C;
        !            60:        exp_r0 = s_str + 95;
        !            61:        exp_r1 = d_str + 95;
        !            62:        movs(no_op,exp_r0,exp_r1,dummy,exp_psw);
        !            63: 
        !            64:        setjmp();
        !            65:        asm("m3:        movab   m3,_stpc");
        !            66:        asm("movl       $3,_subtst");
        !            67:        flag_msk = exp_psw = 0;
        !            68:        flag_msk = exp_psw = Z;
        !            69:        s_str = "\0";
        !            70:        exp_r0 = s_str;
        !            71:        exp_r1 = d_str;
        !            72:        movs(no_op,exp_r0,exp_r1,dummy,exp_psw);
        !            73: }
        !            74: 
        !            75: static movs3()
        !            76: {
        !            77:        long no_op,  exp_r2, ix, exp_psw;
        !            78:        char *exp_r0, *exp_r1, *cptr;
        !            79: 
        !            80:        no_op = 3;
        !            81: 
        !            82:        setjmp();
        !            83:        asm("m4:        movab   m4,_stpc");
        !            84:        asm("movl       $4,_subtst");
        !            85:        len = MAXBYTE;
        !            86:        cptr = srcstr;
        !            87:        for(ix=0;ix<len;ix++) 
        !            88:                *cptr++ = ' ' + ix; /* make a long string */
        !            89:        *cptr = '\0';
        !            90:        s_str = srcstr;
        !            91:        flag_msk = exp_psw = 0;
        !            92:        flag_msk = exp_psw = N|V|C;
        !            93:        len = 35;
        !            94:        exp_r0 = s_str + len;
        !            95:        exp_r1 = d_str + len;
        !            96:        exp_r2 = 0;
        !            97:        movs(no_op,exp_r0,exp_r1,exp_r2,exp_psw);
        !            98: 
        !            99:        setjmp();
        !           100:        asm("m5:        movab   m5,_stpc");
        !           101:        asm("movl       $5,_subtst");
        !           102:        flag_msk = exp_psw = 0;
        !           103:        flag_msk = exp_psw = Z;
        !           104:        len = 0;
        !           105:        exp_r0 = s_str + len;
        !           106:        exp_r1 = d_str + len;
        !           107:        exp_r2 = 0;
        !           108:        movs(no_op,exp_r0,exp_r1,exp_r2,exp_psw);
        !           109: 
        !           110:        setjmp();
        !           111:        asm("m6:        movab   m6,_stpc");
        !           112:        asm("movl       $6,_subtst");
        !           113:        flag_msk = exp_psw = 0;
        !           114:        flag_msk = exp_psw = Z;
        !           115:        len = MAXBYTE + 10;
        !           116:        exp_r0 = s_str + MAXBYTE;
        !           117:        exp_r1 = d_str + len;
        !           118:        exp_r2 = 0;
        !           119:        movs(no_op,exp_r0,exp_r1,exp_r2,exp_psw);
        !           120: 
        !           121: }
        !           122: 
        !           123: 
        !           124: /* THIS ROUTINE EXECUTE MOVS2, MOVS3 INSTRUCTION */
        !           125:  
        !           126: static movs(no_op,exp_r0,exp_r1,exp_r2,exp_psw)
        !           127: char *exp_r0, *exp_r1;
        !           128: long no_op, exp_psw, exp_r2;
        !           129: {
        !           130:        char *msg1, *msg2, savs[MAXLINE], *str, *cptr, *c1ptr;
        !           131:        long lenstr, len_op, ix, ierror, psw, n_flg;
        !           132: 
        !           133: flag_msk = flag_msk << 16;
        !           134: len_op = len;
        !           135: for(;;)
        !           136:      {
        !           137: 
        !           138:        /* CLEAR DESTINATION STRING */
        !           139:        cptr = d_str;
        !           140:        for (ix=0;ix<MAXLINE;ix++) { *cptr++ = '^';  savs[ix] = NULL; }
        !           141:                
        !           142:        /* SAVE SOURCE STRINGS  */
        !           143:        str = s_str;
        !           144:        n_flg = lenstr = 0;
        !           145:        cptr = savs;
        !           146:        for(;;)
        !           147:                {
        !           148:                *cptr = *str++;
        !           149:                if (*cptr == NULL)  break; 
        !           150:                cptr++; lenstr++;
        !           151:                }
        !           152:        if (lenstr >= len) n_flg++;
        !           153:        len = len_op;
        !           154: 
        !           155:        if (no_op == 2)
        !           156:                {
        !           157:                asm("movl _s_str,r0");          /* R0 : addr of source */
        !           158:                asm("movab _d_str,r1");         /* R1 : addr of destination */
        !           159:                asm("bicpsw $0xf");             /* clear all flags */
        !           160:                asm("bispsw _flag_msk");
        !           161: asm(".globl _mvstr2");
        !           162: asm("_mvstr2:");
        !           163:                asm("movs2");
        !           164:                asm("movpsl _psl");
        !           165:                asm("movl r0,_r0");
        !           166:                asm("movl r1,_r1");
        !           167:                }
        !           168:            else
        !           169:                {
        !           170:                asm("movl _s_str,r0");          /* R0 : addr of source */
        !           171:                asm("movab _d_str,r1");         /* R1 : addr of destination */
        !           172:                asm("movl _len,r2");            /* R2 : no of bytes to move */
        !           173:                asm("bicpsw $0xf");     /* clear all flags */
        !           174:                asm("bispsw _flag_msk");
        !           175: asm(".globl _mvstr3");
        !           176: asm("_mvstr3:");
        !           177:                asm("movs3");
        !           178:                asm("movpsl _psl");
        !           179:                asm("movl r0,_r0");
        !           180:                asm("movl r1,_r1");
        !           181:                asm("movl r2,_r2");
        !           182:                }
        !           183: 
        !           184:        psw = psl & 0xf;
        !           185: 
        !           186:        /* CHECK IF SOURCE GET CHANGED  */
        !           187:        ierror = 0;
        !           188:        if (no_op==3) lenstr = len;
        !           189:        cptr = s_str;
        !           190:        c1ptr = savs;
        !           191:        for(ix=0;ix<lenstr;ix++)
        !           192:                {       if (*cptr++ != *c1ptr++) 
        !           193:                                { ierror++;
        !           194:                                  break;
        !           195:                                }
        !           196:                        if (*cptr == NULL) break;
        !           197:                }
        !           198:        if (ierror)
        !           199:                {
        !           200:                asm("movl       $3,_ercode");
        !           201:                if (scoplp) longjmp();
        !           202:                error_str(*cptr-1,*c1ptr-1,s_str,savs);
        !           203:                }
        !           204: 
        !           205:        /* CHECK DESTINATION STRING     */
        !           206:        ierror = 0;
        !           207:        cptr = d_str;
        !           208:        c1ptr = savs;
        !           209:        for(ix=0;ix<lenstr;ix++)
        !           210:                {       if (*c1ptr++ != *cptr++) 
        !           211:                                { ierror++;
        !           212:                                  break;
        !           213:                                }
        !           214:                }
        !           215:        if (no_op==2) { if (d_str[ix]!='\0') ierror++; }
        !           216:                else
        !           217:                        if (len==0) { if (d_str[0] != '^') ierror++; }
        !           218:        if (ierror)
        !           219:                {
        !           220:                asm("movl       $1,_ercode");
        !           221:                if (scoplp) longjmp();
        !           222:                if (n_flg) { savs[lenstr] = d_str[lenstr] = '\0'; }
        !           223:                error_str(*cptr-1,*c1ptr-1,d_str,savs);
        !           224:                }
        !           225: 
        !           226: 
        !           227:        /* CHECK R0, R1         */
        !           228:        if (r0 != exp_r0 )
        !           229:                {
        !           230:                asm("movl       $3,_ercode");
        !           231:                if (scoplp) longjmp();
        !           232:                error_hdl1(r0,exp_r0,s_str,d_str,len);
        !           233:                } 
        !           234:        if (r1 != exp_r1 )
        !           235:                {
        !           236:                asm("movl       $3,_ercode");
        !           237:                if (scoplp) longjmp();
        !           238:                error_hdl1(r1,exp_r1,s_str,d_str,len);
        !           239:                } 
        !           240:        if (psw != exp_psw)
        !           241:                {
        !           242:                asm("movl       $3,_ercode");
        !           243:                if (scoplp) longjmp();
        !           244:                error_hdl1(psw,exp_psw,s_str,d_str,len);
        !           245:                }
        !           246:        if (no_op == 3)
        !           247:                {       /* MOVS3 : check r2 */
        !           248:                if (r2 != exp_r2 )
        !           249:                        {
        !           250:                        asm("movl       $3,_ercode");
        !           251:                        if (scoplp) longjmp();
        !           252:                        error_hdl1(r2,exp_r2,s_str,d_str,len);
        !           253:                        } 
        !           254:                /* CHECK LENGTH OPERAND */
        !           255:                if (len_op != len)
        !           256:                        {
        !           257:                        asm("movl       $3,_ercode");
        !           258:                        if (scoplp) longjmp();
        !           259:                        error_hdl1(len_op,len,s_str,d_str,len);
        !           260:                        }
        !           261:                /* CHECK NO. OF BYTES COPIED EQUAL LENGTH SPECIFIED */  
        !           262:                ierror = 0;
        !           263:                if (len<=MAXBYTE)
        !           264:                        { if (d_str[len]!='^')  
        !           265:                                {
        !           266:                                asm("movl       $1,_ercode");
        !           267:                                if (scoplp) longjmp();
        !           268:                                error_hdl1(d_str,savs,s_str,d_str,len);
        !           269:                                }
        !           270:                        }
        !           271:        
        !           272:                /* check for NULL padded at end of dest. string */
        !           273:                ierror = 0;
        !           274:                if (len>MAXBYTE)   
        !           275:                        { for(ix=MAXBYTE;ix<len;ix++)
        !           276:                                { if (d_str[ix] != NULL)
        !           277:                                        {
        !           278:                                        asm("movl       $1,_ercode");
        !           279:                                        if (scoplp) longjmp();
        !           280:                                        error_str(d_str,savs,s_str,d_str,len);
        !           281:                                        }
        !           282:                                if (force_lp) longjmp();
        !           283:                                }
        !           284:                        }
        !           285: 
        !           286:                }
        !           287:        break;
        !           288:     }
        !           289: }
        !           290: 
        !           291: 

unix.superglobalmegacorp.com

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