home *** CD-ROM | disk | FTP | other *** search
- /* The following function displays the numeric and
- * environment registers of the NDP in use. If the
- * program is running on a system with both an 80x87
- * and an mW1167 coprocessor, the function will choose
- * the correct action depending on the compiler options
- * used. In case of an error, the function returns FALSE,
- * otherwise it returns TRUE.
- */
-
- int display_ndp()
-
- {
- unsigned i, j, k;
- unsigned tos_reg; /* Top of Stack Register */
- unsigned new_tw; /* Rearranged Tag Word */
- unsigned char *regptr;
-
- #if NDP387==1 || NDP287==1
- printf("\nControl word:\t\t %04x\n", buff.cw);
- printf("Status word:\t\t %04x\n", buff.sw);
- printf("Tag word:\t\t %04x\n", buff.tag);
- printf("IP offset:\t\t%08x\n", buff.ip_off);
- printf("CS selector:\t\t %04x\n", buff.cs_sel);
- printf("Data operand offset:\t%08x\n", buff.data_off);
- printf("Operand selector:\t %04x\n\n",
- buff.oper_sel);
-
- /* Which numeric register is Top of Stack ? */
- tos_reg = (buff.sw >> 11) & 7;
- /* The following if-else block rearranges the bit pattern
- * of the Tag Word, if necessary, to correctly associate bit
- * pairs representing physical numeric registers 0-7 with
- * relative stack registers ST(0)-ST(7).
- */
- if (tos_reg) {
- new_tw = buff.tag >> (tos_reg * 2);
- i = buff.tag << (16 - (tos_reg * 2));
- new_tw |= i;
- }
- else {
- new_tw = buff.tag;
- }
-
- printf("Registers:\n");
- regptr = &buff.st0[0];
- for (i = 0; i < 8; i++) {
- printf("ST%1d = ", i);
- for (j = 0; j < 10; j++)
- printf("%02x", *(regptr+9-j));
- k = (new_tw >> (2*i)) & 3;
- switch (k) {
- case 0: /* Valid number */
- case 1: /* Zero */
- printf("\t%20.14e\n", temp_dbl(regptr));
- break;
- case 2: printf ("\tInfinity,NAN,or denormal\n");
- break;
- case 3: printf ("\tEmpty register\n");
- break;
- }
- regptr += 10;
- }
- #endif
-
- #if NDP1167==1
- printf("\nControl word:\t\t %04x\n", buff.cw);
- printf("Status word:\t\t %04x\n", buff.sw);
- for (i = 0; i < 16; i++) {
- printf("%08x %08x %10e\t%10e\t%16e\n",
- buff.u.regs[2*i], buff.u.regs[2*i+1],
- buff.u.f_regs[2*i], buff.u.f_regs[2*i+1],
- buff.u.d_regs[i]);
- }
- #endif
- printf ("\n");
- return (TRUE);
- }
-