mach5.c 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. #define RCSID5 "$Id$"
  6. /*
  7. * Motorola 6800 special routines
  8. */
  9. branch(opc,exp) register opc; expr_t exp; {
  10. register sm, dist;
  11. int saving;
  12. dist = exp.val - (DOTVAL + 2);
  13. if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
  14. dist -= DOTGAIN;
  15. sm = fitb(dist);
  16. if ((exp.typ & ~S_DOT) != DOTTYP)
  17. sm = 0;
  18. if (opc == 0x8D || opc == 0x20)
  19. saving = 1;
  20. else
  21. saving = 3;
  22. if (small(sm,saving)) {
  23. emit1(opc);
  24. emit1(dist);
  25. } else {
  26. if (opc == 0x8D) /* bsr */
  27. emit1(0xBD); /* jsr */
  28. else {
  29. if (opc != 0x20) { /* bra */
  30. /* reverse condition : */
  31. emit1(opc ^ 1);
  32. emit1(3);
  33. }
  34. emit1(0x7E); /* jmp */
  35. }
  36. #ifdef RELOCATION
  37. newrelo(exp.typ, RELO2 | RELBR);
  38. #endif
  39. emit2(exp.val);
  40. }
  41. }