Fixed bug: some offsets were just plain wrong

This commit is contained in:
ceriel 1993-02-19 17:33:40 +00:00
parent 6da226ab2b
commit dfc4956d59
3 changed files with 45 additions and 5 deletions

View file

@ -90,6 +90,9 @@ extern int dot_offset;
#define PUTW 0x40
#define PUTL 0x80
extern int curr_instr;
extern int curr_size;
#ifndef extern
extern short eamode[];
#else

View file

@ -14,6 +14,7 @@
operation
: { instrp = instr;
dot_offset = 0;
curr_instr = curr_token;
}
instruction
{ emit_instr();
@ -131,7 +132,9 @@ instruction
{ movem(0, $2, $3);}
| MOVEM sizedef notimmreg ',' regs
{ movem(1, $2, $5);}
| MOVESP sizedef ea_ea
| MOVESP sizedef
{ curr_size = $1; }
ea_ea
{ if ($1 == 0) {
/* movep */
movep($2);
@ -372,8 +375,8 @@ reg : DREG
{ $$ = $1 | 010;}
;
sizedef : /* empty */
{ $$ = SIZE_DEF;}
| SIZE
{ $$ = SIZE_DEF; curr_size = SIZE_DEF; }
| SIZE { curr_size = $1; $$ = $1; }
;
sizenon : /* empty */
{ $$ = SIZE_NON;}

View file

@ -628,8 +628,42 @@ ea7071(sz)
return;
}
if ((bd_2.typ & ~S_DOT) == DOTTYP) {
if (small(fitw(bd_2.val-(DOTVAL+2)), 2)) {
bd_2.val -= (DOTVAL+2);
/* the "off" variable fixes the problem described above,
* e.g., when references to program space are made by
* instructions with more than one opcode word.
*/
int off = 2;
switch(curr_instr) {
case MOVEM:
case FMOVE:
case FMOVEM:
case FDYADIC:
case FMONADIC:
case FSINCOS:
case FSCC:
case FTST:
case DIVL:
case OP_RANGE:
case CALLM:
case CAS:
case CPSCC:
case CPTRAPCC:
case PFLUSH:
case PTEST:
case PMOVE:
case PLOAD:
off = 4;
break;
case MOVESP:
if (curr_size != 0) off = 4;
break;
case DIVMUL:
if (curr_size != SIZE_W) off = 4;
break;
}
if (small(fitw(bd_2.val-(DOTVAL+off)), 2)) {
bd_2.val -= (DOTVAL+off);
mrg_2 = 072;
}
} else