/* Also note that comments like this one will always work. */
const char line_comment_chars[] = "#";
+const char line_separator_chars[] = "";
+
/* Chars that can be used to separate mant from exp in floating point nums */
const char EXP_CHARS[] = "eE";
* advance the pointer.
*/
-enum _register m68k_reg_parse(ccp)
-register char **ccp;
+enum _register
+m68k_reg_parse(ccp)
+ register char **ccp;
{
char *start = *ccp;
+#ifdef REGISTER_PREFIX
+ if (*start == REGISTER_PREFIX)
+ ++start;
+#endif
+
if (isalpha(*start) && is_name_beginner(*start))
{
char c;
symbolS *symbolP;
c = *p++;
- while (isalpha(c) || isdigit(c))
- {
- c = *p++;
- }
+ while (isalpha(c) || isdigit(c) || c == '_')
+ {
+ c = *p++;
+ }
- ;
* -- p = 0;
symbolP = symbol_find(start);
*p = c;
break;
} /* Its BIG */
if(offs(opP->con1)>0) {
- as_warn("Bignum assumed to be binary bit-pattern");
if(offs(opP->con1)>baseo) {
as_warn("Bignum too big for %c format; truncated",s[1]);
offs(opP->con1)=baseo;
fixS *fixP;
long val;
{
+#ifdef IBM_COMPILER_SUX
+ /* This is unnecessary but it convinces the native rs6000
+ compiler to generate the code we want. */
+ char *buf = fixP->fx_frag->fr_literal;
+ buf += fixP->fx_where;
+#else /* IBM_COMPILER_SUX */
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
+#endif /* IBM_COMPILER_SUX */
switch(fixP->fx_size) {
case 1:
break;
}
break;
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- if(ok>=10 && ok<=70) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok==10) ? 1 : 0;
- as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
- }
- break;
case SEG_BIG:
if (offs (exp) < 0 /* flonum */
&& (ok == 80 /* no bignums */
}
break;
default:
- as_fatal("failed sanity check.");
+ case SEG_TEXT:
+ case SEG_DATA:
+ case SEG_BSS:
+ case SEG_UNKNOWN:
+ case SEG_DIFFERENCE:
+ if(ok>=10 && ok<=70) {
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
+ offs(exp)= (ok==10) ? 1 : 0;
+ as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
+ }
+ break;
+
+
}
if(input_line_pointer!=exp->e_end+1)
as_bad("Ignoring junk after expression");
#include "../opcodes/z8k-opc.h"
#include "as.h"
+#include "read.h"
#include "bfd.h"
#include <ctype.h>
#include "listing.h"
-char comment_chars[] = { ';',0 };
-char line_separator_chars[] = { '$' ,0};
+const char comment_chars[] = { '!',0 };
+const char line_separator_chars[] = { ';' ,0};
+const char line_comment_chars[] = "";
extern int machine;
extern int coff_flags;
{ "import", s_ignore, 0},
{ "page", listing_eject, 0},
{ "program", s_ignore, 0},
-{ "SEGM", s_segm, 0},
-{ "UNSEG", s_unseg, 0},
+{ "z8001", s_segm, 0},
+{ "z8002", s_unseg, 0},
{ 0,0,0 }
};
/* Chars that mean this number is a floating point constant */
/* As in 0f12.456 */
/* or 0d1.2345e12 */
-char FLT_CHARS[] = "rRsSfFdDxXpP";
+const char FLT_CHARS[] = "rRsSfFdDxXpP";
const relax_typeS md_relax_table[1];
-static op_type *da_address;
-static op_type *imm_operand;
+static expressionS *da_operand;
+static expressionS *imm_operand;
+
+int reg[16];
int the_cc;
char *
unsigned int *reg)
{
char *res = 0;
- if (src[0] == 'R')
+ if (src[0] == 'r')
{
- if (src[1] == 'R')
+ if (src[1] == 'r')
{
*mode = CLASS_REG_LONG;
res = whatreg(reg, src+2);
}
- else if (src[1] == 'H')
+ else if (src[1] == 'h')
{
*mode = CLASS_REG_BYTE;
res = whatreg(reg, src+2);
}
- else if (src[1] == 'L')
+ else if (src[1] == 'l')
{
*mode = CLASS_REG_BYTE;
res = whatreg(reg, src+2);
}
- else if (src[1] == 'Q')
+ else if (src[1] == 'q')
{
* mode = CLASS_REG_QUAD;
res = whatreg(reg, src+2);
struct cc_names table[] =
{
- 0x0,"F",
- 0x6,"Z",
- 0xe,"NZ",
- 0x7,"C",
- 0xf,"NC",
- 0xd,"PL",
- 0x5,"MI",
- 0xe,"NE",
- 0x6,"EQ",
- 0x4,"OV",
- 0xc,"NOV",
- 0x4,"PE",
- 0xC,"PO",
- 0x9,"GE",
- 0x1,"LT",
- 0xa,"GT",
- 0x2,"LE",
- 0xf,"UGE",
- 0x7,"ULT",
- 0xb,"UGT",
- 0x3,"ULE",
+ 0x0,"f",
+ 0x1,"lt",
+ 0x2,"le",
+ 0x3,"ule",
+ 0x4,"ov",
+ 0x4,"pe",
+ 0x5,"mi",
+ 0x6,"eq",
+ 0x6,"z",
+ 0x7,"c",
+ 0x7,"ult",
+ 0x8,"t",
+ 0x9,"ge",
+ 0xa,"gt",
+ 0xb,"ugt",
+ 0xc,"nov",
+ 0xc,"po",
+ 0xd,"pl",
+ 0xe,"ne",
+ 0xe,"nz",
+ 0xf,"nc",
+ 0xf,"uge",
0,0
};
char *src = *ptr;
int r;
int i;
+ while (*src== ' ')
+ src++;
+
mode->mode = CLASS_CC;
for (i = 0; table[i].name; i++)
{
if (table[i].name[j] != src[j])
goto fail;
}
- the_cc = table[i].value;
+ the_cc = table[i].value;
*ptr = src + j;
return;
fail:;
}
-the_cc = 0x8;
+ the_cc = 0x8;
return ;
}
unsigned int size;
mode->mode = 0;
+
+ while (*src == ' ')
+ src++;
if (*src == '#')
{
mode->mode = CLASS_IMM;
- imm_operand = mode;
+ imm_operand = &(mode->exp);
src = parse_exp(src+1, &(mode->exp));
}
else if (*src == '@') {
}
else
{
- int reg;
- end = parse_reg(src, &mode->mode, ®);
+ int regn;
+ end = parse_reg(src, &mode->mode, ®n);
if (end)
{
regaddr(mode->mode,"ra(rb) ra");
regword(mode->mode,"ra(rb) rb");
mode->mode = CLASS_BX;
- mode->reg = reg;
+ mode->reg = regn;
mode->x_reg = nr;
-
+ reg[ARG_RX] = nr;
}
else
{
src = parse_exp(src, &(mode->exp));
src = checkfor(src, ')');
mode->mode = CLASS_BA;
- mode->reg = reg;
+ mode->reg = regn;
mode->x_reg = 0;
+ da_operand = &(mode->exp);
}
}
else
{
- mode->reg = reg;
+ mode->reg = regn;
mode->x_reg = 0;
}
}
if (*src == '(')
{
src++;
- end = parse_reg(src, &(mode->mode), ®);
+ end = parse_reg(src, &(mode->mode), ®n);
regword(mode->mode,"addr(Ra) ra");
mode->mode = CLASS_X;
- mode->reg = reg;
+ mode->reg = regn;
mode->x_reg =0;
- da_address = mode;
+ da_operand = &(mode->exp);
src = checkfor(end, ')');
}
else
mode->mode = CLASS_DA;
mode->reg = 0;
mode->x_reg = 0;
- da_address = mode;
+ da_operand = &(mode->exp);
}
}
}
operand[1].mode = 0;
break;
- case 1:
+ case 1:
ptr++;
- get_operand(& ptr, operand +0,0);
+ if (opcode->arg_info[0] == CLASS_CC)
+ {
+ get_cc_operand(&ptr, operand+0,0);
+ }
+ else
+ {
+
+ get_operand(& ptr, operand +0,0);
+ }
operand[1].mode =0;
break;
}
else
{
+
get_operand(& ptr, operand +0,0);
}
if (*ptr == ',') ptr++;
get_operand(& ptr, operand +1, 1);
break;
+
+ case 3:
+ ptr++;
+ get_operand(& ptr, operand +0,0);
+ if (*ptr == ',') ptr++;
+ get_operand(& ptr, operand +1, 1);
+ if (*ptr == ',') ptr++;
+ get_operand(& ptr, operand +2, 2);
+ break;
default:
abort();
provided
*/
-int reg[16];
-expressionS disp;
+
+
static
opcode_entry_type *
{
int mode = operands[i].mode;
- if ((mode&CLASS_MASK) != (this_try->arg_info[i] & CLASS_MASK)) goto fail;
-
- reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
+ if ((mode&CLASS_MASK) != (this_try->arg_info[i] & CLASS_MASK))
+ {
+ /* it could be an pc rel operand, if this is a da mode and
+ we like disps, then insert it */
+
+ if (mode == CLASS_DA && this_try->arg_info[i] == CLASS_DISP)
+ {
+ /* This is the case */
+ operands[i].mode = CLASS_DISP;
+ }
+ else {
+ /* Can't think of a way to turn what we've been given into
+ something that's ok */
+ goto fail;
+ }
+ }
+ switch (mode & CLASS_MASK) {
+ default:
+ break;
+ case CLASS_X:
+ case CLASS_IR:
+ case CLASS_BA:
+ case CLASS_BX:
+ case CLASS_DISP:
+ case CLASS_REG:
+ reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
+ break;
+ }
}
found =1;
DEFUN(newfix,(ptr, type, operand),
int ptr AND
int type AND
- op_type *operand)
+ expressionS *operand)
{
-
- fix_new(frag_now,
- ptr,
- 1,
- operand->exp.X_add_symbol,
- operand->exp.X_subtract_symbol,
- operand->exp.X_add_number,
- 0,
- type);
+ if (operand->X_add_symbol
+ || operand->X_subtract_symbol
+ || operand->X_add_number) {
+ fix_new(frag_now,
+ ptr,
+ 1,
+ operand->X_add_symbol,
+ operand->X_subtract_symbol,
+ operand->X_add_number,
+ 0,
+ type);
+ }
}
int nib;
int nibble;
unsigned short *class_ptr;
- length = this_try->length;
- if (segmented_mode && da_address)
- {
- /* two more bytes when in segmented mode and using da address
- mode */
- length += 2;
- }
- output = frag_more(length);
-memset(buffer, 20, 0);
+ memset(buffer, 20, 0);
class_ptr = this_try->byte_info;
top: ;
switch (c & CLASS_MASK)
{
default:
+
abort();
case CLASS_ADDRESS:
/* Direct address, we don't cope with the SS mode right now */
if (segmented_mode) {
- newfix((output_ptr-buffer)/2, R_DA | R_SEG, da_address);
- output_ptr += 8;
+ newfix((output_ptr-buffer)/2, R_DA | R_SEG, da_operand);
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
}
else {
- newfix((output_ptr-buffer)/2, R_DA, da_address);
- output_ptr += 4;
+ newfix((output_ptr-buffer)/2, R_DA, da_operand);
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
}
- da_address = 0;
+ da_operand = 0;
break;
+ case CLASS_DISP8:
+ /* pc rel 8 bit */
+ newfix((output_ptr-buffer)/2, R_JR, da_operand);
+ da_operand = 0;
+ *output_ptr++ = 0;
+ *output_ptr++ = 0;
+ break;
+
case CLASS_CC:
*output_ptr++ = the_cc;
break;
right reg */
*output_ptr++ = reg[c & 0xf];
break;
+ case CLASS_DISP:
+ newfix((output_ptr-buffer)/2, R_DA, da_operand);
+ da_operand= 0;
+ output_ptr += 4;
+ break;
case CLASS_IMM:
{
nib = 0;
switch (c & ARG_MASK)
{
case ARG_IMM4:
+ *output_ptr ++ = imm_operand->X_add_number;
+ imm_operand->X_add_number = 0;
+ newfix((output_ptr-buffer)/2, R_IMM4L, imm_operand);
+ break;
+ case ARG_IMMNMINUS1:
+ imm_operand->X_add_number --;
newfix((output_ptr-buffer)/2, R_IMM4L, imm_operand);
*output_ptr++ = 0;
break;
-
case ARG_IMM8:
newfix((output_ptr-buffer)/2, R_IMM8, imm_operand);
*output_ptr++ = 0;
*output_ptr++ = 0;
- case ARG_IMM16:
- newfix((output_ptr-buffer)/2, R_IMM16, imm_operand);
+ case ARG_NIM16:
+ imm_operand->X_add_number = - imm_operand->X_add_number;
+ newfix((output_ptr-buffer)/2, R_DA, imm_operand);
*output_ptr++ = 0;
*output_ptr++ = 0;
*output_ptr++ = 0;
*output_ptr++ = 0;
break;
+ case ARG_IMM16:
+ {
+ int n = imm_operand->X_add_number ;
+ imm_operand->X_add_number = 0;
+ newfix((output_ptr-buffer)/2, R_DA, imm_operand);
+ *output_ptr++ = n>>24;
+ *output_ptr++ = n>>16;
+ *output_ptr++ = n>>8;
+ *output_ptr++ = n;
+ }
+
+ break;
+
case ARG_IMM32:
newfix((output_ptr-buffer)/2, R_IMM32, imm_operand);
*output_ptr++ = 0;
/* Copy from the nibble buffer into the frag */
{
+ int length = (output_ptr - buffer) / 2 ;
char *src = buffer;
- char *fragp = output;
+ char *fragp = frag_more(length);
+ frag_wane(frag_now);
+ frag_new(0);
while (src < output_ptr)
{
*fragp = (src[0] << 4) | src[1];
char *op_start;
char *op_end;
unsigned int i;
- struct z8k_op operand[2];
+ struct z8k_op operand[3];
opcode_entry_type *opcode;
opcode_entry_type * prev_opcode;
buf[0] = (buf[0] & 0xf0) | ((buf[0] + val) & 0xf);
break;
+ case R_JR:
+
+ *buf++= val;
+/* if (val != 0) abort();*/
+ break;
+
+
case R_IMM8:
buf[0] += val;
break;
-
+ break;
case R_DA:
- case R_IMM16:
*buf++=(val>>8);
*buf++=val;
break;
{
case 2:
- intr->r_type = R_IMM16;
+ intr->r_type = R_DA;
break;
case 1:
intr->r_type = R_IMM8;