made a bit more portable

This commit is contained in:
ceriel 1988-10-17 10:38:30 +00:00
parent 0f8489fe28
commit 8b6ba39da4

View file

@ -42,8 +42,7 @@ short typ;
return; return;
} }
switch (opc){ if (opc == MOV) {
case MOV:
if (small((val & 0xF0000000) == 0xF0000000, 8)){ if (small((val & 0xF0000000) == 0xF0000000, 8)){
emit4(0xE51F0004 | (ins & 0xF000)); emit4(0xE51F0004 | (ins & 0xF000));
emit4(val); emit4(val);
@ -57,7 +56,8 @@ short typ;
} }
DOTVAL += 16; DOTVAL += 16;
return; return;
case ADD: }
if (opc == ADD) {
if (small((val & 0xF0000000) == 0xF0000000, 4)){ if (small((val & 0xF0000000) == 0xF0000000, 4)){
emit4(0xE51F0004 | (ins & 0xF000)); emit4(0xE51F0004 | (ins & 0xF000));
emit4(val); emit4(val);
@ -69,13 +69,11 @@ short typ;
emit4(val); emit4(val);
emit4(0xE2800000 | (ins&0xFF000) | (ins&0xF000)>>12); emit4(0xE2800000 | (ins&0xFF000) | (ins&0xF000)>>12);
return; return;
default:
if (pass == PASS_1)
DOTVAL += 16;
else
serror("immediate value out of range");
return;
} }
if (pass == PASS_1)
DOTVAL += 16;
else
serror("immediate value out of range");
} }
calcimm(opc,val,typ) calcimm(opc,val,typ)
@ -90,35 +88,32 @@ short typ;
if ((*val & ~0xFF) == 0) return 1; if ((*val & ~0xFF) == 0) return 1;
if ((~*val & ~0xFF) == 0){ if ((~*val & ~0xFF) == 0){
switch (*opc){ if (*opc == AND) {
case AND:
*val = ~*val; *val = ~*val;
*opc = BIC; *opc = BIC;
return 1; return 1;
case MOV: }
if (*opc == MOV) {
*val = ~*val; *val = ~*val;
*opc = MVN; *opc = MVN;
return 1; return 1;
case ADC: }
if (*opc == ADC) {
*val = ~*val; *val = ~*val;
*opc = SBC; *opc = SBC;
return 1; return 1;
default :
break;
} }
} }
if ((-1**val & ~0xFF) == 0 ){ if ((-1**val & ~0xFF) == 0 ){
switch (*opc){ if (*opc == ADD) {
case ADD:
*val *= -1; *val *= -1;
*opc = SUB; *opc = SUB;
return 1; return 1;
case CMP: }
if (*opc == CMP) {
*val *= -1; *val *= -1;
*opc = CMN; *opc = CMN;
return 1; return 1;
default:
break;
} }
} }
@ -130,21 +125,20 @@ short typ;
return 1; return 1;
} }
if ((~*val & ~0xFF) == 0){ if ((~*val & ~0xFF) == 0){
switch (*opc){ if (*opc == AND) {
case AND:
*val = ~*val|i<<8; *val = ~*val|i<<8;
*opc = BIC; *opc = BIC;
return 1; return 1;
case MOV: }
if (*opc == MOV) {
*val = ~*val|i<<8; *val = ~*val|i<<8;
*opc = MVN; *opc = MVN;
return 1; return 1;
case ADC: }
if (*opc == ADC) {
*val = ~*val|i<<8; *val = ~*val|i<<8;
*opc = SBC; *opc = SBC;
return 1; return 1;
default :
break;
} }
} }
}while(i<15); }while(i<15);
@ -205,13 +199,13 @@ short typ;
if (typ != S_ABS){ if (typ != S_ABS){
tmpval = val-DOTVAL-8; tmpval = val-DOTVAL-8;
if (small((tmpval & ~0xFF) == 0),12){ if (small((tmpval & ~0xFF) == 0),12){
emit4(0xE2000000|ADD|0xF<<16|reg<<12|tmpval); emit4(0xE2000000|ADD|(long)0xF<<16|reg<<12|tmpval);
return 0; return 0;
} }
tmpval *= -1; tmpval *= -1;
if (small((tmpval & ~0xFF) == 0), 12){ if (small((tmpval & ~0xFF) == 0), 12){
emit4(0xE2000000|SUB|0xF<<16|reg<<12|tmpval); emit4(0xE2000000|SUB|(long)0xF<<16|reg<<12|tmpval);
return 0; return 0;
} }
} }