| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include "as.h" |
| 29 |
#include "safe-ctype.h" |
| 30 |
#include "opcode/pdp11.h" |
| 31 |
|
| 32 |
static int set_option PARAMS ((char *arg)); |
| 33 |
static int set_cpu_model PARAMS ((char *arg)); |
| 34 |
static int set_machine_model PARAMS ((char *arg)); |
| 35 |
|
| 36 |
extern int flonum_gen2vax PARAMS ((char format_letter, FLONUM_TYPE * f, |
| 37 |
LITTLENUM_TYPE * words)); |
| 38 |
|
| 39 |
#define TRUE 1 |
| 40 |
#define FALSE 0 |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
struct pdp11_code |
| 46 |
{ |
| 47 |
char *error; |
| 48 |
int code; |
| 49 |
int additional; |
| 50 |
int word; |
| 51 |
struct |
| 52 |
{ |
| 53 |
bfd_reloc_code_real_type type; |
| 54 |
expressionS exp; |
| 55 |
int pc_rel; |
| 56 |
} reloc; |
| 57 |
}; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
int pdp11_extension[PDP11_EXT_NUM]; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
#define ASM_OPT_PIC 1 |
| 72 |
#define ASM_OPT_NUM 2 |
| 73 |
|
| 74 |
int asm_option[ASM_OPT_NUM]; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
const char comment_chars[] = "#/"; |
| 79 |
|
| 80 |
|
| 81 |
const char line_comment_chars[] = "#/"; |
| 82 |
|
| 83 |
const char line_separator_chars[] = ";"; |
| 84 |
|
| 85 |
|
| 86 |
const char EXP_CHARS[] = "eE"; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
const char FLT_CHARS[] = "dDfF"; |
| 92 |
|
| 93 |
void pseudo_even (int); |
| 94 |
void pseudo_bss (int); |
| 95 |
|
| 96 |
const pseudo_typeS md_pseudo_table[] = |
| 97 |
{ |
| 98 |
{ "bss", pseudo_bss, 0 }, |
| 99 |
{ "even", pseudo_even, 0 }, |
| 100 |
{ 0, 0, 0 }, |
| 101 |
}; |
| 102 |
|
| 103 |
static void |
| 104 |
init_defaults () |
| 105 |
{ |
| 106 |
static int first = 1; |
| 107 |
|
| 108 |
if (first) |
| 109 |
{ |
| 110 |
set_option ("all-extensions"); |
| 111 |
set_option ("pic"); |
| 112 |
first = 0; |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
static struct hash_control *insn_hash = NULL; |
| 117 |
|
| 118 |
void |
| 119 |
md_begin () |
| 120 |
{ |
| 121 |
int i; |
| 122 |
|
| 123 |
init_defaults (); |
| 124 |
|
| 125 |
insn_hash = hash_new (); |
| 126 |
if (insn_hash == NULL) |
| 127 |
as_fatal ("Virtual memory exhausted"); |
| 128 |
|
| 129 |
for (i = 0; i < pdp11_num_opcodes; i++) |
| 130 |
hash_insert (insn_hash, pdp11_opcodes[i].name, (PTR)(pdp11_opcodes + i)); |
| 131 |
for (i = 0; i < pdp11_num_aliases; i++) |
| 132 |
hash_insert (insn_hash, pdp11_aliases[i].name, (PTR)(pdp11_aliases + i)); |
| 133 |
} |
| 134 |
|
| 135 |
void |
| 136 |
md_number_to_chars (con, value, nbytes) |
| 137 |
char con[]; |
| 138 |
valueT value; |
| 139 |
int nbytes; |
| 140 |
{ |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
switch (nbytes) |
| 147 |
{ |
| 148 |
case 0: |
| 149 |
break; |
| 150 |
case 1: |
| 151 |
con[0] = value & 0xff; |
| 152 |
break; |
| 153 |
case 2: |
| 154 |
con[0] = value & 0xff; |
| 155 |
con[1] = (value >> 8) & 0xff; |
| 156 |
break; |
| 157 |
case 4: |
| 158 |
con[0] = (value >> 16) & 0xff; |
| 159 |
con[1] = (value >> 24) & 0xff; |
| 160 |
con[2] = value & 0xff; |
| 161 |
con[3] = (value >> 8) & 0xff; |
| 162 |
break; |
| 163 |
default: |
| 164 |
BAD_CASE (nbytes); |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
void |
| 172 |
md_apply_fix3 (fixP, valP, seg) |
| 173 |
fixS *fixP; |
| 174 |
valueT * valP; |
| 175 |
segT seg ATTRIBUTE_UNUSED; |
| 176 |
{ |
| 177 |
valueT code; |
| 178 |
valueT mask; |
| 179 |
valueT val = * valP; |
| 180 |
char *buf; |
| 181 |
int shift; |
| 182 |
int size; |
| 183 |
|
| 184 |
buf = fixP->fx_where + fixP->fx_frag->fr_literal; |
| 185 |
size = fixP->fx_size; |
| 186 |
code = md_chars_to_number (buf, size); |
| 187 |
|
| 188 |
switch (fixP->fx_r_type) |
| 189 |
{ |
| 190 |
case BFD_RELOC_16: |
| 191 |
case BFD_RELOC_16_PCREL: |
| 192 |
mask = 0xffff; |
| 193 |
shift = 0; |
| 194 |
break; |
| 195 |
case BFD_RELOC_PDP11_DISP_8_PCREL: |
| 196 |
mask = 0x00ff; |
| 197 |
shift = 1; |
| 198 |
break; |
| 199 |
case BFD_RELOC_PDP11_DISP_6_PCREL: |
| 200 |
mask = 0x003f; |
| 201 |
shift = 1; |
| 202 |
val = -val; |
| 203 |
break; |
| 204 |
default: |
| 205 |
BAD_CASE (fixP->fx_r_type); |
| 206 |
} |
| 207 |
|
| 208 |
if (fixP->fx_addsy != NULL) |
| 209 |
val += symbol_get_bfdsym (fixP->fx_addsy)->section->vma; |
| 210 |
|
| 211 |
|
| 212 |
code &= ~mask; |
| 213 |
code |= (val >> shift) & mask; |
| 214 |
number_to_chars_littleendian (buf, code, size); |
| 215 |
|
| 216 |
if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) |
| 217 |
fixP->fx_done = 1; |
| 218 |
} |
| 219 |
|
| 220 |
long |
| 221 |
md_chars_to_number (con, nbytes) |
| 222 |
unsigned char con[]; |
| 223 |
int nbytes; |
| 224 |
{ |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
switch (nbytes) |
| 231 |
{ |
| 232 |
case 0: |
| 233 |
return 0; |
| 234 |
case 1: |
| 235 |
return con[0]; |
| 236 |
case 2: |
| 237 |
return (con[1] << BITS_PER_CHAR) | con[0]; |
| 238 |
case 4: |
| 239 |
return |
| 240 |
(((con[1] << BITS_PER_CHAR) | con[0]) << (2 * BITS_PER_CHAR)) | |
| 241 |
((con[3] << BITS_PER_CHAR) | con[2]); |
| 242 |
default: |
| 243 |
BAD_CASE (nbytes); |
| 244 |
return 0; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
static char * |
| 249 |
skip_whitespace (char *str) |
| 250 |
{ |
| 251 |
while (*str == ' ' || *str == '\t') |
| 252 |
str++; |
| 253 |
return str; |
| 254 |
} |
| 255 |
|
| 256 |
static char * |
| 257 |
find_whitespace (char *str) |
| 258 |
{ |
| 259 |
while (*str != ' ' && *str != '\t' && *str != 0) |
| 260 |
str++; |
| 261 |
return str; |
| 262 |
} |
| 263 |
|
| 264 |
static char * |
| 265 |
parse_reg (char *str, struct pdp11_code *operand) |
| 266 |
{ |
| 267 |
str = skip_whitespace (str); |
| 268 |
if (TOLOWER (*str) == 'r') |
| 269 |
{ |
| 270 |
str++; |
| 271 |
switch (*str) |
| 272 |
{ |
| 273 |
case '0': case '1': case '2': case '3': |
| 274 |
case '4': case '5': case '6': case '7': |
| 275 |
operand->code = *str - '0'; |
| 276 |
str++; |
| 277 |
break; |
| 278 |
default: |
| 279 |
operand->error = "Bad register name"; |
| 280 |
return str - 1; |
| 281 |
} |
| 282 |
} |
| 283 |
else if (strncmp (str, "sp", 2) == 0 || |
| 284 |
strncmp (str, "SP", 2) == 0) |
| 285 |
{ |
| 286 |
operand->code = 6; |
| 287 |
str += 2; |
| 288 |
} |
| 289 |
else if (strncmp (str, "pc", 2) == 0 || |
| 290 |
strncmp (str, "PC", 2) == 0) |
| 291 |
{ |
| 292 |
operand->code = 7; |
| 293 |
str += 2; |
| 294 |
} |
| 295 |
else |
| 296 |
{ |
| 297 |
operand->error = "Bad register name"; |
| 298 |
return str; |
| 299 |
} |
| 300 |
|
| 301 |
return str; |
| 302 |
} |
| 303 |
|
| 304 |
static char * |
| 305 |
parse_ac5 (char *str, struct pdp11_code *operand) |
| 306 |
{ |
| 307 |
str = skip_whitespace (str); |
| 308 |
if (strncmp (str, "fr", 2) == 0 || |
| 309 |
strncmp (str, "FR", 2) == 0 || |
| 310 |
strncmp (str, "ac", 2) == 0 || |
| 311 |
strncmp (str, "AC", 2) == 0) |
| 312 |
{ |
| 313 |
str += 2; |
| 314 |
switch (*str) |
| 315 |
{ |
| 316 |
case '0': case '1': case '2': case '3': |
| 317 |
case '4': case '5': |
| 318 |
operand->code = *str - '0'; |
| 319 |
str++; |
| 320 |
break; |
| 321 |
default: |
| 322 |
operand->error = "Bad register name"; |
| 323 |
return str - 2; |
| 324 |
} |
| 325 |
} |
| 326 |
else |
| 327 |
{ |
| 328 |
operand->error = "Bad register name"; |
| 329 |
return str; |
| 330 |
} |
| 331 |
|
| 332 |
return str; |
| 333 |
} |
| 334 |
|
| 335 |
static char * |
| 336 |
parse_ac (char *str, struct pdp11_code *operand) |
| 337 |
{ |
| 338 |
str = parse_ac5 (str, operand); |
| 339 |
if (!operand->error && operand->code > 3) |
| 340 |
{ |
| 341 |
operand->error = "Bad register name"; |
| 342 |
return str - 3; |
| 343 |
} |
| 344 |
|
| 345 |
return str; |
| 346 |
} |
| 347 |
|
| 348 |
static char * |
| 349 |
parse_expression (char *str, struct pdp11_code *operand) |
| 350 |
{ |
| 351 |
char *save_input_line_pointer; |
| 352 |
segT seg; |
| 353 |
|
| 354 |
save_input_line_pointer = input_line_pointer; |
| 355 |
input_line_pointer = str; |
| 356 |
seg = expression (&operand->reloc.exp); |
| 357 |
if (seg == NULL) |
| 358 |
{ |
| 359 |
input_line_pointer = save_input_line_pointer; |
| 360 |
operand->error = "Error in expression"; |
| 361 |
return str; |
| 362 |
} |
| 363 |
|
| 364 |
str = input_line_pointer; |
| 365 |
input_line_pointer = save_input_line_pointer; |
| 366 |
|
| 367 |
operand->reloc.pc_rel = 0; |
| 368 |
|
| 369 |
return str; |
| 370 |
} |
| 371 |
|
| 372 |
static char * |
| 373 |
parse_op_no_deferred (char *str, struct pdp11_code *operand) |
| 374 |
{ |
| 375 |
LITTLENUM_TYPE literal_float[2]; |
| 376 |
|
| 377 |
str = skip_whitespace (str); |
| 378 |
|
| 379 |
switch (*str) |
| 380 |
{ |
| 381 |
case '(': |
| 382 |
str = parse_reg (str + 1, operand); |
| 383 |
if (operand->error) |
| 384 |
return str; |
| 385 |
str = skip_whitespace (str); |
| 386 |
if (*str != ')') |
| 387 |
{ |
| 388 |
operand->error = "Missing ')'"; |
| 389 |
return str; |
| 390 |
} |
| 391 |
str++; |
| 392 |
if (*str == '+') |
| 393 |
{ |
| 394 |
operand->code |= 020; |
| 395 |
str++; |
| 396 |
} |
| 397 |
else |
| 398 |
{ |
| 399 |
operand->code |= 010; |
| 400 |
} |
| 401 |
break; |
| 402 |
|
| 403 |
case '#': |
| 404 |
case '$': |
| 405 |
str = parse_expression (str + 1, operand); |
| 406 |
if (operand->error) |
| 407 |
return str; |
| 408 |
operand->additional = TRUE; |
| 409 |
operand->word = operand->reloc.exp.X_add_number; |
| 410 |
switch (operand->reloc.exp.X_op) |
| 411 |
{ |
| 412 |
case O_constant: |
| 413 |
break; |
| 414 |
case O_symbol: |
| 415 |
case O_add: |
| 416 |
case O_subtract: |
| 417 |
operand->reloc.type = BFD_RELOC_16; |
| 418 |
operand->reloc.pc_rel = 0; |
| 419 |
break; |
| 420 |
case O_big: |
| 421 |
if (operand->reloc.exp.X_add_number > 0) |
| 422 |
{ |
| 423 |
operand->error = "Error in expression"; |
| 424 |
break; |
| 425 |
} |
| 426 |
|
| 427 |
know (operand->reloc.exp.X_add_number < 0); |
| 428 |
flonum_gen2vax ('f', &generic_floating_point_number, literal_float); |
| 429 |
operand->word = literal_float[0]; |
| 430 |
if (literal_float[1] != 0) |
| 431 |
as_warn (_("Low order bits truncated in immediate float operand")); |
| 432 |
break; |
| 433 |
default: |
| 434 |
operand->error = "Error in expression"; |
| 435 |
break; |
| 436 |
} |
| 437 |
operand->code = 027; |
| 438 |
break; |
| 439 |
|
| 440 |
default: |
| 441 |
{ |
| 442 |
char *old = str; |
| 443 |
|
| 444 |
if (strncmp (str, "-(", 2) == 0) |
| 445 |
{ |
| 446 |
str = parse_reg (str + 2, operand); |
| 447 |
if (operand->error) |
| 448 |
return str; |
| 449 |
str = skip_whitespace (str); |
| 450 |
if (*str != ')') |
| 451 |
{ |
| 452 |
operand->error = "Missing ')'"; |
| 453 |
return str; |
| 454 |
} |
| 455 |
operand->code |= 040; |
| 456 |
str++; |
| 457 |
break; |
| 458 |
} |
| 459 |
|
| 460 |
str = parse_expression (str, operand); |
| 461 |
if (operand->error) |
| 462 |
return str; |
| 463 |
|
| 464 |
str = skip_whitespace (str); |
| 465 |
|
| 466 |
if (*str != '(') |
| 467 |
{ |
| 468 |
if (operand->reloc.exp.X_op != O_symbol) |
| 469 |
{ |
| 470 |
operand->error = "Label expected"; |
| 471 |
return old; |
| 472 |
} |
| 473 |
operand->code = 067; |
| 474 |
operand->additional = 1; |
| 475 |
operand->word = 0; |
| 476 |
operand->reloc.type = BFD_RELOC_16_PCREL; |
| 477 |
operand->reloc.pc_rel = 1; |
| 478 |
break; |
| 479 |
} |
| 480 |
|
| 481 |
str++; |
| 482 |
str = parse_reg (str, operand); |
| 483 |
if (operand->error) |
| 484 |
return str; |
| 485 |
|
| 486 |
str = skip_whitespace (str); |
| 487 |
|
| 488 |
if (*str != ')') |
| 489 |
{ |
| 490 |
operand->error = "Missing ')'"; |
| 491 |
return str; |
| 492 |
} |
| 493 |
|
| 494 |
str++; |
| 495 |
operand->additional = TRUE; |
| 496 |
operand->code |= 060; |
| 497 |
switch (operand->reloc.exp.X_op) |
| 498 |
{ |
| 499 |
case O_symbol: |
| 500 |
operand->word = 0; |
| 501 |
operand->reloc.pc_rel = 1; |
| 502 |
break; |
| 503 |
case O_constant: |
| 504 |
if ((operand->code & 7) == 7) |
| 505 |
{ |
| 506 |
operand->reloc.pc_rel = 1; |
| 507 |
operand->word = operand->reloc.exp.X_add_number; |
| 508 |
} |
| 509 |
else |
| 510 |
{ |
| 511 |
operand->word = operand->reloc.exp.X_add_number; |
| 512 |
} |
| 513 |
break; |
| 514 |
default: |
| 515 |
BAD_CASE (operand->reloc.exp.X_op); |
| 516 |
} |
| 517 |
break; |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
return str; |
| 522 |
} |
| 523 |
|
| 524 |
static char * |
| 525 |
parse_op_noreg (char *str, struct pdp11_code *operand) |
| 526 |
{ |
| 527 |
str = skip_whitespace (str); |
| 528 |
operand->error = NULL; |
| 529 |
|
| 530 |
if (*str == '@' || *str == '*') |
| 531 |
{ |
| 532 |
str = parse_op_no_deferred (str + 1, operand); |
| 533 |
if (operand->error) |
| 534 |
return str; |
| 535 |
operand->code |= 010; |
| 536 |
} |
| 537 |
else |
| 538 |
str = parse_op_no_deferred (str, operand); |
| 539 |
|
| 540 |
return str; |
| 541 |
} |
| 542 |
|
| 543 |
static char * |
| 544 |
parse_op (char *str, struct pdp11_code *operand) |
| 545 |
{ |
| 546 |
str = skip_whitespace (str); |
| 547 |
|
| 548 |
str = parse_reg (str, operand); |
| 549 |
if (!operand->error) |
| 550 |
return str; |
| 551 |
|
| 552 |
operand->error = NULL; |
| 553 |
parse_ac5 (str, operand); |
| 554 |
if (!operand->error) |
| 555 |
{ |
| 556 |
operand->error = "Float AC not legal as integer operand"; |
| 557 |
return str; |
| 558 |
} |
| 559 |
|
| 560 |
return parse_op_noreg (str, operand); |
| 561 |
} |
| 562 |
|
| 563 |
static char * |
| 564 |
parse_fop (char *str, struct pdp11_code *operand) |
| 565 |
{ |
| 566 |
str = skip_whitespace (str); |
| 567 |
|
| 568 |
str = parse_ac5 (str, operand); |
| 569 |
if (!operand->error) |
| 570 |
return str; |
| 571 |
|
| 572 |
operand->error = NULL; |
| 573 |
parse_reg (str, operand); |
| 574 |
if (!operand->error) |
| 575 |
{ |
| 576 |
operand->error = "General register not legal as float operand"; |
| 577 |
return str; |
| 578 |
} |
| 579 |
|
| 580 |
return parse_op_noreg (str, operand); |
| 581 |
} |
| 582 |
|
| 583 |
static char * |
| 584 |
parse_separator (char *str, int *error) |
| 585 |
{ |
| 586 |
str = skip_whitespace (str); |
| 587 |
*error = (*str != ','); |
| 588 |
if (!*error) |
| 589 |
str++; |
| 590 |
return str; |
| 591 |
} |
| 592 |
|
| 593 |
void |
| 594 |
md_assemble (instruction_string) |
| 595 |
char *instruction_string; |
| 596 |
{ |
| 597 |
const struct pdp11_opcode *op; |
| 598 |
struct pdp11_code insn, op1, op2; |
| 599 |
int error; |
| 600 |
int size; |
| 601 |
char *err = NULL; |
| 602 |
char *str; |
| 603 |
char *p; |
| 604 |
char c; |
| 605 |
|
| 606 |
str = skip_whitespace (instruction_string); |
| 607 |
p = find_whitespace (str); |
| 608 |
if (p - str == 0) |
| 609 |
{ |
| 610 |
as_bad ("No instruction found"); |
| 611 |
return; |
| 612 |
} |
| 613 |
|
| 614 |
c = *p; |
| 615 |
*p = '\0'; |
| 616 |
op = (struct pdp11_opcode *)hash_find (insn_hash, str); |
| 617 |
*p = c; |
| 618 |
if (op == 0) |
| 619 |
{ |
| 620 |
as_bad (_("Unknown instruction '%s'"), str); |
| 621 |
return; |
| 622 |
} |
| 623 |
|
| 624 |
if (!pdp11_extension[op->extension]) |
| 625 |
{ |
| 626 |
as_warn ("Unsupported instruction set extension: %s", op->name); |
| 627 |
return; |
| 628 |
} |
| 629 |
|
| 630 |
insn.error = NULL; |
| 631 |
insn.code = op->opcode; |
| 632 |
insn.reloc.type = BFD_RELOC_NONE; |
| 633 |
op1.error = NULL; |
| 634 |
op1.additional = FALSE; |
| 635 |
op1.reloc.type = BFD_RELOC_NONE; |
| 636 |
op2.error = NULL; |
| 637 |
op2.additional = FALSE; |
| 638 |
op2.reloc.type = BFD_RELOC_NONE; |
| 639 |
|
| 640 |
str = p; |
| 641 |
size = 2; |
| 642 |
|
| 643 |
switch (op->type) |
| 644 |
{ |
| 645 |
case PDP11_OPCODE_NO_OPS: |
| 646 |
str = skip_whitespace (str); |
| 647 |
if (*str == 0) |
| 648 |
str = ""; |
| 649 |
break; |
| 650 |
|
| 651 |
case PDP11_OPCODE_IMM3: |
| 652 |
case PDP11_OPCODE_IMM6: |
| 653 |
case PDP11_OPCODE_IMM8: |
| 654 |
str = skip_whitespace (str); |
| 655 |
if (*str == '#' || *str == '$') |
| 656 |
str++; |
| 657 |
str = parse_expression (str, &op1); |
| 658 |
if (op1.error) |
| 659 |
break; |
| 660 |
if (op1.reloc.exp.X_op != O_constant || op1.reloc.type != BFD_RELOC_NONE) |
| 661 |
{ |
| 662 |
op1.error = "operand is not an absolute constant"; |
| 663 |
break; |
| 664 |
} |
| 665 |
switch (op->type) |
| 666 |
{ |
| 667 |
case PDP11_OPCODE_IMM3: |
| 668 |
if (op1.reloc.exp.X_add_number & ~7) |
| 669 |
{ |
| 670 |
op1.error = "3-bit immediate out of range"; |
| 671 |
break; |
| 672 |
} |
| 673 |
break; |
| 674 |
case PDP11_OPCODE_IMM6: |
| 675 |
if (op1.reloc.exp.X_add_number & ~0x3f) |
| 676 |
{ |
| 677 |
op1.error = "6-bit immediate out of range"; |
| 678 |
break; |
| 679 |
} |
| 680 |
break; |
| 681 |
case PDP11_OPCODE_IMM8: |
| 682 |
if (op1.reloc.exp.X_add_number & ~0xff) |
| 683 |
{ |
| 684 |
op1.error = "8-bit immediate out of range"; |
| 685 |
break; |
| 686 |
} |
| 687 |
break; |
| 688 |
} |
| 689 |
insn.code |= op1.reloc.exp.X_add_number; |
| 690 |
break; |
| 691 |
|
| 692 |
case PDP11_OPCODE_DISPL: |
| 693 |
{ |
| 694 |
char *new; |
| 695 |
new = parse_expression (str, &op1); |
| 696 |
op1.code = 0; |
| 697 |
op1.reloc.pc_rel = 1; |
| 698 |
op1.reloc.type = BFD_RELOC_PDP11_DISP_8_PCREL; |
| 699 |
if (op1.reloc.exp.X_op != O_symbol) |
| 700 |
{ |
| 701 |
op1.error = "Symbol expected"; |
| 702 |
break; |
| 703 |
} |
| 704 |
if (op1.code & ~0xff) |
| 705 |
{ |
| 706 |
err = "8-bit displacement out of range"; |
| 707 |
break; |
| 708 |
} |
| 709 |
str = new; |
| 710 |
insn.code |= op1.code; |
| 711 |
insn.reloc = op1.reloc; |
| 712 |
} |
| 713 |
break; |
| 714 |
|
| 715 |
case PDP11_OPCODE_REG: |
| 716 |
str = parse_reg (str, &op1); |
| 717 |
if (op1.error) |
| 718 |
break; |
| 719 |
insn.code |= op1.code; |
| 720 |
break; |
| 721 |
|
| 722 |
case PDP11_OPCODE_OP: |
| 723 |
str = parse_op (str, &op1); |
| 724 |
if (op1.error) |
| 725 |
break; |
| 726 |
insn.code |= op1.code; |
| 727 |
if (op1.additional) |
| 728 |
size += 2; |
| 729 |
break; |
| 730 |
|
| 731 |
case PDP11_OPCODE_FOP: |
| 732 |
str = parse_fop (str, &op1); |
| 733 |
if (op1.error) |
| 734 |
break; |
| 735 |
insn.code |= op1.code; |
| 736 |
if (op1.additional) |
| 737 |
size += 2; |
| 738 |
break; |
| 739 |
|
| 740 |
case PDP11_OPCODE_REG_OP: |
| 741 |
str = parse_reg (str, &op2); |
| 742 |
if (op2.error) |
| 743 |
break; |
| 744 |
insn.code |= op2.code << 6; |
| 745 |
str = parse_separator (str, &error); |
| 746 |
if (error) |
| 747 |
{ |
| 748 |
op2.error = "Missing ','"; |
| 749 |
break; |
| 750 |
} |
| 751 |
str = parse_op (str, &op1); |
| 752 |
if (op1.error) |
| 753 |
break; |
| 754 |
insn.code |= op1.code; |
| 755 |
if (op1.additional) |
| 756 |
size += 2; |
| 757 |
break; |
| 758 |
|
| 759 |
case PDP11_OPCODE_REG_OP_REV: |
| 760 |
str = parse_op (str, &op1); |
| 761 |
if (op1.error) |
| 762 |
break; |
| 763 |
insn.code |= op1.code; |
| 764 |
if (op1.additional) |
| 765 |
size += 2; |
| 766 |
str = parse_separator (str, &error); |
| 767 |
if (error) |
| 768 |
{ |
| 769 |
op2.error = "Missing ','"; |
| 770 |
break; |
| 771 |
} |
| 772 |
str = parse_reg (str, &op2); |
| 773 |
if (op2.error) |
| 774 |
break; |
| 775 |
insn.code |= op2.code << 6; |
| 776 |
break; |
| 777 |
|
| 778 |
case PDP11_OPCODE_AC_FOP: |
| 779 |
str = parse_ac (str, &op2); |
| 780 |
if (op2.error) |
| 781 |
break; |
| 782 |
insn.code |= op2.code << 6; |
| 783 |
str = parse_separator (str, &error); |
| 784 |
if (error) |
| 785 |
{ |
| 786 |
op1.error = "Missing ','"; |
| 787 |
break; |
| 788 |
} |
| 789 |
str = parse_fop (str, &op1); |
| 790 |
if (op1.error) |
| 791 |
break; |
| 792 |
insn.code |= op1.code; |
| 793 |
if (op1.additional) |
| 794 |
size += 2; |
| 795 |
break; |
| 796 |
|
| 797 |
case PDP11_OPCODE_FOP_AC: |
| 798 |
str = parse_fop (str, &op1); |
| 799 |
if (op1.error) |
| 800 |
break; |
| 801 |
insn.code |= op1.code; |
| 802 |
if (op1.additional) |
| 803 |
size += 2; |
| 804 |
str = parse_separator (str, &error); |
| 805 |
if (error) |
| 806 |
{ |
| 807 |
op1.error = "Missing ','"; |
| 808 |
break; |
| 809 |
} |
| 810 |
str = parse_ac (str, &op2); |
| 811 |
if (op2.error) |
| 812 |
break; |
| 813 |
insn.code |= op2.code << 6; |
| 814 |
break; |
| 815 |
|
| 816 |
case PDP11_OPCODE_AC_OP: |
| 817 |
str = parse_ac (str, &op2); |
| 818 |
if (op2.error) |
| 819 |
break; |
| 820 |
insn.code |= op2.code << 6; |
| 821 |
str = parse_separator (str, &error); |
| 822 |
if (error) |
| 823 |
{ |
| 824 |
op1.error = "Missing ','"; |
| 825 |
break; |
| 826 |
} |
| 827 |
str = parse_op (str, &op1); |
| 828 |
if (op1.error) |
| 829 |
break; |
| 830 |
insn.code |= op1.code; |
| 831 |
if (op1.additional) |
| 832 |
size += 2; |
| 833 |
break; |
| 834 |
|
| 835 |
case PDP11_OPCODE_OP_AC: |
| 836 |
str = parse_op (str, &op1); |
| 837 |
if (op1.error) |
| 838 |
break; |
| 839 |
insn.code |= op1.code; |
| 840 |
if (op1.additional) |
| 841 |
size += 2; |
| 842 |
str = parse_separator (str, &error); |
| 843 |
if (error) |
| 844 |
{ |
| 845 |
op1.error = "Missing ','"; |
| 846 |
break; |
| 847 |
} |
| 848 |
str = parse_ac (str, &op2); |
| 849 |
if (op2.error) |
| 850 |
break; |
| 851 |
insn.code |= op2.code << 6; |
| 852 |
break; |
| 853 |
|
| 854 |
case PDP11_OPCODE_OP_OP: |
| 855 |
str = parse_op (str, &op1); |
| 856 |
if (op1.error) |
| 857 |
break; |
| 858 |
insn.code |= op1.code << 6; |
| 859 |
if (op1.additional) |
| 860 |
size += 2; |
| 861 |
str = parse_separator (str, &error); |
| 862 |
if (error) |
| 863 |
{ |
| 864 |
op2.error = "Missing ','"; |
| 865 |
break; |
| 866 |
} |
| 867 |
str = parse_op (str, &op2); |
| 868 |
if (op2.error) |
| 869 |
break; |
| 870 |
insn.code |= op2.code; |
| 871 |
if (op2.additional) |
| 872 |
size += 2; |
| 873 |
break; |
| 874 |
|
| 875 |
case PDP11_OPCODE_REG_DISPL: |
| 876 |
{ |
| 877 |
char *new; |
| 878 |
str = parse_reg (str, &op2); |
| 879 |
if (op2.error) |
| 880 |
break; |
| 881 |
insn.code |= op2.code << 6; |
| 882 |
str = parse_separator (str, &error); |
| 883 |
if (error) |
| 884 |
{ |
| 885 |
op1.error = "Missing ','"; |
| 886 |
break; |
| 887 |
} |
| 888 |
new = parse_expression (str, &op1); |
| 889 |
op1.code = 0; |
| 890 |
op1.reloc.pc_rel = 1; |
| 891 |
op1.reloc.type = BFD_RELOC_PDP11_DISP_6_PCREL; |
| 892 |
if (op1.reloc.exp.X_op != O_symbol) |
| 893 |
{ |
| 894 |
op1.error = "Symbol expected"; |
| 895 |
break; |
| 896 |
} |
| 897 |
if (op1.code & ~0x3f) |
| 898 |
{ |
| 899 |
err = "6-bit displacement out of range"; |
| 900 |
break; |
| 901 |
} |
| 902 |
str = new; |
| 903 |
insn.code |= op1.code; |
| 904 |
insn.reloc = op1.reloc; |
| 905 |
} |
| 906 |
break; |
| 907 |
|
| 908 |
default: |
| 909 |
BAD_CASE (op->type); |
| 910 |
} |
| 911 |
|
| 912 |
if (op1.error) |
| 913 |
err = op1.error; |
| 914 |
else if (op2.error) |
| 915 |
err = op2.error; |
| 916 |
else |
| 917 |
{ |
| 918 |
str = skip_whitespace (str); |
| 919 |
if (*str) |
| 920 |
err = "Too many operands"; |
| 921 |
} |
| 922 |
|
| 923 |
{ |
| 924 |
char *to = NULL; |
| 925 |
|
| 926 |
if (err) |
| 927 |
{ |
| 928 |
as_bad (err); |
| 929 |
return; |
| 930 |
} |
| 931 |
|
| 932 |
to = frag_more (size); |
| 933 |
|
| 934 |
md_number_to_chars (to, insn.code, 2); |
| 935 |
if (insn.reloc.type != BFD_RELOC_NONE) |
| 936 |
fix_new_exp (frag_now, to - frag_now->fr_literal, 2, |
| 937 |
&insn.reloc.exp, insn.reloc.pc_rel, insn.reloc.type); |
| 938 |
to += 2; |
| 939 |
|
| 940 |
if (op1.additional) |
| 941 |
{ |
| 942 |
md_number_to_chars (to, op1.word, 2); |
| 943 |
if (op1.reloc.type != BFD_RELOC_NONE) |
| 944 |
fix_new_exp (frag_now, to - frag_now->fr_literal, 2, |
| 945 |
&op1.reloc.exp, op1.reloc.pc_rel, op1.reloc.type); |
| 946 |
to += 2; |
| 947 |
} |
| 948 |
|
| 949 |
if (op2.additional) |
| 950 |
{ |
| 951 |
md_number_to_chars (to, op2.word, 2); |
| 952 |
if (op2.reloc.type != BFD_RELOC_NONE) |
| 953 |
fix_new_exp (frag_now, to - frag_now->fr_literal, 2, |
| 954 |
&op2.reloc.exp, op2.reloc.pc_rel, op2.reloc.type); |
| 955 |
} |
| 956 |
} |
| 957 |
} |
| 958 |
|
| 959 |
int |
| 960 |
md_estimate_size_before_relax (fragP, segment) |
| 961 |
fragS *fragP ATTRIBUTE_UNUSED; |
| 962 |
segT segment ATTRIBUTE_UNUSED; |
| 963 |
{ |
| 964 |
return 0; |
| 965 |
} |
| 966 |
|
| 967 |
void |
| 968 |
md_convert_frag (headers, seg, fragP) |
| 969 |
bfd *headers ATTRIBUTE_UNUSED; |
| 970 |
segT seg ATTRIBUTE_UNUSED; |
| 971 |
fragS *fragP ATTRIBUTE_UNUSED; |
| 972 |
{ |
| 973 |
} |
| 974 |
|
| 975 |
int md_short_jump_size = 2; |
| 976 |
int md_long_jump_size = 4; |
| 977 |
|
| 978 |
void |
| 979 |
md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) |
| 980 |
char *ptr ATTRIBUTE_UNUSED; |
| 981 |
addressT from_addr ATTRIBUTE_UNUSED; |
| 982 |
addressT to_addr ATTRIBUTE_UNUSED; |
| 983 |
fragS *frag ATTRIBUTE_UNUSED; |
| 984 |
symbolS *to_symbol ATTRIBUTE_UNUSED; |
| 985 |
{ |
| 986 |
} |
| 987 |
|
| 988 |
void |
| 989 |
md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) |
| 990 |
char *ptr ATTRIBUTE_UNUSED; |
| 991 |
addressT from_addr ATTRIBUTE_UNUSED; |
| 992 |
addressT to_addr ATTRIBUTE_UNUSED; |
| 993 |
fragS *frag ATTRIBUTE_UNUSED; |
| 994 |
symbolS *to_symbol ATTRIBUTE_UNUSED; |
| 995 |
{ |
| 996 |
} |
| 997 |
|
| 998 |
static int |
| 999 |
set_option (arg) |
| 1000 |
char *arg; |
| 1001 |
{ |
| 1002 |
int yes = 1; |
| 1003 |
|
| 1004 |
if (strcmp (arg, "all-extensions") == 0 || |
| 1005 |
strcmp (arg, "all") == 0) |
| 1006 |
{ |
| 1007 |
memset (pdp11_extension, ~0, sizeof pdp11_extension); |
| 1008 |
pdp11_extension[PDP11_NONE] = 0; |
| 1009 |
return 1; |
| 1010 |
} |
| 1011 |
else if (strcmp (arg, "no-extensions") == 0) |
| 1012 |
{ |
| 1013 |
memset (pdp11_extension, 0, sizeof pdp11_extension); |
| 1014 |
pdp11_extension[PDP11_BASIC] = 1; |
| 1015 |
return 1; |
| 1016 |
} |
| 1017 |
|
| 1018 |
if (strncmp (arg, "no-", 3) == 0) |
| 1019 |
{ |
| 1020 |
yes = 0; |
| 1021 |
arg += 3; |
| 1022 |
} |
| 1023 |
|
| 1024 |
if (strcmp (arg, "cis") == 0) |
| 1025 |
pdp11_extension[PDP11_CIS] = yes; |
| 1026 |
else if (strcmp (arg, "csm") == 0) |
| 1027 |
pdp11_extension[PDP11_CSM] = yes; |
| 1028 |
else if (strcmp (arg, "eis") == 0) |
| 1029 |
pdp11_extension[PDP11_EIS] = pdp11_extension[PDP11_LEIS] = yes; |
| 1030 |
else if (strcmp (arg, "fis") == 0 || |
| 1031 |
strcmp (arg, "kev11") == 0 || |
| 1032 |
strcmp (arg, "kev-11") == 0) |
| 1033 |
pdp11_extension[PDP11_FIS] = yes; |
| 1034 |
else if (strcmp (arg, "fpp") == 0 || |
| 1035 |
strcmp (arg, "fpu") == 0 || |
| 1036 |
strcmp (arg, "fp11") == 0 || |
| 1037 |
strcmp (arg, "fp-11") == 0 || |
| 1038 |
strcmp (arg, "fpj11") == 0 || |
| 1039 |
strcmp (arg, "fp-j11") == 0 || |
| 1040 |
strcmp (arg, "fpj-11") == 0) |
| 1041 |
pdp11_extension[PDP11_FPP] = yes; |
| 1042 |
else if (strcmp (arg, "limited-eis") == 0) |
| 1043 |
{ |
| 1044 |
pdp11_extension[PDP11_LEIS] = yes; |
| 1045 |
if (!pdp11_extension[PDP11_LEIS]) |
| 1046 |
pdp11_extension[PDP11_EIS] = 0; |
| 1047 |
} |
| 1048 |
else if (strcmp (arg, "mfpt") == 0) |
| 1049 |
pdp11_extension[PDP11_MFPT] = yes; |
| 1050 |
else if (strncmp (arg, "mproc", 5) == 0 || |
| 1051 |
strncmp (arg, "multiproc", 9) == 0 ) |
| 1052 |
pdp11_extension[PDP11_MPROC] = yes; |
| 1053 |
else if (strcmp (arg, "mxps") == 0) |
| 1054 |
pdp11_extension[PDP11_MXPS] = yes; |
| 1055 |
else if (strcmp (arg, "pic") == 0) |
| 1056 |
asm_option[ASM_OPT_PIC] = yes; |
| 1057 |
else if (strcmp (arg, "spl") == 0) |
| 1058 |
pdp11_extension[PDP11_SPL] = yes; |
| 1059 |
else if (strcmp (arg, "ucode") == 0 || |
| 1060 |
strcmp (arg, "microcode") == 0) |
| 1061 |
pdp11_extension[PDP11_UCODE] = yes; |
| 1062 |
else |
| 1063 |
return 0; |
| 1064 |
|
| 1065 |
return 1; |
| 1066 |
} |
| 1067 |
|
| 1068 |
static int |
| 1069 |
set_cpu_model (arg) |
| 1070 |
char *arg; |
| 1071 |
{ |
| 1072 |
char buf[4]; |
| 1073 |
char *model = buf; |
| 1074 |
|
| 1075 |
if (arg[0] == 'k') |
| 1076 |
arg++; |
| 1077 |
|
| 1078 |
*model++ = *arg++; |
| 1079 |
|
| 1080 |
if (strchr ("abdx", model[-1]) == NULL) |
| 1081 |
return 0; |
| 1082 |
|
| 1083 |
if (model[-1] == 'd') |
| 1084 |
{ |
| 1085 |
if (arg[0] == 'f' || |
| 1086 |
arg[0] == 'j') |
| 1087 |
model[-1] = *arg++; |
| 1088 |
} |
| 1089 |
else if (model[-1] == 'x') |
| 1090 |
{ |
| 1091 |
if (arg[0] == 't') |
| 1092 |
model[-1] = *arg++; |
| 1093 |
} |
| 1094 |
|
| 1095 |
if (arg[0] == '-') |
| 1096 |
arg++; |
| 1097 |
|
| 1098 |
if (strncmp (arg, "11", 2) != 0) |
| 1099 |
return 0; |
| 1100 |
arg += 2; |
| 1101 |
|
| 1102 |
if (arg[0] == '-') |
| 1103 |
{ |
| 1104 |
if (*++arg == 0) |
| 1105 |
return 0; |
| 1106 |
} |
| 1107 |
|
| 1108 |
|
| 1109 |
if (arg[0] != 0) |
| 1110 |
*model++ = *arg++; |
| 1111 |
if (arg[0] != 0) |
| 1112 |
*model++ = *arg++; |
| 1113 |
|
| 1114 |
*model++ = 0; |
| 1115 |
|
| 1116 |
set_option ("no-extensions"); |
| 1117 |
|
| 1118 |
if (strncmp (buf, "a", 1) == 0) |
| 1119 |
return 1; |
| 1120 |
|
| 1121 |
else if (strncmp (buf, "b", 1) == 0) |
| 1122 |
return set_option ("eis") && |
| 1123 |
set_option ("spl"); |
| 1124 |
|
| 1125 |
else if (strncmp (buf, "da", 2) == 0) |
| 1126 |
return set_option ("limited-eis"); |
| 1127 |
|
| 1128 |
else if (strncmp (buf, "db", 2) == 0 || |
| 1129 |
strncmp (buf, "dd", 2) == 0) |
| 1130 |
return 1; |
| 1131 |
|
| 1132 |
else if (strncmp (buf, "de", 2) == 0) |
| 1133 |
return set_option ("eis") && |
| 1134 |
set_option ("mxps"); |
| 1135 |
|
| 1136 |
else if (strncmp (buf, "df", 2) == 0 || |
| 1137 |
strncmp (buf, "dh", 2) == 0 || |
| 1138 |
strncmp (buf, "dq", 2) == 0) |
| 1139 |
return set_option ("limited-eis") && |
| 1140 |
set_option ("mxps"); |
| 1141 |
|
| 1142 |
else if (strncmp (buf, "dk", 2) == 0) |
| 1143 |
return set_option ("eis") && |
| 1144 |
set_option ("mxps") && |
| 1145 |
set_option ("ucode"); |
| 1146 |
|
| 1147 |
else if (strncmp (buf, "dz", 2) == 0) |
| 1148 |
return set_option ("csm") && |
| 1149 |
set_option ("eis") && |
| 1150 |
set_option ("mfpt") && |
| 1151 |
set_option ("mxps") && |
| 1152 |
set_option ("spl"); |
| 1153 |
|
| 1154 |
else if (strncmp (buf, "f", 1) == 0) |
| 1155 |
return set_option ("eis") && |
| 1156 |
set_option ("mfpt") && |
| 1157 |
set_option ("mxps"); |
| 1158 |
|
| 1159 |
else if (strncmp (buf, "j", 1) == 0) |
| 1160 |
return set_option ("csm") && |
| 1161 |
set_option ("eis") && |
| 1162 |
set_option ("mfpt") && |
| 1163 |
set_option ("multiproc") && |
| 1164 |
set_option ("mxps") && |
| 1165 |
set_option ("spl"); |
| 1166 |
|
| 1167 |
else if (strncmp (buf, "t", 1) == 0) |
| 1168 |
return set_option ("limited-eis") && |
| 1169 |
set_option ("mxps"); |
| 1170 |
|
| 1171 |
else |
| 1172 |
return 0; |
| 1173 |
} |
| 1174 |
|
| 1175 |
static int |
| 1176 |
set_machine_model (arg) |
| 1177 |
char *arg; |
| 1178 |
{ |
| 1179 |
if (strncmp (arg, "pdp-11/", 7) != 0 && |
| 1180 |
strncmp (arg, "pdp11/", 6) != 0 && |
| 1181 |
strncmp (arg, "11/", 3) != 0) |
| 1182 |
return 0; |
| 1183 |
|
| 1184 |
if (strncmp (arg, "pdp", 3) == 0) |
| 1185 |
arg += 3; |
| 1186 |
if (arg[0] == '-') |
| 1187 |
arg++; |
| 1188 |
if (strncmp (arg, "11/", 3) == 0) |
| 1189 |
arg += 3; |
| 1190 |
|
| 1191 |
if (strcmp (arg, "03") == 0) |
| 1192 |
return set_cpu_model ("kd11f"); |
| 1193 |
|
| 1194 |
else if (strcmp (arg, "04") == 0) |
| 1195 |
return set_cpu_model ("kd11d"); |
| 1196 |
|
| 1197 |
else if (strcmp (arg, "05") == 0 || |
| 1198 |
strcmp (arg, "10") == 0) |
| 1199 |
return set_cpu_model ("kd11b"); |
| 1200 |
|
| 1201 |
else if (strcmp (arg, "15") == 0 || |
| 1202 |
strcmp (arg, "20") == 0) |
| 1203 |
return set_cpu_model ("ka11"); |
| 1204 |
|
| 1205 |
else if (strcmp (arg, "21") == 0) |
| 1206 |
return set_cpu_model ("t11"); |
| 1207 |
|
| 1208 |
else if (strcmp (arg, "23") == 0 || |
| 1209 |
strcmp (arg, "24") == 0) |
| 1210 |
return set_cpu_model ("f11"); |
| 1211 |
|
| 1212 |
else if (strcmp (arg, "34") == 0 || |
| 1213 |
strcmp (arg, "34a") == 0) |
| 1214 |
return set_cpu_model ("kd11e"); |
| 1215 |
|
| 1216 |
else if (strcmp (arg, "35") == 0 || |
| 1217 |
strcmp (arg, "40") == 0) |
| 1218 |
return set_cpu_model ("kd11da"); |
| 1219 |
|
| 1220 |
else if (strcmp (arg, "44") == 0) |
| 1221 |
return set_cpu_model ("kd11dz"); |
| 1222 |
|
| 1223 |
else if (strcmp (arg, "45") == 0 || |
| 1224 |
strcmp (arg, "50") == 0 || |
| 1225 |
strcmp (arg, "55") == 0 || |
| 1226 |
strcmp (arg, "70") == 0) |
| 1227 |
return set_cpu_model ("kb11"); |
| 1228 |
|
| 1229 |
else if (strcmp (arg, "60") == 0) |
| 1230 |
return set_cpu_model ("kd11k"); |
| 1231 |
|
| 1232 |
else if (strcmp (arg, "53") == 0 || |
| 1233 |
strcmp (arg, "73") == 0 || |
| 1234 |
strcmp (arg, "83") == 0 || |
| 1235 |
strcmp (arg, "84") == 0 || |
| 1236 |
strcmp (arg, "93") == 0 || |
| 1237 |
strcmp (arg, "94") == 0) |
| 1238 |
return set_cpu_model ("j11") && |
| 1239 |
set_option ("fpp"); |
| 1240 |
|
| 1241 |
else |
| 1242 |
return 0; |
| 1243 |
} |
| 1244 |
|
| 1245 |
const char *md_shortopts = "m:"; |
| 1246 |
|
| 1247 |
struct option md_longopts[] = |
| 1248 |
{ |
| 1249 |
#define OPTION_CPU 257 |
| 1250 |
{ "cpu", required_argument, NULL, OPTION_CPU }, |
| 1251 |
#define OPTION_MACHINE 258 |
| 1252 |
{ "machine", required_argument, NULL, OPTION_MACHINE }, |
| 1253 |
#define OPTION_PIC 259 |
| 1254 |
{ "pic", no_argument, NULL, OPTION_PIC }, |
| 1255 |
{ NULL, no_argument, NULL, 0 } |
| 1256 |
}; |
| 1257 |
|
| 1258 |
size_t md_longopts_size = sizeof (md_longopts); |
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
int |
| 1267 |
md_parse_option (c, arg) |
| 1268 |
int c; |
| 1269 |
char *arg; |
| 1270 |
{ |
| 1271 |
init_defaults (); |
| 1272 |
|
| 1273 |
switch (c) |
| 1274 |
{ |
| 1275 |
case 'm': |
| 1276 |
if (set_option (arg)) |
| 1277 |
return 1; |
| 1278 |
if (set_cpu_model (arg)) |
| 1279 |
return 1; |
| 1280 |
if (set_machine_model (arg)) |
| 1281 |
return 1; |
| 1282 |
break; |
| 1283 |
|
| 1284 |
case OPTION_CPU: |
| 1285 |
if (set_cpu_model (arg)) |
| 1286 |
return 1; |
| 1287 |
break; |
| 1288 |
|
| 1289 |
case OPTION_MACHINE: |
| 1290 |
if (set_machine_model (arg)) |
| 1291 |
return 1; |
| 1292 |
break; |
| 1293 |
|
| 1294 |
case OPTION_PIC: |
| 1295 |
if (set_option ("pic")) |
| 1296 |
return 1; |
| 1297 |
break; |
| 1298 |
|
| 1299 |
default: |
| 1300 |
break; |
| 1301 |
} |
| 1302 |
|
| 1303 |
return 0; |
| 1304 |
} |
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
|
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
void |
| 1547 |
md_show_usage (stream) |
| 1548 |
FILE *stream; |
| 1549 |
{ |
| 1550 |
fprintf (stream, "\ |
| 1551 |
\n\ |
| 1552 |
PDP-11 instruction set extentions:\n\ |
| 1553 |
\n\ |
| 1554 |
-m(no-)cis allow (disallow) commersial instruction set\n\ |
| 1555 |
-m(no-)csm allow (disallow) CSM instruction\n\ |
| 1556 |
-m(no-)eis allow (disallow) full extended instruction set\n\ |
| 1557 |
-m(no-)fis allow (disallow) KEV11 floating-point instructions\n\ |
| 1558 |
-m(no-)fpp allow (disallow) FP-11 floating-point instructions\n\ |
| 1559 |
-m(no-)fpu allow (disallow) FP-11 floating-point instructions\n\ |
| 1560 |
-m(no-)limited-eis allow (disallow) limited extended instruction set\n\ |
| 1561 |
-m(no-)mfpt allow (disallow) processor type instruction\n\ |
| 1562 |
-m(no-)multiproc allow (disallow) multiprocessor instructions\n\ |
| 1563 |
-m(no-)mxps allow (disallow) processor status instructions\n\ |
| 1564 |
-m(no-)spl allow (disallow) SPL instruction\n\ |
| 1565 |
-m(no-)ucode allow (disallow) microcode instructions\n\ |
| 1566 |
-mall-extensions allow all instruction set extensions\n\ |
| 1567 |
(this is the default)\n\ |
| 1568 |
-mno-extentions disallow all instruction set extensions\n\ |
| 1569 |
-pic generate position-indepenent code\n\ |
| 1570 |
\n\ |
| 1571 |
PDP-11 CPU model options:\n\ |
| 1572 |
\n\ |
| 1573 |
-mka11* KA11 CPU. base line instruction set only\n\ |
| 1574 |
-mkb11* KB11 CPU. enable full EIS and SPL\n\ |
| 1575 |
-mkd11a* KD11-A CPU. enable limited EIS\n\ |
| 1576 |
-mkd11b* KD11-B CPU. base line instruction set only\n\ |
| 1577 |
-mkd11d* KD11-D CPU. base line instruction set only\n\ |
| 1578 |
-mkd11e* KD11-E CPU. enable full EIS, MTPS, and MFPS\n\ |
| 1579 |
-mkd11f* KD11-F CPU. enable limited EIS, MTPS, and MFPS\n\ |
| 1580 |
-mkd11h* KD11-H CPU. enable limited EIS, MTPS, and MFPS\n\ |
| 1581 |
-mkd11q* KD11-Q CPU. enable limited EIS, MTPS, and MFPS\n\ |
| 1582 |
-mkd11k* KD11-K CPU. enable full EIS, MTPS, MFPS, LDUB, MED,\n\ |
| 1583 |
XFC, and MFPT\n\ |
| 1584 |
-mkd11z* KD11-Z CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\ |
| 1585 |
and CSM\n\ |
| 1586 |
-mf11* F11 CPU. enable full EIS, MFPS, MTPS, and MFPT\n\ |
| 1587 |
-mj11* J11 CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\ |
| 1588 |
CSM, TSTSET, and WRTLCK\n\ |
| 1589 |
-mt11* T11 CPU. enable limited EIS, MTPS, and MFPS\n\ |
| 1590 |
\n\ |
| 1591 |
PDP-11 machine model options:\n\ |
| 1592 |
\n\ |
| 1593 |
-m11/03 same as -mkd11f\n\ |
| 1594 |
-m11/04 same as -mkd11d\n\ |
| 1595 |
-m11/05 same as -mkd11b\n\ |
| 1596 |
-m11/10 same as -mkd11b\n\ |
| 1597 |
-m11/15 same as -mka11\n\ |
| 1598 |
-m11/20 same as -mka11\n\ |
| 1599 |
-m11/21 same as -mt11\n\ |
| 1600 |
-m11/23 same as -mf11\n\ |
| 1601 |
-m11/24 same as -mf11\n\ |
| 1602 |
-m11/34 same as -mkd11e\n\ |
| 1603 |
-m11/34a same as -mkd11e -mfpp\n\ |
| 1604 |
-m11/35 same as -mkd11a\n\ |
| 1605 |
-m11/40 same as -mkd11a\n\ |
| 1606 |
-m11/44 same as -mkd11z\n\ |
| 1607 |
-m11/45 same as -mkb11\n\ |
| 1608 |
-m11/50 same as -mkb11\n\ |
| 1609 |
-m11/53 same as -mj11\n\ |
| 1610 |
-m11/55 same as -mkb11\n\ |
| 1611 |
-m11/60 same as -mkd11k\n\ |
| 1612 |
-m11/70 same as -mkb11\n\ |
| 1613 |
-m11/73 same as -mj11\n\ |
| 1614 |
-m11/83 same as -mj11\n\ |
| 1615 |
-m11/84 same as -mj11\n\ |
| 1616 |
-m11/93 same as -mj11\n\ |
| 1617 |
-m11/94 same as -mj11\n\ |
| 1618 |
"); |
| 1619 |
} |
| 1620 |
|
| 1621 |
symbolS * |
| 1622 |
md_undefined_symbol (name) |
| 1623 |
char *name ATTRIBUTE_UNUSED; |
| 1624 |
{ |
| 1625 |
return 0; |
| 1626 |
} |
| 1627 |
|
| 1628 |
valueT |
| 1629 |
md_section_align (segment, size) |
| 1630 |
segT segment ATTRIBUTE_UNUSED; |
| 1631 |
valueT size; |
| 1632 |
{ |
| 1633 |
return (size + 1) & ~1; |
| 1634 |
} |
| 1635 |
|
| 1636 |
long |
| 1637 |
md_pcrel_from (fixP) |
| 1638 |
fixS *fixP; |
| 1639 |
{ |
| 1640 |
return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size; |
| 1641 |
} |
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
arelent * |
| 1646 |
tc_gen_reloc (section, fixp) |
| 1647 |
asection *section ATTRIBUTE_UNUSED; |
| 1648 |
fixS *fixp; |
| 1649 |
{ |
| 1650 |
arelent *reloc; |
| 1651 |
bfd_reloc_code_real_type code; |
| 1652 |
|
| 1653 |
reloc = (arelent *) xmalloc (sizeof (arelent)); |
| 1654 |
|
| 1655 |
reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
| 1656 |
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); |
| 1657 |
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; |
| 1658 |
|
| 1659 |
|
| 1660 |
reloc->addend = -symbol_get_bfdsym (fixp->fx_addsy)->section->vma; |
| 1661 |
|
| 1662 |
switch (fixp->fx_r_type) |
| 1663 |
{ |
| 1664 |
case BFD_RELOC_16: |
| 1665 |
if (fixp->fx_pcrel) |
| 1666 |
code = BFD_RELOC_16_PCREL; |
| 1667 |
else |
| 1668 |
code = BFD_RELOC_16; |
| 1669 |
break; |
| 1670 |
|
| 1671 |
case BFD_RELOC_16_PCREL: |
| 1672 |
code = BFD_RELOC_16_PCREL; |
| 1673 |
break; |
| 1674 |
|
| 1675 |
default: |
| 1676 |
BAD_CASE (fixp->fx_r_type); |
| 1677 |
return NULL; |
| 1678 |
} |
| 1679 |
|
| 1680 |
reloc->howto = bfd_reloc_type_lookup (stdoutput, code); |
| 1681 |
|
| 1682 |
if (reloc->howto == NULL) |
| 1683 |
{ |
| 1684 |
as_bad_where (fixp->fx_file, fixp->fx_line, |
| 1685 |
"Can not represent %s relocation in this object file format", |
| 1686 |
bfd_get_reloc_code_name (code)); |
| 1687 |
return NULL; |
| 1688 |
} |
| 1689 |
|
| 1690 |
return reloc; |
| 1691 |
} |
| 1692 |
|
| 1693 |
void |
| 1694 |
pseudo_bss (c) |
| 1695 |
int c ATTRIBUTE_UNUSED; |
| 1696 |
{ |
| 1697 |
int temp; |
| 1698 |
|
| 1699 |
temp = get_absolute_expression (); |
| 1700 |
subseg_set (bss_section, temp); |
| 1701 |
demand_empty_rest_of_line (); |
| 1702 |
} |
| 1703 |
|
| 1704 |
void |
| 1705 |
pseudo_even (c) |
| 1706 |
int c ATTRIBUTE_UNUSED; |
| 1707 |
{ |
| 1708 |
int alignment = 1; |
| 1709 |
frag_align (alignment, 0, 1); |
| 1710 |
record_alignment (now_seg, alignment); |
| 1711 |
} |
| 1712 |
|
| 1713 |
|