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 PUTW 0x40
#define PUTL 0x80 #define PUTL 0x80
extern int curr_instr;
extern int curr_size;
#ifndef extern #ifndef extern
extern short eamode[]; extern short eamode[];
#else #else

View file

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

View file

@ -628,8 +628,42 @@ ea7071(sz)
return; return;
} }
if ((bd_2.typ & ~S_DOT) == DOTTYP) { if ((bd_2.typ & ~S_DOT) == DOTTYP) {
if (small(fitw(bd_2.val-(DOTVAL+2)), 2)) { /* the "off" variable fixes the problem described above,
bd_2.val -= (DOTVAL+2); * 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; mrg_2 = 072;
} }
} else } else