C_lil ==> "move.l ([$1,a6]), -(sp)".
-C_lof ==> "move.l (sp)+, a0";
- "move.l ($1,a0), -(sp)".
+C_lof ==> "move.l (sp), a0";
+ "move.l ($1,a0), (sp)".
C_lal ==> "pea ($1,a6)".
"pea (8,a0)".
C_loi
- $1 == 1 ==> "move.l (sp)+, a0";
- "clr.l -(sp)";
+ $1 == 1 ==> "move.l (sp), a0";
+ "clr.l (sp)";
"move.b (a0), (3,sp)".
- $1 == 2 ==> "move.l (sp)+, a0";
- "clr.l -(sp)";
+ $1 == 2 ==> "move.l (sp), a0";
+ "clr.l (sp)";
"move.w (a0), (2,sp)".
- $1 == 4 ==> "move.l (sp)+, a0";
- "move.l (a0), -(sp)".
- $1 == 8 ==> "move.l (sp)+, a0";
- "move.l (4,a0), -(sp)";
+ $1 == 4 ==> "move.l (sp), a0";
+ "move.l (a0), (sp)".
+ $1 == 8 ==> "move.l (sp), a0";
+ "move.l (4,a0), (sp)";
"move.l (a0), -(sp)".
$1 % 4 == 0 ==> "move.l (sp)+, a0";
"move.l #$1/4-1, d0";
C_lde.. ==> "move.l ($1+$2+4), -(sp)";
"move.l ($1+$2), -(sp)".
-C_ldf ==> "move.l (sp)+, a0";
- "move.l ($1+4,a0), -(sp)";
+C_ldf ==> "move.l (sp), a0";
+ "move.l ($1+4,a0), (sp)";
"move.l ($1,a0), -(sp)".
C_lpi ==> "pea ($1)".
C_mli
$1 == 4 ==> "move.l (sp)+, d0";
- "muls.l (sp)+, d0";
- "move.l d0, -(sp)".
+ "muls.l (sp), d0";
+ "move.l d0, (sp)".
default ==> arg_error( "mli", $1).
C_dvi
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"divs.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "dvi", $1).
C_rmi
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
- "divsl.l d0, d2:d1";
- "move.l d2, -(sp)".
+ "move.l (sp), d1";
+ "move.l d0, (sp)";
+ "divsl.l (sp), d0:d1";
+ "move.l d0, (sp)".
default ==> arg_error( "rmi", $1).
C_ngi
C_sli
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"asl.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "sli", $1).
C_sri
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"asr.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "sri", $1).
C_mlu
$1 == 4 ==> "move.l (sp)+, d0";
- "mulu.l (sp)+, d0";
- "move.l d0, -(sp)".
+ "mulu.l (sp), d0";
+ "move.l d0, (sp)".
default ==> arg_error( "mlu", $1).
C_dvu
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"divu.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "dvu", $1).
C_rmu
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
- "divul.l d0, d2:d1";
- "move.l d2, -(sp)".
+ "move.l (sp), d1";
+ "move.l d0, (sp)";
+ "divul.l (sp), d0:d1";
+ "move.l d0, (sp)".
default ==> arg_error( "rmu", $1).
C_slu ==> C_sli( w).
C_sru
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"lsr.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "sru", $1).
/* */
/******************************************************************************/
-C_cii ==> " move.l (sp), d0";
- " move.l (4, sp), d1";
+/* cii, ciu, cuu, cui are assumed to be called with legal arguments only */
+
+C_cii ==> " move.l (sp)+, d0";
+ " move.l (sp)+, d1";
" cmp.l d1, d0";
" ble 4f";
- " cmp.l #4, d1";
- " bge 4f";
- " move.l (8, sp), d2";
+ " move.l (sp), d0";
" cmp.l #1, d1";
" bne 2f";
- " cmp.l #2, d0";
- " bne 1f";
- " ext.w d2";
- " bra 3f";
- "1: extl.l d2";
- " bra 3f";
- "2: ext.l d2";
- "3: move.l d2, (8, sp)";
- " move.l #4, (4, sp)";
- "4: jsr (.cii)".
+ " ext.w d0";
+ "2: ext.l d0";
+ " move.l d0,(sp)";
+ "4:".
C_cuu ==> "lea (8,sp),sp".
C_rol
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"rol.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "rol", $1).
C_ror
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"ror.l d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> arg_error( "ror", $1).
C_inn
$1 == 4 ==> "move.l (sp)+, d0";
- "move.l (sp)+, d1";
+ "move.l (sp), d1";
"btst d0, d1";
"sne d1";
"and.l #1, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> "move.l (sp)+, d0";
"move.l #$1, d1";
"jsr (.inn)";
"move.l d0, -(sp)".
C_set
- $1 == 4 ==> "move.l (sp)+, d0";
+ $1 == 4 ==> "move.l (sp), d0";
"clr.l d1";
"bset d0, d1";
- "move.l d1, -(sp)".
+ "move.l d1, (sp)".
default ==> "move.l (sp)+, d0";
"move.l #$1, d1";
"jsr (.set)".
C_cmp ==> C_cmu( (arith)4).
-C_tlt ==> "move.l (sp)+, d0";
- "move.l #1, -(sp)";
+C_tlt ==> "move.l (sp), d0";
+ "move.l #1, (sp)";
"tst.l d0";
"blt 1f";
"clr.l (sp)";
"1:".
-C_tle ==> "move.l (sp)+, d0";
- "move.l #1, -(sp)";
+C_tle ==> "move.l (sp), d0";
+ "move.l #1, (sp)";
"tst.l d0";
"ble 1f";
"clr.l (sp)";
"1:".
-C_teq ==> "move.l (sp)+, d0";
- "move.l #1, -(sp)";
+C_teq ==> "move.l (sp), d0";
+ "move.l #1, (sp)";
"tst.l d0";
"beq 1f";
"clr.l (sp)";
"1:".
-C_tne ==> "move.l (sp)+, d0";
- "move.l #1, -(sp)";
+C_tne ==> "move.l (sp), d0";
+ "move.l #1, (sp)";
"tst.l d0";
"bne 1f";
"clr.l (sp)";
"1:".
-C_tge ==> "move.l (sp)+, d0";
- "move.l #1, -(sp)";
+C_tge ==> "move.l (sp), d0";
+ "move.l #1, (sp)";
"tst.l d0";
"bge 1f";
"clr.l (sp)";
"1:".
-C_tgt ==> "move.l (sp)+, d0";
- "move.l #1, -(sp)";
+C_tgt ==> "move.l (sp), d0";
+ "move.l #1, (sp)";
"tst.l d0";
"bgt 1f";
"clr.l (sp)";
prolog ==> .
-jump ==> "jmp $1".
+jump ==> "bra $1".
locals ==> "link a6, #-$1".
Malloc((unsigned)nrelo*sizeof(struct relocation_info));
for (i = 0; i < nrelo; i++) {
- if ( ( reloc_info[i].or_sect-S_MIN) == SEGTXT) {
- convert_reloc( &reloc_info[i], u_reloc++);
+ if ( ( reloc_info[i].or_sect-S_MIN) == SEGTXT &&
+ convert_reloc( &reloc_info[i], u_reloc)) {
trsize++;
+ u_reloc++;
}
}
for (i = 0; i < nrelo; i++) {
- if ( ( reloc_info[i].or_sect-S_MIN) != SEGTXT) {
- convert_reloc( &reloc_info[i], u_reloc++);
+ if ( ( reloc_info[i].or_sect-S_MIN) != SEGTXT &&
+ convert_reloc( &reloc_info[i], u_reloc)) {
+ u_reloc++;
drsize++;
}
}
+ nrelo = trsize + drsize;
u_reloc -= nrelo;
init_unixheader();
struct outrelo *a_relo;
struct relocation_info *u_relo;
{
+ int retval = 1;
+
u_relo->r_address = a_relo->or_addr;
u_relo->r_symbolnum = a_relo->or_nami;
u_relo->r_pcrel = (a_relo->or_type & RELPC) >> 3;
if ( u_relo->r_extern == 0) {
switch ( (symbol_table[ a_relo->or_nami].on_type & S_TYP) - S_MIN) {
case SEGTXT : u_relo->r_symbolnum = N_TEXT;
+ if (u_relo->r_pcrel &&
+ (a_relo->or_sect-S_MIN == SEGTXT))
+ retval = 0;
break;
case SEGCON : u_relo->r_symbolnum = N_DATA;
break;
(symbol_table[ a_relo->or_nami].on_type & S_TYP) - S_MIN);
}
}
+ return retval;
}
{
int sect;
- *u_type = '\0';
- *u_type |= ( *a_type & S_EXT) ? N_EXT : N_UNDF;
+ *u_type = ((*a_type&S_TYP) == S_UND || (*a_type & S_EXT)) ? N_EXT : 0;
if ( valu != -1 && (! (*a_type & S_COM))) {
sect = ( *a_type & S_TYP ) - S_MIN;
long get4();
extern long base_address();
+/*
extern short get2();
extern char get1();
-
-static do_relo();
+*/
do_local_relocation()
{
- register struct outrelo *ptr;
- register int s;
+ register struct outrelo *rp;
/* print( "n relocation records %d\n", relo - reloc_info); */
- for ( ptr = reloc_info; ptr < relo; ptr++) {
- s = ptr->or_nami;
- if ( symbol_table[ s].on_valu != -1 &&
- ! (symbol_table[s].on_type & S_COM))
- do_relo(&symbol_table[ s], ptr);
- }
-}
+ for ( rp = reloc_info; rp < relo; rp++) {
+ register struct outname *np = &symbol_table[rp->or_nami];
+ if ( np->on_valu != -1 && ! (np->on_type & S_COM)) {
+ register long oldval,newval;
+ register char *sect;
-static
-do_relo(np,rp)
-struct outname *np;
-struct outrelo *rp;
-{
- long oldval,newval;
- char *sect;
-
- switch( rp->or_sect - S_MIN) {
- case SEGTXT:
- sect = text_area;
- break;
- case SEGCON:
- sect = data_area;
- break;
- default:
- fprint( STDERR,
- "do_local_relo(): bad section %d\n",
- rp->or_sect - S_MIN);
- break;
+ switch( rp->or_sect - S_MIN) {
+ case SEGTXT:
+ sect = text_area;
+ break;
+ case SEGCON:
+ sect = data_area;
+ break;
+ default:
+ fprint( STDERR,
+ "do_local_relo(): bad section %d\n",
+ rp->or_sect - S_MIN);
+ break;
+ }
+ oldval = get4( sect, rp->or_addr);
+ newval = oldval + np->on_valu +
+ base_address( (np->on_type & S_TYP) -S_MIN);
+ if ( rp->or_type & RELO4)
+ put4( sect, rp->or_addr, newval);
+ /*
+ else if ( rp->or_type & RELO2)
+ put2( sect, rp->or_addr, (int) newval);
+ else if ( rp->or_type & RELO1)
+ put1( sect, rp->or_addr, (char) newval);
+ */
+ else
+ print( STDERR,
+ "do_relo() : bad relocation size\n");
+ }
}
- oldval = get4( sect, rp->or_addr);
- newval = oldval + np->on_valu +
- base_address( (np->on_type & S_TYP) -S_MIN);
- if ( rp->or_type & RELO4)
- put4( sect, rp->or_addr, newval);
- /*
- else if ( rp->or_type & RELO2)
- put2( sect, rp->or_addr, (int) newval);
- else if ( rp->or_type & RELO1)
- put1( sect, rp->or_addr, (char) newval);
- */
- else
- print( STDERR, "do_relo() : bad relocation size\n");
- /* print( "reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n",
-np->on_foff + string_area, rp->or_addr, rp->or_sect-S_MIN, oldval, newval,
-np->on_valu);
- */
}