mach.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #define CODE_EXPANDER
  2. #include "mach.h"
  3. #include <back.h>
  4. #include <system.h>
  5. #ifdef DEBUG
  6. arg_error( s, arg)
  7. char *s;
  8. int arg;
  9. {
  10. fprint( STDERR, "arg_error %s %d\n", s, arg);
  11. }
  12. #endif
  13. /*
  14. do_open( filename)
  15. char *filename;
  16. {
  17. if ( filename == (char *)0 || !sys_open( filename, OP_WRITE, &codefile))
  18. return( 0);
  19. fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n");
  20. return( 1);
  21. }
  22. */
  23. #include <con_float>
  24. __instr_code(code, reg, off)
  25. {
  26. if (off <= 32767 & off >= -32768) {
  27. text2(code|0x28|reg);
  28. text2(off);
  29. return;
  30. }
  31. text2(code|0x30|reg);
  32. text2(0x0170);
  33. text4(off);
  34. }
  35. __move_X(code, reg, off)
  36. {
  37. if (off <= 32767 & off >= -32768) {
  38. text2(code|(reg<<9)|0x140);
  39. text2(off);
  40. return;
  41. }
  42. text2(code|(reg<<9)|0x180);
  43. text2(0x0170);
  44. text4(off);
  45. }
  46. __moveXX(code, srcreg, srcoff, dstreg, dstoff)
  47. {
  48. if (srcoff <= 32767 && srcoff >= -32768) {
  49. __move_X(code|0x28|srcreg, dstreg, dstoff);
  50. return;
  51. }
  52. if (dstoff <= 32767 && dstoff >= -32768) {
  53. __instr_code(code|0x140|(dstreg<<9), srcreg, srcoff);
  54. return;
  55. }
  56. text2(code|(dstreg<<9)|srcreg|0x180|0x30);
  57. text2(0x0170);
  58. text4(srcoff);
  59. text2(0x0170);
  60. text4(dstoff);
  61. }