mach5.c 932 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * Mostek 6500 special routines.
  8. */
  9. branch(opc, exp)
  10. register int opc;
  11. expr_t exp;
  12. {
  13. register int dist;
  14. dist = exp.val - (DOTVAL + 2);
  15. if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
  16. dist -= DOTGAIN;
  17. if (small(fitb(dist) && (exp.typ & ~S_DOT) == DOTTYP, 3)) {
  18. emit1(opc); emit1(dist);
  19. } else {
  20. emit1(opc^0x20); emit1(0x03); /* Skip over ... */
  21. emit1(0x4C); /* ... far jump. */
  22. #ifdef RELOCATION
  23. newrelo(exp.typ, RELO2);
  24. #endif
  25. emit2(exp.val);
  26. }
  27. }
  28. code(exp, opc1, opc2)
  29. expr_t exp;
  30. register int opc1, opc2;
  31. {
  32. if (small((exp.typ & S_TYP) == S_ABS && fits_zeropage(exp.val), 1)) {
  33. emit1(opc1); emit1(exp.val);
  34. } else {
  35. emit1(opc2);
  36. #ifdef RELOCATION
  37. newrelo(exp.typ, RELO2);
  38. #endif
  39. emit2(exp.val);
  40. }
  41. }