mach5.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 6805 special routines
  8. */
  9. /* VARARGS2 */
  10. branch(opc,exp,cell) register opc; expr_t cell; expr_t exp; {
  11. register sm, dist;
  12. int saving;
  13. dist = exp.val - (DOTVAL + 2);
  14. if((opc & 0xf0) == 0) dist -= 1; /* bitbranch */
  15. if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
  16. dist -= DOTGAIN;
  17. sm = fitj(dist);
  18. if ((exp.typ & ~S_DOT) != DOTTYP)
  19. sm = 0;
  20. if (opc == 0x20 || opc == 0xAD)
  21. saving = 1;
  22. else
  23. saving = 3;
  24. if (small(sm,saving)) {
  25. emit1(opc);
  26. if((opc & 0xF0) == 0) /* bit branch */
  27. emit1(cell.val);
  28. #ifdef RELOCATION
  29. newrelo(exp.typ, RELPC|RELO1);
  30. #endif
  31. emit1(dist);
  32. } else {
  33. if (opc == 0xAD) /* bsr */
  34. emit1(0xBD); /* jsr */
  35. else {
  36. if (opc != 0x20) { /* bra */
  37. /* reverse condition : */
  38. emit1(opc ^ 1);
  39. if((opc & 0xF0) == 0) /* bitbranch */
  40. emit1(cell.val);
  41. emit1(3);
  42. }
  43. emit1(0xCC); /* jmp */
  44. }
  45. #ifdef RELOCATION
  46. newrelo(exp.typ, RELPC|RELO2|RELBR);
  47. #endif
  48. emit2(exp.val);
  49. }
  50. }