home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
pd3.lzh
/
SBPROLOG2.2
/
SIM
/
dis.c
< prev
next >
Wrap
Text File
|
1991-08-10
|
3KB
|
87 lines
/************************************************************************
* *
* The SB-Prolog System *
* Copyright SUNY at Stony Brook, 1986 *
* *
************************************************************************/
/*-----------------------------------------------------------------
SB-Prolog is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY. No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing. Refer to the SB-Prolog General Public
License for full details.
Everyone is granted permission to copy, modify and redistribute
SB-Prolog, but only under the conditions described in the
SB-Prolog General Public License. A copy of this license is
supposed to have been given to you along with SB-Prolog so you
can know your rights and responsibilities. It should be in a
file named COPYING. Among other things, the copyright notice
and this notice must be preserved on all copies.
------------------------------------------------------------------ */
/* dis.c */
#include "sim.h"
#include "inst.h"
#include "aux.h"
#define parse_operands(opcode) (*p_routine[parse_table[opcode]])()
static FILE *filedes ;
dis( )
{
filedes = fopen("dump.pil","w");
dis_data();
dis_text();
fflush(filedes);
fclose(filedes);
}
dis_data()
{
struct psc_rec *temp;
pw chain_ptr;
int i;
fprintf(filedes, "\n/* data below: name, arity, type, and entry *\/\n\n");
for ( i = 0; i < bucket_chain; ++i ) {
chain_ptr = (pw)&hash_table[i][PERM];
while (!isfree(chain_ptr)) {
chain_ptr = (pw)follow(chain_ptr);
temp = (struct psc_rec *)follow(chain_ptr);
fprintf(filedes, "%x: ", temp);
writepname(filedes, get_name(temp), get_length(temp));
fprintf(filedes, "/%d,\t", get_arity(temp));
switch(get_etype(temp)) {
case T_PRED: fprintf(filedes, "PRED"); break;
case T_BUFF: fprintf(filedes, "BUFF"); break;
case T_DYNA: fprintf(filedes, "DYNA"); break;
case T_ORDI: fprintf(filedes, "ORDI"); break;
}
fprintf(filedes, ", %x\n", get_ep(temp));
chain_ptr++;
}
}
fprintf(filedes, "\n");
}
dis_text()
{
int current_opcode;
fprintf(filedes, "\n/*text below\t\t*\/\n\n");
pcreg = inst_begin;
do {
fprintf(filedes, "\nNew segment below \n\n");
while ( *(pcreg) != endfile ) {
print_inst(filedes, pcreg);
}
pcreg += 2;
} while (pcreg = *(pb *)(pcreg)); /* repeat for all text segment */
}