Mercurial > hg > CbC > old > device
comparison mc-code-mips.c @ 415:bdf900926f32
fix cpmd register
author | kono |
---|---|
date | Sat, 23 Oct 2004 23:26:33 +0900 |
parents | 32c1914308db |
children | c73f013d07d7 |
comparison
equal
deleted
inserted
replaced
414:0a4416b34d4a | 415:bdf900926f32 |
---|---|
1060 | 1060 |
1061 free_all_register(); | 1061 free_all_register(); |
1062 max_reg_var=0; max_freg_var=0; | 1062 max_reg_var=0; max_freg_var=0; |
1063 reg_sp = 0; | 1063 reg_sp = 0; |
1064 freg_sp = 0; | 1064 freg_sp = 0; |
1065 text_mode(3); | |
1066 } | 1065 } |
1067 | 1066 |
1068 #define reg_var_num(i) (REG_VAR_BASE-i) | 1067 #define reg_var_num(i) (REG_VAR_BASE-i) |
1069 | 1068 |
1070 int | 1069 int |
2692 | 2691 |
2693 void | 2692 void |
2694 code_cmpdimm(int e, int csreg,int label,int cond) | 2693 code_cmpdimm(int e, int csreg,int label,int cond) |
2695 { | 2694 { |
2696 /* used in dosiwtch() */ | 2695 /* used in dosiwtch() */ |
2697 int reg=-1; | 2696 int reg=-1,regsv; |
2698 char *rn,*crn; | 2697 char *rn,*crn; |
2699 if(chk) return; | 2698 if(chk) return; |
2700 crn = register_name(csreg); | 2699 crn = register_name(csreg); |
2701 | 2700 |
2702 if (e<-32767||32766<e) { | 2701 if (e<-32767||32766<e) { |
2702 regsv=regs[csreg]; use_reg(csreg); | |
2703 rn = register_name(reg= get_register()); | 2703 rn = register_name(reg= get_register()); |
2704 regs[csreg]=regsv; | |
2704 code_const(e,reg); | 2705 code_const(e,reg); |
2705 switch(cond) { | 2706 switch(cond) { |
2706 case 1: | 2707 case 1: |
2707 printf("\tbne\t%s,%s,$L_%d\n",crn,rn,label); break; | 2708 printf("\tbne\t%s,%s,$L_%d\n",crn,rn,label); break; |
2708 case 0: | 2709 case 0: |
2709 printf("\tbeq\t%s,%s,$L_%d\n",crn,rn,label); break; | 2710 printf("\tbeq\t%s,%s,$L_%d\n",crn,rn,label); break; |
2710 case LT: | 2711 case LT: |
2711 use_reg(csreg); | |
2712 printf("\tslt\t%s,%s,%s\n",rn,crn,rn); | 2712 printf("\tslt\t%s,%s,%s\n",rn,crn,rn); |
2713 printf("\tbne\t%s,$0,$L_%d\n",rn,label); break; | 2713 printf("\tbne\t%s,$0,$L_%d\n",rn,label); break; |
2714 default: error(-1); | 2714 default: error(-1); |
2715 } | 2715 } |
2716 free_register(reg); | 2716 free_register(reg); |
2719 case 1: | 2719 case 1: |
2720 printf("\tbne\t%s,%d,$L_%d\n",crn,e,label); break; | 2720 printf("\tbne\t%s,%d,$L_%d\n",crn,e,label); break; |
2721 case 0: | 2721 case 0: |
2722 printf("\tbeq\t%s,%d,$L_%d\n",crn,e,label); break; | 2722 printf("\tbeq\t%s,%d,$L_%d\n",crn,e,label); break; |
2723 case LT: | 2723 case LT: |
2724 use_reg(csreg); | 2724 regsv=regs[csreg]; use_reg(csreg); |
2725 rn = register_name(reg= get_register()); | 2725 rn = register_name(reg= get_register()); |
2726 regs[csreg]=regsv; | |
2726 printf("\tslt\t%s,%s,%d\n",rn,crn,e); | 2727 printf("\tslt\t%s,%s,%d\n",rn,crn,e); |
2727 printf("\tbne\t%s,$0,$L_%d\n",rn,label); break; | 2728 printf("\tbne\t%s,$0,$L_%d\n",rn,label); break; |
2728 default: error(-1); | 2729 default: error(-1); |
2729 } | 2730 } |
2730 if (reg!=-1) free_register(reg); | 2731 if (reg!=-1) free_register(reg); |
3206 printf(".globl %s\n",n); | 3207 printf(".globl %s\n",n); |
3207 */ | 3208 */ |
3208 } | 3209 } |
3209 | 3210 |
3210 void | 3211 void |
3211 | |
3212 align(int t) | 3212 align(int t) |
3213 { | 3213 { |
3214 if (t!=CHAR) { | 3214 int d; |
3215 if (data_alignment & 1) | 3215 switch(t) { |
3216 printf("\t.align 2\n"); | 3216 case CHAR: case UCHAR: return; |
3217 data_alignment = 0; | 3217 case SHORT: case USHORT: d = data_alignment & 1; break; |
3218 default: d = data_alignment & 3; | |
3219 } | |
3220 if (d) { | |
3221 printf("\t.align 2\n"); | |
3222 data_alignment = 0; | |
3218 } | 3223 } |
3219 } | 3224 } |
3220 | 3225 |
3221 void | 3226 void |
3222 ascii(char *s) | 3227 ascii(char *s) |