Commit 2b79e896 authored by Martin Ruckert's avatar Martin Ruckert
Browse files

metting the vmb version to work.

parent 92a115a0
......@@ -60,6 +60,10 @@ mmix-sim: libmmix.a mmix-sim.c
mmixal: libmmix.a mmixal.c
$(CC) $(CFLAGS) mmixal.c -L. -lmmix -o mmixal
.PHONY: TAGS
TAGS:
etags *.c *.h *.ch
clean:
rm -f *.o
rm -f $(LIBSIM) $(LIBH) $(LIBAL) mmix-arith.c mmix-io.c
......
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
#include "libconfig.h"
#include "libtype.h"
#include "libglobals.h"
......@@ -41,6 +42,5 @@ void free_file_info(void)
{ free(file_info[i].map);
file_info[i].map=NULL;
}
ybyte2file_no[i]=-1;
}
}
......@@ -5,23 +5,26 @@
#pragma warning(disable : 4996)
#endif
#define store_octa(val,addr) (ll=mem_find(addr),ll->tet=(val).h,(ll+1)->tet=(val).l,true)
#define store_tetra(val,addr) (ll=mem_find(addr),ll->tet=(val).l,true)
#define store_wyde(val,addr) (ll=mem_find(addr),ll->tet=(ll->tet&(~(0xFFFF<<((1-((addr).l&0x1))<<4))))|(((val).l&0xFFFF)<<((1-((addr).l&0x1))<<4)),true)
#define store_byte(val,addr) (ll=mem_find(addr),ll->tet=(ll->tet&(~(0xFF<<((3-((addr).l&0x3))<<3))))|(((val).l&0xFF)<<((3-((addr).l&0x3))<<3)),true)
/* define this if you need a local copy of mem_tetra ll */
#define MMIX_LOCAL_LL mem_tetra *ll; /* current place in the simulated memory */
#define load_octa(val,addr) (ll=mem_find(addr),(val)->h=ll->tet,(val)->l=(ll+1)->tet,true)
#define load_tetra(val,addr) (ll=mem_find(addr),(val)->h=0,(val)->l=ll->tet,true)
#define load_wyde(val,addr) (ll=mem_find(addr),(val)->h=0,(val)->l=(ll->tet>>(16*(1-((addr).l&1))))&0xFFFF,true)
#define load_byte(val,addr) (ll=mem_find(addr),(val)->h=0,(val)->l=(ll->tet>>(8*(3-((addr).l&3))))&0xFF,true)
#define MMIX_STO(val,addr) (ll=mem_find(addr),ll->tet=(val).h,(ll+1)->tet=(val).l,true)
#define MMIX_STT(val,addr) (ll=mem_find(addr),ll->tet=(val).l,true)
#define MMIX_STW(val,addr) (ll=mem_find(addr),ll->tet=(ll->tet&(~(0xFFFF<<((1-((addr).l&0x1))<<4))))|(((val).l&0xFFFF)<<((1-((addr).l&0x1))<<4)),true)
#define MMIX_STB(val,addr) (ll=mem_find(addr),ll->tet=(ll->tet&(~(0xFF<<((3-((addr).l&0x3))<<3))))|(((val).l&0xFF)<<((3-((addr).l&0x3))<<3)),true)
#define store_octa_uncached(val,addr) store_octa(val,addr)
#define load_octa_uncached(val,addr) load_octa(val,addr)
#define MMIX_LDO(val,addr) (ll=mem_find(addr),(val).h=ll->tet,(val).l=(ll+1)->tet,true)
#define MMIX_LDT(val,addr) (ll=mem_find(addr),(val).h=0,(val).l=ll->tet,true)
#define MMIX_LDW(val,addr) (ll=mem_find(addr),(val).h=0,(val).l=(ll->tet>>(16*(1-((addr).l&1))))&0xFFFF,true)
#define MMIX_LDB(val,addr) (ll=mem_find(addr),(val).h=0,(val).l=(ll->tet>>(8*(3-((addr).l&3))))&0xFF,true)
#define MMIX_STO_UNCACHED(val,addr) MMIX_STO(val,addr)
#define MMIX_LDO_UNCACHED(val,addr) MMIX_LDO(val,addr)
#define load_instruction(inst,loc) (ll=mem_find(loc),*(inst)=ll->tet,true)
#define store_exec_translation(virt,phys)
#define store_data_translation(virt,phys)
#define MMIX_FETCH(inst,loc) (ll=mem_find(loc),inst=ll->tet,true)
#define MMIX_STORE_IVTC(virt,phys)
#define MMIX_STORE_DVTC(virt,phys)
#ifdef WIN32
#define MMIX_DELAY(ms,d) (Sleep(ms), d=(ms))
......@@ -32,12 +35,6 @@
/* define this to check for external asynchronous ineterrupts*/
#define MMIX_GET_INTERRUPT
/* this code is executed after processing the commandline */
#define MMIX_AFTER_COMMANDLINE
/* this code is executed before MMIX boots */
#define MMIX_PREBOOT
/* this code is executed when MMIX enters the handler for Ctrl-C */
#define MMIX_CTRL_HANDLER
......@@ -49,6 +46,10 @@
/* this code defines the actions for the strings above */
#define MMIX_INTERACT_ACTION
/* if MMIX_BOOT is defined, mmis-sim will boot from addres #8000...0000
otherwise it will resume at Main */
#undef MMIX_BOOT
#ifdef MMIX_PRINT
extern int mmix_printf(char *format,...);
......@@ -63,14 +64,10 @@ extern int mmix_fputc(int c, FILE *f);
/* give a condition to break from the inner loop */
#define MMIX_BREAK_LOOP false
/* give a condition to test for a reboot inside the inner loop */
#define MMIX_REBOOT false
/* define this to get the real TRAP implementation not the MMIXWARE fake TRAPS */
#undef MMIX_TRAP
#define MMIX_END halted
/* this is the error display function */
#define MMIX_ERROR(f,m) fprintf(stderr,f,m)
......@@ -80,17 +77,17 @@ extern int mmix_fputc(int c, FILE *f);
#define MMIX_MEM_TET tetra tet; /* the tetrabyte of simulated memory */
/* these are the functions for the instructions not implemented in the basic mmix simulator */
#define write_all_data_cache()
#define clear_all_instruction_cache()
#define clear_all_data_cache()
#define update_vtc(key) zero_octa
#define clear_all_data_vtc()
#define clear_all_instruction_vtc()
#define preload_data_cache(w,xx)
#define prego_instruction(w,xx)
#define store_data_cache(w,xx)
#define delete_data_cache(w,xx)
#define delete_instruction_cache(w,xx)
#define MMIX_WRITE_DCACHE()
#define MMIX_CLEAR_ICACHE()
#define MMIX_CLEAR_DCACHE()
#define MMIX_UPDATE_VTC(w) zero_octa
#define MMIX_CLEAR_DVTC()
#define MMIX_CLEAR_IVTC()
#define MMIX_PRELOAD_DCACHE(w,xx)
#define MMIX_PRELOAD_ICACHE(w,xx)
#define MMIX_STORE_DCACHE(w,xx)
#define MMIX_DELETE_DCACHE(w,xx)
#define MMIX_DELETE_ICACHE(w,xx)
#define MMXIAL_LINE_TRUNCATED fprintf(stderr,"(say `-b <number>' to increase the length of my input buffer)\n");
......
#ifndef LIBCONFIG_H
#define LIBCONFIG_H
#ifdef WIN32
#pragma warning(disable : 4996)
#endif
/* define this if you need a local copy of mem_tetra ll */
#define MMIX_LOCAL_LL /* mem_tetra *ll; current place in the simulated memory */
#define MMIX_STO(val,addr) store_data(8,val,addr)
#define MMIX_STT(val,addr) store_data(4,val,addr)
#define MMIX_STW(val,addr) store_data(2,val,addr)
#define MMIX_STB(val,addr) store_data(1,val,addr)
#define MMIX_LDO(val,addr) load_data(8,&(val),addr,0)
#define MMIX_LDT(val,addr) load_data(4,&(val),addr,0)
#define MMIX_LDW(val,addr) load_data(2,&(val),addr,0)
#define MMIX_LDB(val,addr) load_data(1,&(val),addr,0)
#define MMIX_STO_UNCACHED(val,addr) store_data_uncached(8,val,addr)
#define MMIX_LDO_UNCACHED(val,addr) load_data_uncached(8,&(val),addr,0)
#define MMIX_FETCH(inst,loc) load_instruction(&inst,loc)
#define MMIX_STORE_IVTC(virt,phys) store_exec_translation(&(virt),&(phys))
#define MMIX_STORE_DVTC(virt,phys) store_data_translation(&(virt),&(phys))
#define MMIX_DELAY(ms,d) d = vmb_wait_for_event_timed(&vmb,ms)
/* define this to check for external asynchronous ineterrupts*/
#define MMIX_GET_INTERRUPT
/* this code is executed when MMIX enters the handler for Ctrl-C */
#define MMIX_CTRL_HANDLER
/* this code defines additional options */
#define MMIX_OPTIONS
/* this defines new interactions for the user */
#define MMIX_INTERACT_STRING
/* this code defines the actions for the strings above */
#define MMIX_INTERACT_ACTION
/* if MMIX_BOOT is defined, mmis-sim will boot from addres #8000...0000
otherwise it will resume at Main */
#define MMIX_BOOT
#ifdef MMIX_PRINT
extern int mmix_printf(char *format,...);
extern int mmix_fputc(int c, FILE *f);
#define printf(...) mmix_printf(__VA_ARGS__)
#define fprintf(file,...) mmix_printf(__VA_ARGS__)
#define fputc(c,f) mmix_fputc(c,f)
#endif
#define MMIX_USAGE if (!*cur_arg) scan_option("?",true) /* exit with usage note */
/* give a condition to break from the inner loop */
#define MMIX_BREAK_LOOP false
/* define this to get the real TRAP implementation not the MMIXWARE fake TRAPS */
#define MMIX_TRAP
/* this is the error display function */
#define MMIX_ERROR(f,m) fprintf(stderr,f,m)
#define MMIX_OPTION_STRING
/* define this if you need the tetra inside the mem_node */
#define MMIX_MEM_TET /* tetra tet; the tetrabyte of simulated memory */
/* these are the functions for the instructions not implemented in the basic mmix simulator */
#define MMIX_WRITE_DCACHE() write_all_data_cache()
#define MMIX_CLEAR_ICACHE() clear_all_instruction_cache()
#define MMIX_CLEAR_DCACHE() clear_all_data_cache()
#define MMIX_UPDATE_VTC(w) update_vtc(w)
#define MMIX_CLEAR_DVTC() clear_all_data_vtc()
#define MMIX_CLEAR_IVTC() clear_all_instruction_vtc()
#define MMIX_PRELOAD_DCACHE(w,xx) preload_data_cache(w,xx)
#define MMIX_PRELOAD_ICACHE(w,xx) prego_instruction(w,xx)
#define MMIX_STORE_DCACHE(w,xx) write_data(w,xx)
#define MMIX_DELETE_DCACHE(w,xx) delete_data(w,xx)
#define MMIX_DELETE_ICACHE(w,xx) delete_instruction(w,xx)
#define MMXIAL_LINE_TRUNCATED fprintf(stderr,"(say `-b <number>' to increase the length of my input buffer)\n");
/* MMIXAL has its own notion of file numbers as embedded in the mmo file
we might want to convert this to a global file number */
#define MMIX_FILE_NO(file_no) (file_no)
/* define this to record file line and location associations while assembling */
#define MMIXAL_LINE_LOC(file_no,line_no,cur_loc)
#endif
......@@ -3,20 +3,12 @@ extern mem_node*mem_root;
extern mem_node*last_mem;
extern octa sclock;
extern octa neg_one;
extern FILE*mmo_file;
extern int postamble;
extern int byte_count;
extern byte buf[4];
extern int yzbytes;
extern int delta;
extern tetra tet;
extern octa cur_loc;
extern int cur_file;
extern int cur_line;
extern octa tmp;
extern tetra obj_time;
extern file_node file_info[256];
extern int ybyte2file_no[256];
extern int buf_size;
extern Char*buffer;
extern FILE*src_file;
......@@ -51,9 +43,6 @@ extern bool interacting;
extern bool show_operating_system;
extern bool rw_break;
extern octa rOlimit;
extern int port;
extern char*host;
extern char localhost[];
extern bool interact_after_break;
extern bool tripping;
extern bool good;
......@@ -89,12 +78,4 @@ extern FILE*fake_stdin;
extern FILE*dump_file;
extern char*usage_help[];
extern char*interactive_help[];
extern char command_buf[];
extern FILE*incl_file;
extern char cur_disp_mode;
extern char cur_disp_type;
extern bool cur_disp_set;
extern octa cur_disp_addr;
extern octa cur_seg;
extern char spec_reg_code[];
extern char spec_regg_code[];
\ No newline at end of file
extern jmp_buf mmix_exit;
#include "/home/ruckert/vmb/src/util/vmb.h"
#include "/home/ruckert/vmb/src/mmix/address.h"
#include "/home/ruckert/vmb/src/mmix/mmix-bus.h"
extern device_info vmb;
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include "libconfig.h"
#include <time.h>
#include "libtype.h"
#include "libglobals.h"
#include <setjmp.h>
#include "libname.h"
/* simple implementation of the identity mapping */
int ybyte2file_no[256];
int filename2file(char *filename, char c)
{ return c;
int filename2file(char *filename, int c)
{ if (file_info[c].name==NULL)/* the usual case */
{ file_info[c].name = filename;
return c;
}
else if (strcmp(file_info[c].name,filename)==0) /* the other usual case */
{ free(filename);
return c;
}
MMIX_ERROR("ybyte does not match filename %s!\n",filename);
free(filename);
longjmp(mmix_exit,-6);
return 0;
}
int ybyte2file(char ybyte)
{
return ybyte;
}
\ No newline at end of file
/* convert a ybyte to a valid index into file_info,
return -1; if there is no valid file_info entry for this ybyte */
int ybyte2file(int c)
{ if (file_info[c].name)
return c;
else
return -1;
}
extern int filename2file(char *filename, char c);
extern int ybyte2file(char ybyte);
extern int filename2file(char *filename, int c);
extern int ybyte2file(int c);
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <signal.h>
#include <setjmp.h>
#include "abstime.h"
#include "libconfig.h"
#include <time.h>
#include "libtype.h"
#include "libglobals.h"
#include "mmixlib.h"
#include "address.h"
#include "mmix-bus.h"
#include "vmb.h"
device_info vmb = {0};
static char localhost[]="localhost";
static int busport=9002; /* on which port to connect to the bus */
static char *bushost=localhost; /* on which host to connect to the bus */
int main(argc,argv)
int argc;
char *argv[];
{
char **boot_cur_arg;
int boot_argc;
g[255].h=0;
g[255].l=setjmp(mmix_exit);
if (g[255].l!=0)
goto end_simulation;
mmix_lib_initialize();
mmix_commandline(argc,argv);
if (bushost==NULL) panic("No Bus given. Use Option -B[host:]port");
init_mmix_bus(bushost,busport,"MMIX CPU");
mmix_initialize();
boot_cur_arg = cur_arg;
boot_argc = argc;
if (vmb.power)
vmb_raise_reset(&vmb);
boot:
argc = boot_argc;
cur_arg = boot_cur_arg;
fprintf(stderr,"Power...");
while (!vmb.power)
{ vmb_wait_for_power(&vmb);
if (!vmb.connected) goto end_simulation;
}
fprintf(stderr,"ON\n");
MMIX_CLEAR_DVTC();
MMIX_CLEAR_IVTC();
MMIX_CLEAR_DCACHE();
MMIX_CLEAR_ICACHE();
mmix_boot();
mmix_load_file(*cur_arg);
mmix_commandline(argc, argv);
write_all_data_cache();
clear_all_instruction_cache();
if (interacting) set_break(g[rWW],exec_bit);
while (true) {
if (interrupt && !breakpoint) breakpoint=interacting=true, interrupt=false;
else if (!(inst_ptr.h&sign_bit) || show_operating_system ||
(inst_ptr.h==0x80000000 && inst_ptr.l==0))
{ breakpoint=false;
if (interacting)
if (!mmix_interact()) goto end_simulation;
}
if (halted) break;
{ if (!resuming)
mmix_fetch_instruction();
mmix_perform_instruction();
mmix_trace();
mmix_dynamic_trap();
if (resuming && op!=RESUME) resuming=false;
if (!resuming && MMIX_BREAK_LOOP) break;
} while (resuming || (!interrupt && !breakpoint));
if (interact_after_break)
interacting=true, interact_after_break=false;
if (!vmb.power||(g[rQ].l&g[rK].l&RE_BIT))
goto boot;
}
end_simulation: if (profiling) mmix_profile();
if (interacting || profiling || showing_stats) show_stats(true);
mmix_finalize();
mmix_lib_finalize();
return g[255].l; /* provide rudimentary feedback for non-interactive runs */
}
This diff is collapsed.
......@@ -7,7 +7,6 @@ extern void free_tree(trie_node *root);
#ifndef _MMIXAL_
extern void free_file_info(void);
/* reset the file_info and ybyte2file_no information */
extern int ybyte2file_no[256]; /* mapping internal to external files */
extern mem_tetra* mem_find(octa addr);
extern mem_node* new_mem(void);
extern void mmputchars(unsigned char *buf,int size,octa addr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment