mach5.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * Zilog Z80 special routines
  8. */
  9. xyreg(r,byte) {
  10. if (r==IX)
  11. emit1(0335);
  12. else if (r==IY)
  13. emit1(0375);
  14. else if (r!=HL)
  15. serror("register error");
  16. emit1(byte);
  17. }
  18. xymem(r,byte) {
  19. xyreg(r,byte);
  20. if (r != HL) {
  21. #ifdef RELOCATION
  22. RELOMOVE(relonami, rel_ind);
  23. newrelo(exp_ind.typ, RELO1);
  24. #endif
  25. emit1(exp_ind.val);
  26. }
  27. }
  28. branch(opc,exp) register opc; expr_t exp; {
  29. register sm,dist;
  30. dist = exp.val - (DOTVAL + 2);
  31. if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
  32. dist -= DOTGAIN;
  33. sm = fitb(dist);
  34. if ((exp.typ & ~S_DOT) != DOTTYP)
  35. sm = 0;
  36. if (opc == 020) { /* DJNZ must be short */
  37. fit(sm);
  38. sm = 1;
  39. } else if ((sm = small(sm,1)) == 0) {
  40. if (opc == 030) /* 'JR exp' */
  41. opc = 0303; /* replace by 'JP exp' */
  42. else /* 'JR CC,exp' */
  43. opc ^= 0342; /* replace by 'JP CC,exp' */
  44. }
  45. emit1(opc);
  46. if (sm == 0) {
  47. #ifdef RELOCATION
  48. newrelo(exp.typ, RELO2);
  49. #endif
  50. emit2(exp.val);
  51. } else {
  52. emit1(lowb(dist));
  53. }
  54. }