obj-coff-bfd:

bfd support gets deeper into gas
*h8*
	fixed numerous bugs in instruction encoding
This commit is contained in:
Steve Chamberlain
1991-11-26 02:16:59 +00:00
parent 23de7ff6f5
commit 05b4b0e70c
4 changed files with 384 additions and 241 deletions

View File

@ -51,7 +51,6 @@ mh-cygnus
mh-i386 mh-i386
mt-ebmon29k mt-ebmon29k
mt-h8300 mt-h8300
mt-h8300hds
mt-m68k mt-m68k
mt-mips mt-mips
obj-aout.c obj-aout.c
@ -124,6 +123,12 @@ echo Done in `pwd`.
# #
# #
# $Log$ # $Log$
# Revision 1.10 1991/11/26 02:16:55 sac
# obj-coff-bfd:
# bfd support gets deeper into gas
# *h8*
# fixed numerous bugs in instruction encoding
#
# Revision 1.9 1991/11/11 23:36:39 sac # Revision 1.9 1991/11/11 23:36:39 sac
# Added tc-sparc.c # Added tc-sparc.c
# #

View File

@ -1,4 +1,5 @@
TARG_CPU_DEPENDENTS=$(srcdir)/../include/h8300-opcode.h TARG_CPU_DEPENDENTS=$(srcdir)/../include/h8300-opcode.h
LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a
TDEFINES=-DBFD -DMANY_SEGMENTS TDEFINES=-DBFD_HEADERS -DMANY_SEGMENTS -DBFD
CC=gcc

View File

@ -20,6 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
Written By Steve Chamberlain Written By Steve Chamberlain
steve@cygnus.com steve@cygnus.com
*/ */
@ -70,7 +71,7 @@ reloc_howto_type *r8pcrel;
void md_begin () void md_begin ()
{ {
bfd_arch_info_struct_type *ai; bfd_arch_info_type *ai;
const struct h8_opcode *opcode; const struct h8_opcode *opcode;
opcode_hash_control = hash_new(); opcode_hash_control = hash_new();
@ -96,7 +97,7 @@ struct h8_exp {
}; };
struct h8_op struct h8_op
{ {
op_enum_type mode; op_type mode;
unsigned reg; unsigned reg;
expressionS exp; expressionS exp;
}; };
@ -114,15 +115,15 @@ op_enum_type mode;
*/ */
op_enum_type r8_sord[] = {RS8, RD8}; op_type r8_sord[] = {RS8, RD8};
op_enum_type r16_sord[] = {RS16, RD16}; op_type r16_sord[] = {RS16, RD16};
op_enum_type rind_sord[] = {RSIND, RDIND}; op_type rind_sord[] = {RSIND, RDIND};
op_enum_type abs_sord[2] = {ABS16SRC, ABS16DST}; op_type abs_sord[2] = {ABS16SRC, ABS16DST};
op_enum_type disp_sord[] = {DISPSRC, DISPDST}; op_type disp_sord[] = {DISPSRC, DISPDST};
/* try and parse a reg name, returns number of chars consumed */ /* try and parse a reg name, returns number of chars consumed */
int DEFUN(parse_reg,(src, mode, reg, dst), int DEFUN(parse_reg,(src, mode, reg, dst),
char *src AND char *src AND
op_enum_type *mode AND op_type *mode AND
unsigned int *reg AND unsigned int *reg AND
int dst) int dst)
{ {
@ -199,7 +200,7 @@ DEFUN(get_operand,(ptr, op, dst),
unsigned int dst) unsigned int dst)
{ {
char *src = *ptr; char *src = *ptr;
op_enum_type mode; op_type mode;
unsigned int num; unsigned int num;
unsigned int len; unsigned int len;
op->mode = E; op->mode = E;
@ -309,6 +310,8 @@ DEFUN(md_assemble,(str),
{ {
char *op_start; char *op_start;
char *op_end; char *op_end;
unsigned int i;
struct h8_opcode * opcode; struct h8_opcode * opcode;
/* Drop leading whitespace */ /* Drop leading whitespace */
while (*str == ' ') while (*str == ' ')
@ -334,7 +337,7 @@ DEFUN(md_assemble,(str),
} }
{ {
int ok = 1; int ok = 1;
int j,i; int j,i;
int dispreg = 0; int dispreg = 0;
@ -351,13 +354,13 @@ DEFUN(md_assemble,(str),
{ {
struct h8_opcode *this_try ; struct h8_opcode *this_try ;
int found = 0; int found = 0;
for (j = 0; j < opcode->nopcodes && !found; j++) { for (j = 0; j < opcode->nopcodes && !found; j++) {
this_try = opcode + j; this_try = opcode + j;
for (i = 0; i < opcode->noperands; i++) { for (i = 0; i < opcode->noperands; i++) {
op_enum_type op = (this_try->args.nib[i]) & ~(B30|B31); op_type op = (this_try->args.nib[i]) & ~(B30|B31);
switch (op) { switch (op) {
case Hex0: case Hex0:
case Hex1: case Hex1:
@ -390,8 +393,13 @@ DEFUN(md_assemble,(str),
case RDDEC: case RDDEC:
if (operand[i].mode != op) goto fail; if (operand[i].mode != op) goto fail;
break; break;
case KBIT:
case IMM8: case IMM8:
/* We have an expression, called IMM16, but we know we
want an 8 bit value here */
if (operand[i].mode != IMM16) goto fail;
operand[i].mode = IMM8;
break;
case KBIT:
case IMM16: case IMM16:
case IMM3: case IMM3:
if (operand[i].mode != IMM16) goto fail; if (operand[i].mode != IMM16) goto fail;
@ -418,12 +426,12 @@ DEFUN(md_assemble,(str),
actually we know how big the instruction will be too. So we actually we know how big the instruction will be too. So we
can get can get
*/ */
{ {
char *output = frag_more(this_try->length); char *output = frag_more(this_try->length);
char *output_ptr = output; char *output_ptr = output;
op_enum_type *nibble_ptr = this_try->data.nib; op_type *nibble_ptr = this_try->data.nib;
char part; char part;
op_enum_type c; op_type c;
char high; char high;
int nib; int nib;
top: ; top: ;
@ -434,7 +442,21 @@ DEFUN(md_assemble,(str),
switch (c) { switch (c) {
default: default:
abort(); abort();
case KBIT:
switch (operand[0].exp.X_add_number) {
case 1:
nib = 0;
break;
case 2:
nib = 8;
break;
default:
as_bad("Need #1 or #2 here");
break;
}
/* stop it making a fix */
operand[0].mode = 0;
break;
case 0: case 0:
case 1: case 1:
case 2: case 3: case 4: case 5: case 6: case 2: case 3: case 4: case 5: case 6:
@ -446,30 +468,13 @@ DEFUN(md_assemble,(str),
nib = dispreg; nib = dispreg;
break; break;
case IMM8: case IMM8:
/* if no symbol then put value in place */
if (operand[0].exp.X_add_symbol == 0) {
operand[0].mode = 0; /* stop it making a fix */
*output_ptr++ = (operand[0].exp.X_add_number);
nibble_ptr += 2;
goto top;
}
nib = 0; nib = 0;
break; break;
case DISPDST: case DISPDST:
/* if no symbol then put value in place */
if (operand[1].exp.X_add_symbol == 0) {
operand[1].mode = 0; /* stop it making a fix */
*output_ptr++ =(operand[1].exp.X_add_number)>>8;
*output_ptr++ = (operand[1].exp.X_add_number);
nibble_ptr += 4;
goto top;
}
nib = 0; nib = 0;
break; break;
case IMM3: case IMM3:
if (operand[0].exp.X_add_symbol == 0) { if (operand[0].exp.X_add_symbol == 0) {
operand[0].mode = 0; /* stop it making a fix */ operand[0].mode = 0; /* stop it making a fix */
nib = (operand[0].exp.X_add_number); nib = (operand[0].exp.X_add_number);
@ -477,20 +482,15 @@ DEFUN(md_assemble,(str),
else as_bad("can't have symbol for bit number"); else as_bad("can't have symbol for bit number");
break; break;
case DISPSRC:
case IMM16:
/* if no symbol then put value in place */
if (operand[0].exp.X_add_symbol == 0) {
operand[0].mode = 0; /* stop it making a fix */
*output_ptr++ =(operand[0].exp.X_add_number)>>8;
*output_ptr++ = (operand[0].exp.X_add_number);
nibble_ptr += 4;
goto top;
}
case ABS16SRC:
case ABS16DST: case ABS16DST:
nib = 0;
break;
case DISPSRC:
case ABS16SRC:
case IMM16:
nib=0;
break;
case ABS8DST: case ABS8DST:
case ABS8SRC: case ABS8SRC:
@ -508,12 +508,13 @@ DEFUN(md_assemble,(str),
case RS16: case RS16:
case RSIND: case RSIND:
case RSINC: case RSINC:
case RDIND:
nib= operand[0].reg; nib= operand[0].reg;
break; break;
case RD8: case RD8:
case RD16: case RD16:
case RDDEC: case RDDEC:
case RDIND:
nib = operand[1].reg; nib = operand[1].reg;
break; break;
@ -535,29 +536,39 @@ DEFUN(md_assemble,(str),
} }
/* output any fixes */ /* output any fixes */
for (i = 0; i < 2; i++)
{ {
int i;
for (i = 0; i < 2; i++) {
switch (operand[i].mode) { switch (operand[i].mode) {
case 0: case 0:
break; break;
case DISP8: case DISP8:
fix_new(frag_now, fix_new(frag_now,
output+1, output - frag_now->fr_literal + 1,
1,
operand[i].exp.X_add_symbol,
operand[i].exp.X_subtract_symbol,
operand[i].exp.X_add_number -1,
1,
(int)r8pcrel);
break;
case IMM8:
fix_new(frag_now,
output - frag_now->fr_literal + 1,
1, 1,
operand[i].exp.X_add_symbol, operand[i].exp.X_add_symbol,
operand[i].exp.X_subtract_symbol, operand[i].exp.X_subtract_symbol,
operand[i].exp.X_add_number, operand[i].exp.X_add_number,
0, 0,
(int)r8pcrel); 0);
break; break;
case ABS16SRC: case ABS16SRC:
case ABS16DST: case ABS16DST:
case IMM16: case IMM16:
case DISPSRC: case DISPSRC:
case DISPDST: case DISPDST:
fix_new(frag_now, fix_new(frag_now,
output+2, output - frag_now->fr_literal + 2,
2, 2,
operand[i].exp.X_add_symbol, operand[i].exp.X_add_symbol,
operand[i].exp.X_subtract_symbol, operand[i].exp.X_subtract_symbol,
@ -570,6 +581,7 @@ DEFUN(md_assemble,(str),
case RS16: case RS16:
case RD16: case RD16:
case RDDEC: case RDDEC:
case KBIT:
case RSINC: case RSINC:
case RDIND: case RDIND:
case RSIND: case RSIND:
@ -578,11 +590,11 @@ DEFUN(md_assemble,(str),
abort(); abort();
} }
} }
}
}
} }
} }
}
} }
void void
@ -610,17 +622,105 @@ DEFUN_VOID(md_end)
} }
/* Various routines to kill one day */ /* Various routines to kill one day */
/* Equal to MAX_PRECISION in atof-ieee.c */
#define MAX_LITTLENUMS 6
char *md_atof () { printf("call to md_atof \n"); abort(); } /* Turn a string in input_line_pointer into a floating point constant of type
int md_parse_option () { printf("call to md_parse_option \n"); abort(); } type, and store the appropriate bytes in *litP. The number of LITTLENUMS
emitted is stored in *sizeP . An error message is returned, or NULL on OK.
*/
char *
md_atof(type,litP,sizeP)
char type;
char *litP;
int *sizeP;
{
int prec;
LITTLENUM_TYPE words[MAX_LITTLENUMS];
LITTLENUM_TYPE *wordP;
char *t;
char *atof_ieee();
switch(type) {
case 'f':
case 'F':
case 's':
case 'S':
prec = 2;
break;
case 'd':
case 'D':
case 'r':
case 'R':
prec = 4;
break;
case 'x':
case 'X':
prec = 6;
break;
case 'p':
case 'P':
prec = 6;
break;
default:
*sizeP=0;
return "Bad call to MD_ATOF()";
}
t=atof_ieee(input_line_pointer,type,words);
if(t)
input_line_pointer=t;
*sizeP=prec * sizeof(LITTLENUM_TYPE);
for(wordP=words;prec--;) {
md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
litP+=sizeof(LITTLENUM_TYPE);
}
return ""; /* Someone should teach Dean about null pointers */
}
int
md_parse_option(argP, cntP, vecP)
char **argP;
int *cntP;
char ***vecP;
{abort();
}
int md_short_jump_size; int md_short_jump_size;
void tc_aout_fix_to_chars () { printf("call to tc_aout_fix_to_chars \n"); void tc_aout_fix_to_chars () { printf("call to tc_aout_fix_to_chars \n");
abort(); } abort(); }
void md_create_long_jump () { printf("call to md_create_long_jump \n"); void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
abort(); } char *ptr;
void md_convert_frag () { printf("call to md_convert_frag \n"); abort(); } long from_addr;
long to_addr;
fragS *frag;
symbolS *to_symbol;
{
as_fatal("failed sanity check.");
}
void
md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
char *ptr;
long from_addr, to_addr;
fragS *frag;
symbolS *to_symbol;
{
as_fatal("failed sanity check.");
}
void
md_convert_frag(headers, fragP)
object_headers *headers;
fragS * fragP;
{ printf("call to md_convert_frag \n"); abort(); }
long long
DEFUN(md_section_align,(seg, size), DEFUN(md_section_align,(seg, size),
@ -631,18 +731,48 @@ DEFUN(md_section_align,(seg, size),
} }
void md_apply_fix () { printf("call to md_apply_fix \n"); abort(); } void
md_apply_fix(fixP, val)
fixS *fixP;
long val;
{
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
switch(fixP->fx_size) {
case 1:
*buf++=val;
break;
case 2:
*buf++=(val>>8);
*buf++=val;
break;
case 4:
*buf++=(val>>24);
*buf++=(val>>16);
*buf++=(val>>8);
*buf++=val;
break;
default:
abort();
}
}
void DEFUN(md_operand, (expressionP),expressionS *expressionP) void DEFUN(md_operand, (expressionP),expressionS *expressionP)
{ } { }
int md_long_jump_size; int md_long_jump_size;
int md_estimate_size_before_relax () { printf("call tomd_estimate_size_before_relax \n"); abort(); } int
md_estimate_size_before_relax(fragP, segment_type)
register fragS *fragP;
register segT segment_type;
{ printf("call tomd_estimate_size_before_relax \n"); abort(); }
/* Put number into target byte order */ /* Put number into target byte order */
void DEFUN(md_number_to_chars,(ptr, use, nbytes), void DEFUN(md_number_to_chars,(ptr, use, nbytes),
char *ptr AND char *ptr AND
int use AND long use AND
unsigned int nbytes) int nbytes)
{ {
switch (nbytes) { switch (nbytes) {
case 4: *ptr++ = (use >> 24) & 0xff; case 4: *ptr++ = (use >> 24) & 0xff;
@ -654,9 +784,7 @@ void DEFUN(md_number_to_chars,(ptr, use, nbytes),
abort(); abort();
} }
} }
long md_pcrel_from(fixP)
long md_pcrel_from () { printf("call to md_pcrel_from \n"); abort(); } fixS *fixP; { abort(); }
void md_create_short_jump () { printf("call to md_create_short_jump \n");
abort(); }
void tc_coff_symbol_emit_hook() { } void tc_coff_symbol_emit_hook() { }

9
gas/config/tc-h8300.h Normal file
View File

@ -0,0 +1,9 @@
#define TC_H8300
/* This macro translates between an internal fix and an coff reloc type */
#define TC_COFF_FIX2RTYPE(fixP) \
(fixP->fx_pcrel ? (fixP->fx_size == 1 ? R_PCRBYTE : R_PCRWORD ) : \
(fixP->fx_size == 1 ? R_RELBYTE : R_RELWORD ))