disfp.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. static char *sccsid =
  2. "@(#) disfp.c, Ver. 2.1 created 00:00:00 87/09/01";
  3. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4. * *
  5. * Copyright (C) 1987 G. M. Harding, all rights reserved *
  6. * *
  7. * Permission to copy and redistribute is hereby granted, *
  8. * provided full source code, with all copyright notices, *
  9. * accompanies any redistribution. *
  10. * *
  11. * This file contains handler routines for the numeric op- *
  12. * codes of the 8087 co-processor, as well as a few other *
  13. * opcodes which are related to 8087 emulation. *
  14. * *
  15. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  16. #include "dis.h" /* Disassembler declarations */
  17. #define FPINT0 0xd8 /* Floating-point interrupts */
  18. #define FPINT1 0xd9
  19. #define FPINT2 0xda
  20. #define FPINT3 0xdb
  21. #define FPINT4 0xdc
  22. #define FPINT5 0xdd
  23. #define FPINT6 0xde
  24. #define FPINT7 0xdf
  25. /* Test for floating opcodes */
  26. #define ISFLOP(x) \
  27. (((x) >= FPINT0) && ((x) <= FPINT7))
  28. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  29. * *
  30. * This is the handler for the escape family of opcodes. *
  31. * These opcodes place the contents of a specified memory *
  32. * location on the system bus, for access by a peripheral *
  33. * or by a co-processor such as the 8087. (The 8087 NDP is *
  34. * accessed only via bus escapes.) Due to a bug in the *
  35. * PC/IX assembler, the "esc" mnemonic is not recognized; *
  36. * consequently, escape opcodes are disassembled as .byte *
  37. * directives, with the appropriate mnemonic and operand *
  38. * included as a comment. FOR NOW, those escape sequences *
  39. * corresponding to 8087 opcodes are treated as simple *
  40. * escapes. *
  41. * *
  42. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  43. void
  44. eshand(j)
  45. register int j; /* Pointer to optab[] entry */
  46. {/* * * * * * * * * * START OF eshand() * * * * * * * * * */
  47. register char *a;
  48. register int k;
  49. objini(j);
  50. FETCH(k);
  51. a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
  52. mtrunc(a);
  53. printf("\t.byte\t0x%02.2x\t\t| esc\t%s\n",j,a);
  54. for (k = 1; k < objptr; ++k)
  55. printf("\t.byte\t0x%02.2x\n",objbuf[k]);
  56. }/* * * * * * * * * * * END OF eshand() * * * * * * * * * * */
  57. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  58. * *
  59. * This is the handler routine for floating-point opcodes. *
  60. * Since PC/IX must accommodate systems with and without *
  61. * 8087 co-processors, it allows floating-point operations *
  62. * to be initiated in either of two ways: by a software *
  63. * interrput whose type is in the range 0xd8 through 0xdf, *
  64. * or by a CPU escape sequence, which is invoked by an op- *
  65. * code in the same range. In either case, the subsequent *
  66. * byte determines the actual numeric operation to be per- *
  67. * formed. However, depending on the method of access, *
  68. * either one or two code bytes will precede that byte, *
  69. * and the fphand() routine has no way of knowing whether *
  70. * it was invoked by interrupt or by an escape sequence. *
  71. * Therefore, unlike all of the other handler routines ex- *
  72. * cept dfhand(), fphand() does not initialize the object *
  73. * buffer, leaving that chore to the caller. *
  74. * *
  75. * FOR NOW, fphand() does not disassemble floating-point *
  76. * opcodes to floating mnemonics, but simply outputs the *
  77. * object code as .byte directives. *
  78. * *
  79. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  80. void
  81. fphand(j)
  82. register int j; /* Pointer to optab[] entry */
  83. {/* * * * * * * * * * START OF fphand() * * * * * * * * * */
  84. register int k;
  85. segflg = 0;
  86. FETCH(k);
  87. printf("\t.byte\t0x%02.2x\t\t| 8087 code sequence\n",
  88. objbuf[0]);
  89. for (k = 1; k < objptr; ++k)
  90. printf("\t.byte\t0x%02.2x\n",objbuf[k]);
  91. /* objout(); FOR NOW */
  92. }/* * * * * * * * * * * END OF fphand() * * * * * * * * * * */
  93. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  94. * *
  95. * This is the handler for variable software interrupt *
  96. * opcodes. It is included in this file because PC/IX im- *
  97. * plements its software floating-point emulation by means *
  98. * of interrupts. Any interrupt in the range 0xd8 through *
  99. * 0xdf is an NDP-emulation interrupt, and is specially *
  100. * handled by the assembler. *
  101. * *
  102. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  103. void
  104. inhand(j)
  105. register int j; /* Pointer to optab[] entry */
  106. {/* * * * * * * * * * START OF inhand() * * * * * * * * * */
  107. register int k;
  108. objini(j);
  109. FETCH(k);
  110. if (ISFLOP(k))
  111. {
  112. fphand(k);
  113. return;
  114. }
  115. printf("%s\t$%02x\n",optab[j].text,k);
  116. objout();
  117. }/* * * * * * * * * * * END OF inhand() * * * * * * * * * * */