/* scp.c: simulator control program Copyright (c) 1993-2022, Robert M Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of Robert M Supnik shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Robert M Supnik. 21-Oct-21 RMS Fixed bug in byte deposits if aincr > 1 16-Feb-21 JDB Rewrote get_rval, put_rval to support arrays of structures 25-Jan-21 JDB REG "size" field now determines access size REG "maxval" field now determines maximum allowed value 08-Mar-16 RMS Added shutdown flag for detach_all 20-Mar-12 MP Fixes to "SHOW SHOW" commands 06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan) 25-Sep-11 MP Added the ability for a simulator built with SIM_ASYNCH_IO to change whether I/O is actually done asynchronously by the new scp command SET ASYNCH and SET NOASYNCH 22-Sep-11 MP Added signal catching of SIGHUP and SIGTERM to cause simulator STOP. This allows an externally signalled event (i.e. system shutdown, or logoff) to signal a running simulator of these events and to allow reasonable actions to be taken. This will facilitate running a simulator as a 'service' on *nix platforms, given a sufficiently flexible simulator .ini file. 20-Apr-11 MP Added expansion of %STATUS% and %TSTATUS% in do command arguments. STATUS is the numeric value of the last command error status and TSTATUS is the text message relating to the last command error status 17-Apr-11 MP Changed sim_rest to defer attaching devices until after device register contents have been restored since some attach activities may reference register contained info. 29-Jan-11 MP Adjusted sim_debug to: - include the simulator timestamp (sim_gtime) as part of the prefix for each line of output - write complete lines at a time (avoid asynch I/O issues). 05-Jan-11 MP Added Asynch I/O support 22-Jan-11 MP Added SET ON, SET NOON, ON, GOTO and RETURN command support 13-Jan-11 MP Added "SHOW SHOW" and "SHOW SHOW" commands 05-Jan-11 RMS Fixed bug in deposit stride for numeric input (John Dundas) 23-Dec-10 RMS Clarified some help messages (Mark Pizzolato) 08-Nov-10 RMS Fixed handling of DO with no arguments (Dave Bryan) 22-May-10 RMS Added *nix READLINE support (Mark Pizzolato) 08-Feb-09 RMS Fixed warnings in help printouts 29-Dec-08 RMS Fixed implementation of MTAB_NC 24-Nov-08 RMS Revised RESTORE unit logic for consistency 05-Sep-08 JDB "detach_all" ignores error status returns if shutting down 17-Aug-08 RMS Revert RUN/BOOT to standard, rather than powerup, reset 25-Jul-08 JDB DO cmd missing params now default to null string 29-Jun-08 JDB DO cmd sub_args now allows "\\" to specify literal backslash 04-Jun-08 JDB label the patch delta more clearly 31-Mar-08 RMS Fixed bug in local/global register search (Mark Pizzolato) Fixed bug in restore of RO units (Mark Pizzolato) 06-Feb-08 RMS Added SET/SHO/NO BR with default argument 18-Jul-07 RMS Modified match_ext for VMS ext;version support 28-Apr-07 RMS Modified sim_instr invocation to call sim_rtcn_init_all Fixed bug in get_sim_opt Fixed bug in restoration with changed memory size 08-Mar-07 JDB Fixed breakpoint actions in DO command file processing 30-Jan-07 RMS Fixed bugs in get_ipaddr 17-Oct-06 RMS Added idle support 04-Oct-06 JDB DO cmd failure now echoes cmd unless -q 30-Aug-06 JDB detach_unit returns SCPE_UNATT if not attached 14-Jul-06 RMS Added sim_activate_abs 02-Jun-06 JDB Fixed do_cmd to exit nested files on assertion failure Added -E switch to do_cmd to exit on any error 14-Feb-06 RMS Upgraded save file format to V3.5 18-Jan-06 RMS Added fprint_stopped_gen Added breakpoint spaces Fixed unaligned register access (Doug Carman) 22-Sep-05 RMS Fixed declarations (Sterling Garwood) 30-Aug-05 RMS Revised to trim trailing spaces on file names 25-Aug-05 RMS Added variable default device support 23-Aug-05 RMS Added Linux line history support 16-Aug-05 RMS Fixed C++ declaration and cast problems 01-May-05 RMS Revised syntax for SET DEBUG (Dave Bryan) 22-Mar-05 JDB Modified DO command to allow ten-level nesting 18-Mar-05 RMS Moved DETACH tests into detach_unit (Dave Bryan) Revised interface to fprint_sym, fparse_sym 13-Mar-05 JDB ASSERT now requires a conditional operator 07-Feb-05 RMS Added ASSERT command (Dave Bryan) 02-Feb-05 RMS Fixed bug in global register search 26-Dec-04 RMS Qualified SAVE examine, RESTORE deposit with SIM_SW_REST 10-Nov-04 JDB Fixed logging of errors from cmds in "do" file 05-Nov-04 RMS Moved SET/SHOW DEBUG under CONSOLE hierarchy Renamed unit OFFLINE/ONLINE to DISABLED/ENABLED (Dave Bryan) Revised to flush output files after simulation stop (Dave Bryan) 15-Oct-04 RMS Fixed HELP to suppress duplicate descriptions 27-Sep-04 RMS Fixed comma-separation options in set (David Bryan) 09-Sep-04 RMS Added -p option for RESET 13-Aug-04 RMS Qualified RESTORE detach with SIM_SW_REST 17-Jul-04 JDB DO cmd file open failure retries with ".sim" appended 17-Jul-04 RMS Added ECHO command (Dave Bryan) 12-Jul-04 RMS Fixed problem ATTACHing to read only files (John Dundas) 28-May-04 RMS Added SET/SHOW CONSOLE 14-Feb-04 RMS Updated SAVE/RESTORE (V3.2) RMS Added debug print routines (Dave Hittner) RMS Added sim_vm_parse_addr and sim_vm_fprint_addr RMS Added REG_VMAD support RMS Split out libraries RMS Moved logging function to SCP RMS Exposed step counter interface(s) RMS Fixed double logging of SHOW BREAK (Mark Pizzolato) RMS Fixed implementation of REG_VMIO RMS Added SET/SHOW DEBUG, SET/SHOW DEBUG, SHOW MODIFIERS, SHOW RADIX RMS Changed sim_fsize to take uptr argument 29-Dec-03 RMS Added Telnet console output stall support 01-Nov-03 RMS Cleaned up implicit detach on attach/restore Fixed bug in command line read while logging (Mark Pizzolato) 01-Sep-03 RMS Fixed end-of-file problem in dep, idep Fixed error on trailing spaces in dep, idep 15-Jul-03 RMS Removed unnecessary test in reset_all 15-Jun-03 RMS Added register flag REG_VMIO 25-Apr-03 RMS Added extended address support (V3.0) Fixed bug in SAVE (Peter Schorn) Added u5, u6 fields Added logical name support 03-Mar-03 RMS Added sim_fsize 27-Feb-03 RMS Fixed bug in multiword deposits to files 08-Feb-03 RMS Changed sim_os_sleep to void, match_ext to char* Added multiple actions, .ini file support Added multiple switch evaluations per line 07-Feb-03 RMS Added VMS support for ! (Mark Pizzolato) 01-Feb-03 RMS Added breakpoint table extension, actions 14-Jan-03 RMS Added missing function prototypes 10-Jan-03 RMS Added attach/restore flag, dynamic memory size support, case sensitive SET options 22-Dec-02 RMS Added ! (OS command) feature (Mark Pizzolato) 17-Dec-02 RMS Added get_ipaddr 02-Dec-02 RMS Added EValuate command 16-Nov-02 RMS Fixed bug in register name match algorithm 13-Oct-02 RMS Fixed Borland compiler warnings (Hans Pufal) 05-Oct-02 RMS Fixed bugs in set_logon, ssh_break (David Hittner) Added support for fixed buffer devices Added support for Telnet console, removed VT support Added help Added VMS file optimizations (Robert Alan Byer) Added quiet mode, DO with parameters, GUI interface, extensible commands (Brian Knittel) Added device enable/disable commands 14-Jul-02 RMS Fixed exit bug in do, added -v switch (Brian Knittel) 17-May-02 RMS Fixed bug in fxread/fxwrite error usage (found by Norm Lastovic) 02-May-02 RMS Added VT emulation interface, changed {NO}LOG to SET {NO}LOG 22-Apr-02 RMS Fixed laptop sleep problem in clock calibration, added magtape record length error (Jonathan Engdahl) 26-Feb-02 RMS Fixed initialization bugs in do_cmd, get_aval (Brian Knittel) 10-Feb-02 RMS Fixed problem in clock calibration 06-Jan-02 RMS Moved device enable/disable to simulators 30-Dec-01 RMS Generalized timer packaged, added circular arrays 19-Dec-01 RMS Fixed DO command bug (John Dundas) 07-Dec-01 RMS Implemented breakpoint package 05-Dec-01 RMS Fixed bug in universal register logic 03-Dec-01 RMS Added read-only units, extended SET/SHOW, universal registers 24-Nov-01 RMS Added unit-based registers 16-Nov-01 RMS Added DO command 28-Oct-01 RMS Added relative range addressing 08-Oct-01 RMS Added SHOW VERSION 30-Sep-01 RMS Relaxed attach test in BOOT 27-Sep-01 RMS Added queue count routine, fixed typo in ex/mod 17-Sep-01 RMS Removed multiple console support 07-Sep-01 RMS Removed conditional externs on function prototypes Added special modifier print 31-Aug-01 RMS Changed int64 to t_int64 for Windoze (V2.7) 18-Jul-01 RMS Minor changes for Macintosh port 12-Jun-01 RMS Fixed bug in big-endian I/O (Dave Conroy) 27-May-01 RMS Added multiple console support 16-May-01 RMS Added logging 15-May-01 RMS Added features from Tim Litt 12-May-01 RMS Fixed missing return in disable_cmd 25-Mar-01 RMS Added ENABLE/DISABLE 14-Mar-01 RMS Revised LOAD/DUMP interface (again) 05-Mar-01 RMS Added clock calibration support 05-Feb-01 RMS Fixed bug, DETACH buffered unit with hwmark = 0 04-Feb-01 RMS Fixed bug, RESTORE not using device's attach routine 21-Jan-01 RMS Added relative time 22-Dec-00 RMS Fixed find_device for devices ending in numbers 08-Dec-00 RMS V2.5a changes 30-Oct-00 RMS Added output file option to examine 11-Jul-99 RMS V2.5 changes 13-Apr-99 RMS Fixed handling of 32b addresses 04-Oct-98 RMS V2.4 changes 20-Aug-98 RMS Added radix commands 05-Jun-98 RMS Fixed bug in ^D handling for UNIX 10-Apr-98 RMS Added switches to all commands 26-Oct-97 RMS Added search capability 25-Jan-97 RMS Revised data types 23-Jan-97 RMS Added bi-endian I/O 06-Sep-96 RMS Fixed bug in variable length IEXAMINE 16-Jun-96 RMS Changed interface to parse/print_sym 06-Apr-96 RMS Added error checking in reset all 07-Jan-96 RMS Added register buffers in save/restore 11-Dec-95 RMS Fixed ordering bug in save/restore 22-May-95 RMS Added symbolic input 13-Apr-95 RMS Added symbolic printouts */ /* Macros and data structures */ #define NOT_MUX_USING_CODE /* sim_tmxr library provider or agnostic */ #define IN_SCP_C 1 /* Include from scp.c */ #include "sim_defs.h" #include "sim_rev.h" #include "sim_disk.h" #include "sim_tape.h" #include "sim_ether.h" #include "sim_card.h" #include "sim_serial.h" #include "sim_video.h" #include "sim_sock.h" #include "sim_frontpanel.h" #include #include #include #include #if defined(_WIN32) #include #include #endif #include #if defined(SIM_HAVE_DLOPEN) /* Dynamic Readline support */ #include #endif #ifndef MAX #define MAX(a,b) (((a) >= (b)) ? (a) : (b)) #endif #ifndef MIN #define MIN(a,b) (((a) <= (b)) ? (a) : (b)) #endif /* Max width of a value expressed as a formatted string */ #define MAX_WIDTH ((int) ((CHAR_BIT * sizeof (t_value) * 4 + 3)/3)) /* search logical and boolean ops */ #define SCH_OR 0 /* search logicals */ #define SCH_AND 1 #define SCH_XOR 2 #define SCH_E 0 /* search booleans */ #define SCH_N 1 #define SCH_G 2 #define SCH_L 3 #define SCH_EE 4 #define SCH_NE 5 #define SCH_GE 6 #define SCH_LE 7 #define MAX_DO_NEST_LVL 20 /* DO cmd nesting level limit */ #define SRBSIZ 1024 /* save/restore buffer */ #define SIM_BRK_INILNT 4096 /* bpt tbl length */ #define SIM_BRK_ALLTYP 0xFFFFFFFB #define UPDATE_SIM_TIME \ if (1) { \ int32 _x; \ AIO_LOCK; \ if (sim_clock_queue == QUEUE_LIST_END) \ _x = noqueue_time; \ else \ _x = sim_clock_queue->time; \ sim_time = sim_time + (_x - sim_interval); \ sim_rtime = sim_rtime + ((uint32) (_x - sim_interval)); \ if (sim_clock_queue == QUEUE_LIST_END) \ noqueue_time = sim_interval; \ else \ sim_clock_queue->time = sim_interval; \ AIO_UNLOCK; \ } \ else \ (void)0 #define SZ_D(dp) (size_map[((dp)->dwidth + CHAR_BIT - 1) / CHAR_BIT]) #define SZ_R(rp) \ (size_map[((rp)->width + (rp)->offset + CHAR_BIT - 1) / CHAR_BIT]) #if defined (USE_INT64) #define SZ_LOAD(sz,v,mb,j) \ if (sz == sizeof (uint8)) v = *(((uint8 *) mb) + ((uint32) j)); \ else if (sz == sizeof (uint16)) v = *(((uint16 *) mb) + ((uint32) j)); \ else if (sz == sizeof (uint32)) v = *(((uint32 *) mb) + ((uint32) j)); \ else v = *(((t_uint64 *) mb) + ((uint32) j)); #define SZ_STORE(sz,v,mb,j) \ if (sz == sizeof (uint8)) *(((uint8 *) mb) + j) = (uint8) v; \ else if (sz == sizeof (uint16)) *(((uint16 *) mb) + ((uint32) j)) = (uint16) v; \ else if (sz == sizeof (uint32)) *(((uint32 *) mb) + ((uint32) j)) = (uint32) v; \ else *(((t_uint64 *) mb) + ((uint32) j)) = v; #else #define SZ_LOAD(sz,v,mb,j) \ if (sz == sizeof (uint8)) v = *(((uint8 *) mb) + ((uint32) j)); \ else if (sz == sizeof (uint16)) v = *(((uint16 *) mb) + ((uint32) j)); \ else v = *(((uint32 *) mb) + ((uint32) j)); #define SZ_STORE(sz,v,mb,j) \ if (sz == sizeof (uint8)) *(((uint8 *) mb) + ((uint32) j)) = (uint8) v; \ else if (sz == sizeof (uint16)) *(((uint16 *) mb) + ((uint32) j)) = (uint16) v; \ else *(((uint32 *) mb) + ((uint32) j)) = v; #endif #define SIM_DBG_EVENT_NEG 0x80000000 /* negative event dispatch activities */ #define SIM_DBG_EVENT 0x40000000 /* event dispatch activities */ #define SIM_DBG_ACTIVATE 0x20000000 /* queue insertion activities */ #define SIM_DBG_AIO_QUEUE 0x10000000 /* asynch event queue activities */ #define SIM_DBG_EXP_STACK 0x08000000 /* expression stack activities */ #define SIM_DBG_EXP_EVAL 0x04000000 /* expression evaluation activities */ #define SIM_DBG_BRK_ACTION 0x02000000 /* action activities */ #define SIM_DBG_DO 0x01000000 /* do activities */ #define SIM_DBG_SAVE 0x00800000 /* save activities */ #define SIM_DBG_RESTORE 0x00400000 /* restore activities */ static DEBTAB scp_debug[] = { {"EVENT", SIM_DBG_EVENT, "Event Dispatch Activities"}, {"NEGATIVE", SIM_DBG_EVENT_NEG, "Negative Event Dispatch Activities"}, {"ACTIVATE", SIM_DBG_ACTIVATE, "Event Queue Insertion Activities"}, {"QUEUE", SIM_DBG_AIO_QUEUE, "Asynch Event Queue Activities"}, {"EXPSTACK", SIM_DBG_EXP_STACK, "Expression Stack Activities"}, {"EXPEVAL", SIM_DBG_EXP_EVAL, "Expression Evaluation Activities"}, {"ACTION", SIM_DBG_BRK_ACTION, "If/Breakpoint/Expect Action Activities"}, {"DO", SIM_DBG_DO, "Do Command/Expansion Activities"}, {"SAVE", SIM_DBG_SAVE, "Save Activities"}, {"RESTORE", SIM_DBG_RESTORE, "Restore Activities"}, {0} }; static const char *sim_scp_description (DEVICE *dptr) { return "SCP Event and Internal Command Processing and Testing"; } static UNIT scp_test_units[4]; DEVICE sim_scp_dev = { "SCP-PROCESS", scp_test_units, NULL, NULL, 4, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DEV_NOSAVE|DEV_DEBUG, 0, scp_debug, NULL, NULL, NULL, NULL, NULL, sim_scp_description}; /* Asynch I/O support */ #if defined (SIM_ASYNCH_IO) pthread_mutex_t sim_asynch_lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t sim_asynch_wake = PTHREAD_COND_INITIALIZER; pthread_mutex_t sim_timer_lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t sim_timer_wake = PTHREAD_COND_INITIALIZER; pthread_mutex_t sim_tmxr_poll_lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t sim_tmxr_poll_cond = PTHREAD_COND_INITIALIZER; int32 sim_tmxr_poll_count; pthread_t sim_asynch_main_threadid; UNIT * volatile sim_asynch_queue; t_bool sim_asynch_enabled = TRUE; int32 sim_asynch_check; int32 sim_asynch_latency = 4000; /* 4 usec interrupt latency */ int32 sim_asynch_inst_latency = 20; /* assume 5 mip simulator */ int sim_aio_update_queue (void) { int migrated = 0; AIO_ILOCK; if (AIO_QUEUE_VAL != QUEUE_LIST_END) { /* List !Empty */ UNIT *q, *uptr; int32 a_event_time; do { /* Grab current queue */ q = AIO_QUEUE_VAL; } while (q != AIO_QUEUE_SET(QUEUE_LIST_END, q)); while (q != QUEUE_LIST_END) { /* List !Empty */ sim_debug (SIM_DBG_AIO_QUEUE, &sim_scp_dev, "Migrating Asynch event for %s after %d %s\n", sim_uname(q), q->a_event_time, sim_vm_interval_units); ++migrated; uptr = q; q = q->a_next; uptr->a_next = NULL; /* hygiene */ if (uptr->a_activate_call != &sim_activate_notbefore) { a_event_time = uptr->a_event_time-((sim_asynch_inst_latency+1)/2); if (a_event_time < 0) a_event_time = 0; } else a_event_time = uptr->a_event_time; AIO_IUNLOCK; uptr->a_activate_call (uptr, a_event_time); if (uptr->a_check_completion) { sim_debug (SIM_DBG_AIO_QUEUE, &sim_scp_dev, "Calling Completion Check for asynch event on %s\n", sim_uname(uptr)); uptr->a_check_completion (uptr); } AIO_ILOCK; } } AIO_IUNLOCK; return migrated; } void sim_aio_activate (ACTIVATE_API caller, UNIT *uptr, int32 event_time) { AIO_ILOCK; sim_debug (SIM_DBG_AIO_QUEUE, &sim_scp_dev, "Queueing Asynch event for %s after %d %s\n", sim_uname(uptr), event_time, sim_vm_interval_units); if (uptr->a_next) { uptr->a_activate_call = sim_activate_abs; } else { UNIT *q; uptr->a_event_time = event_time; uptr->a_activate_call = caller; do { q = AIO_QUEUE_VAL; uptr->a_next = q; /* Mark as on list */ } while (q != AIO_QUEUE_SET(uptr, q)); } AIO_IUNLOCK; sim_asynch_check = 0; /* try to force check */ if (sim_idle_wait) { sim_debug (TIMER_DBG_IDLE, &sim_timer_dev, "waking due to event on %s after %d %s\n", sim_uname(uptr), event_time, sim_vm_interval_units); pthread_cond_signal (&sim_asynch_wake); } } #else t_bool sim_asynch_enabled = FALSE; #endif /* The per-simulator init routine is a weak global that defaults to NULL The other per-simulator pointers can be overrriden by the init routine WEAK void (*sim_vm_init) (void); This routine is no longer invoked this way since it doesn't work reliably on all simh supported compile environments. A simulator that needs these initializations can perform them in the CPU device reset routine which will always be called before anything else can be processed. */ char* (*sim_vm_read) (char *ptr, int32 size, FILE *stream) = NULL; void (*sim_vm_post) (t_bool from_scp) = NULL; CTAB *sim_vm_cmd = NULL; void (*sim_vm_sprint_addr) (char *buf, DEVICE *dptr, t_addr addr) = NULL; void (*sim_vm_fprint_addr) (FILE *st, DEVICE *dptr, t_addr addr) = NULL; t_addr (*sim_vm_parse_addr) (DEVICE *dptr, CONST char *cptr, CONST char **tptr) = NULL; t_value (*sim_vm_pc_value) (void) = NULL; t_bool (*sim_vm_is_subroutine_call) (t_addr **ret_addrs) = NULL; void (*sim_vm_reg_update) (REG *rptr, uint32 idx, t_value prev_val, t_value new_val) = NULL; t_bool (*sim_vm_fprint_stopped) (FILE *st, t_stat reason) = NULL; const char *sim_vm_release = NULL; const char *sim_vm_release_message = NULL; const char **sim_clock_precalibrate_commands = NULL; /* Prototypes */ /* Set and show command processors */ t_stat set_dev_radix (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat set_dev_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat set_unit_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat set_unit_append (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat ssh_break (FILE *st, const char *cptr, int32 flg); t_stat show_cmd_fi (FILE *ofile, int32 flag, CONST char *cptr); t_stat show_config (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_queue (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_time (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_mod_names (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_show_commands (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_log_names (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_dev_radix (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_dev_logicals (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_dev_modifiers (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_dev_show_commands (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_version (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_default (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_break (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_on (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_do (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_runlimit (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat sim_show_send (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat sim_show_expect (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat show_device (FILE *st, DEVICE *dptr, int32 flag); t_stat show_unit (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag); t_stat show_all_mods (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flg, int32 *toks); t_stat show_one_mod (FILE *st, DEVICE *dptr, UNIT *uptr, MTAB *mptr, CONST char *cptr, int32 flag); t_stat sim_save (FILE *sfile); t_stat sim_rest (FILE *rfile); /* Breakpoint package */ t_stat sim_brk_init (void); t_stat sim_brk_set (t_addr loc, int32 sw, int32 ncnt, CONST char *act); t_stat sim_brk_clr (t_addr loc, int32 sw); t_stat sim_brk_clrall (int32 sw); t_stat sim_brk_show (FILE *st, t_addr loc, int32 sw); t_stat sim_brk_showall (FILE *st, int32 sw); CONST char *sim_brk_getact (char *buf, int32 size); BRKTAB *sim_brk_new (t_addr loc, uint32 btyp); char *sim_brk_clract (void); FILE *stdnul; /* Command support routines */ SCHTAB *get_rsearch (CONST char *cptr, int32 radix, SCHTAB *schptr); SCHTAB *get_asearch (CONST char *cptr, int32 radix, SCHTAB *schptr); int32 test_search (t_value *val, SCHTAB *schptr); static const char *get_glyph_gen (const char *iptr, char *optr, char mchar, t_bool uc, t_bool quote, char escape_char); typedef enum { SW_ERROR, /* Parse Error */ SW_BITMASK, /* Bitmask Value or Not a switch */ SW_NUMBER /* Numeric Value */ } SWITCH_PARSE; SWITCH_PARSE get_switches (const char *cptr, int32 *sw_val, int32 *sw_number); void put_rval_pcchk (REG *rptr, uint32 idx, t_value val, t_bool pc_chk); void put_rval (REG *rptr, uint32 idx, t_value val); void fprint_help (FILE *st); void fprint_stopped (FILE *st, t_stat r); void fprint_capac (FILE *st, DEVICE *dptr, UNIT *uptr); void fprint_sep (FILE *st, int32 *tokens); REG *find_reg_glob (CONST char *ptr, CONST char **optr, DEVICE **gdptr); REG *find_reg_glob_reason (CONST char *cptr, CONST char **optr, DEVICE **gdptr, t_stat *stat); const char *sim_eval_expression (const char *cptr, t_svalue *value, t_bool parens_required, t_stat *stat); /* Forward references */ t_stat scp_attach_unit (DEVICE *dptr, UNIT *uptr, const char *cptr); t_stat scp_detach_unit (DEVICE *dptr, UNIT *uptr); t_bool qdisable (DEVICE *dptr); t_stat attach_err (UNIT *uptr, t_stat stat); t_stat detach_all (int32 start_device, t_bool shutdown); t_stat assign_device (DEVICE *dptr, const char *cptr); t_stat deassign_device (DEVICE *dptr); t_stat ssh_break_one (FILE *st, int32 flg, t_addr lo, int32 cnt, CONST char *aptr); t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, CONST char *cptr, REG *lowr, REG *highr, uint32 lows, uint32 highs); t_stat ex_reg (FILE *ofile, t_value val, int32 flag, REG *rptr, uint32 idx); t_stat dep_reg (int32 flag, CONST char *cptr, REG *rptr, uint32 idx); t_stat exdep_addr_loop (FILE *ofile, SCHTAB *schptr, int32 flag, const char *cptr, t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr); t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc); t_stat dep_addr (int32 flag, const char *cptr, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc); void fprint_fields (FILE *stream, t_value before, t_value after, BITFIELD* bitdefs); t_stat step_svc (UNIT *ptr); t_stat runlimit_svc (UNIT *ptr); t_stat expect_svc (UNIT *ptr); t_stat flush_svc (UNIT *ptr); t_stat shift_args (char *do_arg[], size_t arg_count); t_stat set_on (int32 flag, CONST char *cptr); t_stat set_verify (int32 flag, CONST char *cptr); t_stat set_message (int32 flag, CONST char *cptr); t_stat set_quiet (int32 flag, CONST char *cptr); t_stat set_asynch (int32 flag, CONST char *cptr); t_stat sim_show_asynch (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr); t_stat do_cmd_label (int32 flag, CONST char *cptr, CONST char *label); void int_handler (int signal); t_stat set_prompt (int32 flag, CONST char *cptr); t_stat set_runlimit (int32 flag, CONST char *cptr); t_stat sim_set_asynch (int32 flag, CONST char *cptr); static const char *_get_dbg_verb (uint32 dbits, DEVICE* dptr, UNIT *uptr); static t_stat sim_sanity_check_register_declarations (DEVICE **devices); static void fix_writelock_mtab (DEVICE *dptr); static t_stat _sim_debug_flush (void); /* Global data */ const char *sim_prog_name = NULL; /* pointer to the executable name */ DEVICE *sim_dflt_dev = NULL; UNIT *sim_clock_queue = QUEUE_LIST_END; int32 sim_interval = 0; const char *sim_vm_interval_units = "instructions"; /* Simulator can change to "cycles" as needed */ const char *sim_vm_step_unit = "instruction"; /* Simulator can change */ int32 sim_switches = 0; int32 sim_switch_number = 0; FILE *sim_ofile = NULL; TMLN *sim_oline = NULL; MEMFILE *sim_mfile = NULL; SCHTAB *sim_schrptr = FALSE; SCHTAB *sim_schaptr = FALSE; DEVICE *sim_dfdev = NULL; UNIT *sim_dfunit = NULL; DEVICE **sim_internal_devices = NULL; uint32 sim_internal_device_count = 0; int32 sim_opt_out = 0; volatile t_bool sim_is_running = FALSE; t_bool sim_processing_event = FALSE; uint32 sim_brk_summ = 0; uint32 sim_brk_types = 0; BRKTYPTAB *sim_brk_type_desc = NULL; /* type descriptions */ uint32 sim_brk_dflt = 0; uint32 sim_brk_match_type; t_addr sim_brk_match_addr; char *sim_brk_act[MAX_DO_NEST_LVL]; char *sim_brk_act_buf[MAX_DO_NEST_LVL]; BRKTAB **sim_brk_tab = NULL; int32 sim_brk_ent = 0; int32 sim_brk_lnt = 0; int32 sim_brk_ins = 0; int32 sim_quiet = 0; int32 sim_show_message = 1; /* the message display status of the currently open do file */ int32 sim_step = 0; int32 sim_runlimit = 0; int32 sim_runlimit_initial = 0; double sim_runlimit_d = 0.0; double sim_runlimit_d_initial = 0.0; int32 sim_runlimit_switches = 0; t_bool sim_runlimit_enabled = FALSE; char *sim_sub_instr = NULL; /* Copy of pre-substitution buffer contents */ char *sim_sub_instr_buf = NULL; /* Buffer address that substitutions were saved in */ size_t sim_sub_instr_size = 0; /* substitution buffer size */ size_t *sim_sub_instr_off = NULL; /* offsets in substitution buffer where original data started */ static double sim_time; static uint32 sim_rtime; static int32 noqueue_time; volatile t_bool stop_cpu = FALSE; volatile t_bool sigterm_received = FALSE; static unsigned int sim_stop_sleep_ms = 250; static char **sim_argv; static int sim_exit_status = EXIT_SUCCESS; /* optionally set by EXIT command */ t_value *sim_eval = NULL; static t_value sim_last_val; static t_addr sim_last_addr; FILE *sim_log = NULL; /* log file */ FILEREF *sim_log_ref = NULL; /* log file file reference */ FILE *sim_deb = NULL; /* debug file */ FILEREF *sim_deb_ref = NULL; /* debug file file reference */ int32 sim_deb_switches = 0; /* debug switches */ size_t sim_deb_buffer_size = 0; /* debug memory buffer size */ char *sim_deb_buffer = NULL; /* debug memory buffer */ size_t sim_debug_buffer_offset = 0; /* debug memory buffer insertion offset */ size_t sim_debug_buffer_inuse = 0; /* debug memory buffer inuse count */ struct timespec sim_deb_basetime; /* debug timestamp relative base time */ char *sim_prompt = NULL; /* prompt string */ static FILE *sim_gotofile; /* the currently open do file */ static int32 sim_goto_line[MAX_DO_NEST_LVL+1]; /* the current line number in the currently open do file */ static int32 sim_do_echo = 0; /* the echo status of the currently open do file */ static int32 sim_on_inherit = 0; /* the inherit status of on state and conditions when executing do files */ static int32 sim_do_depth = 0; static t_bool sim_cmd_echoed = FALSE; /* Command was emitted already prior to message output */ static char **sim_exp_argv = NULL; static int32 sim_on_check[MAX_DO_NEST_LVL+1]; static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+2]; #define ON_SIGINT_ACTION (SCPE_MAX_ERR+1) static char sim_do_filename[MAX_DO_NEST_LVL+1][CBUFSIZE]; static const char *sim_do_ocptr[MAX_DO_NEST_LVL+1]; static const char *sim_do_label[MAX_DO_NEST_LVL+1]; static t_bool sim_if_cmd[MAX_DO_NEST_LVL+1]; static t_bool sim_if_cmd_last[MAX_DO_NEST_LVL+1]; static t_bool sim_if_result[MAX_DO_NEST_LVL+1]; static t_bool sim_if_result_last[MAX_DO_NEST_LVL+1]; static t_bool sim_cptr_is_action[MAX_DO_NEST_LVL+1]; static DEVICE *sim_failed_reset_dptr = NULL; static struct deleted_env_var { char *name; char *value; } *sim_external_env = NULL; static int sim_external_env_count = 0; t_stat sim_last_cmd_stat; /* Command Status */ struct timespec cmd_time; /* */ static SCHTAB sim_stabr; /* Register search specifier */ static SCHTAB sim_staba; /* Memory search specifier */ static const char *sim_int_step_description (DEVICE *dptr) { return "Step/Next facility"; } static UNIT sim_step_unit = { UDATA (&step_svc, UNIT_IDLE, 0) }; DEVICE sim_step_dev = { "INT-STEP", &sim_step_unit, NULL, NULL, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DEV_NOSAVE, 0, NULL, NULL, NULL, NULL, NULL, NULL, sim_int_step_description}; static const char *sim_int_runlimit_description (DEVICE *dptr) { return "Run time limit facility"; } static t_stat sim_int_runlimit_reset (DEVICE *dptr) { if (sim_runlimit_enabled) { if (sim_runlimit_switches & SWMASK ('T')) return sim_activate_after_d (dptr->units, sim_runlimit_d); else return sim_activate (dptr->units, sim_runlimit); } return SCPE_OK; } static UNIT sim_runlimit_unit = { UDATA (&runlimit_svc, UNIT_IDLE, 0) }; DEVICE sim_runlimit_dev = { "INT-RUNLIMIT", &sim_runlimit_unit, NULL, NULL, 1, 0, 0, 0, 0, 0, NULL, NULL, &sim_int_runlimit_reset, NULL, NULL, NULL, NULL, DEV_NOSAVE, 0, NULL, NULL, NULL, NULL, NULL, NULL, sim_int_runlimit_description}; static const char *sim_int_expect_description (DEVICE *dptr) { return "Expect facility"; } static UNIT sim_expect_unit = { UDATA (&expect_svc, 0, 0) }; DEVICE sim_expect_dev = { "INT-EXPECT", &sim_expect_unit, NULL, NULL, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DEV_NOSAVE, 0, NULL, NULL, NULL, NULL, NULL, NULL, sim_int_expect_description}; static const char *sim_int_flush_description (DEVICE *dptr) { return "Open File Flush facility"; } static uint32 sim_flush_interval = 30; /* Flush I/O buffers every 30 seconds */ static REG sim_flush_reg[] = { { DRDATAD(FLUSH_INTERVAL, sim_flush_interval, 32, "Periodic Buffer Flush Interval (seconds)") }, { NULL} }; static UNIT sim_flush_unit = { UDATA (&flush_svc, UNIT_IDLE, 0) }; DEVICE sim_flush_dev = { "INT-FLUSH", &sim_flush_unit, sim_flush_reg, NULL, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DEV_NOSAVE, 0, NULL, NULL, NULL, NULL, NULL, NULL, sim_int_flush_description}; #if defined USE_INT64 static const char *sim_si64 = "64b data"; #else static const char *sim_si64 = "32b data"; #endif #if defined USE_ADDR64 static const char *sim_sa64 = "64b addresses"; #else static const char *sim_sa64 = "32b addresses"; #endif const char *sim_savename = sim_name; /* Simulator Name used in SAVE/RESTORE images */ /* Tables and strings */ const char save_vercur[] = "V4.0"; const char save_ver40[] = "V4.0"; const char save_ver35[] = "V3.5"; const char save_ver32[] = "V3.2"; const char save_ver30[] = "V3.0"; const struct scp_error { const char *code; const char *message; } scp_errors[1+SCPE_MAX_ERR-SCPE_BASE] = {{"NXM", "Address space exceeded"}, {"UNATT", "Unit not attached"}, {"IOERR", "I/O error"}, {"CSUM", "Checksum error"}, {"FMT", "Format error"}, {"NOATT", "Unit not attachable"}, {"OPENERR", "File open error"}, {"MEM", "Memory exhausted"}, {"ARG", "Invalid argument"}, {"STEP", "Step expired"}, {"UNK", "Unknown command"}, {"RO", "Read only argument"}, {"INCOMP", "Command not completed"}, {"STOP", "Simulation stopped"}, {"EXIT", "Goodbye"}, {"TTIERR", "Console input I/O error"}, {"TTOERR", "Console output I/O error"}, {"EOF", "End of file"}, {"REL", "Relocation error"}, {"NOPARAM", "No settable parameters"}, {"ALATT", "Unit already attached"}, {"TIMER", "Hardware timer error"}, {"SIGERR", "Signal handler setup error"}, {"TTYERR", "Console terminal setup error"}, {"SUB", "Subscript out of range"}, {"NOFNC", "Command not allowed"}, {"UDIS", "Unit disabled"}, {"NORO", "Read only operation not allowed"}, {"INVSW", "Invalid switch"}, {"MISVAL", "Missing value"}, {"2FARG", "Too few arguments"}, {"2MARG", "Too many arguments"}, {"NXDEV", "Non-existent device"}, {"NXUN", "Non-existent unit"}, {"NXREG", "Non-existent register"}, {"NXPAR", "Non-existent parameter"}, {"NEST", "Nested DO command limit exceeded"}, {"IERR", "Internal error"}, {"MTRLNT", "Invalid magtape record length"}, {"LOST", "Console Telnet connection lost"}, {"TTMO", "Console Telnet connection timed out"}, {"STALL", "Console Telnet output stall"}, {"AFAIL", "Assertion failed"}, {"INVREM", "Invalid remote console command"}, {"EXPECT", "Expect matched"}, {"AMBREG", "Ambiguous register name"}, {"REMOTE", "remote console command"}, {"INVEXPR", "invalid expression"}, {"SIGTERM", "SIGTERM received"}, {"FSSIZE", "File System size larger than disk size"}, {"RUNTIME", "Run time limit exhausted"}, {"INCOMPDSK", "Incompatible Disk Container"}, }; const size_t size_map[] = { sizeof (int8), sizeof (int8), sizeof (int16), sizeof (int32), sizeof (int32) #if defined (USE_INT64) , sizeof (t_int64), sizeof (t_int64), sizeof (t_int64), sizeof (t_int64) #endif }; const t_value width_mask[] = { 0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF #if defined (USE_INT64) , 0x1FFFFFFFF, 0x3FFFFFFFF, 0x7FFFFFFFF, 0xFFFFFFFFF, 0x1FFFFFFFFF, 0x3FFFFFFFFF, 0x7FFFFFFFFF, 0xFFFFFFFFFF, 0x1FFFFFFFFFF, 0x3FFFFFFFFFF, 0x7FFFFFFFFFF, 0xFFFFFFFFFFF, 0x1FFFFFFFFFFF, 0x3FFFFFFFFFFF, 0x7FFFFFFFFFFF, 0xFFFFFFFFFFFF, 0x1FFFFFFFFFFFF, 0x3FFFFFFFFFFFF, 0x7FFFFFFFFFFFF, 0xFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFF, 0x3FFFFFFFFFFFFF, 0x7FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF #endif }; static char *simh_help = NULL; /* First invocation of HELP command appends the help pieces */ static const char simh_help1[] = /***************** 80 character line width template *************************/ "1Commands\n" #define HLP_RESET "*Commands Resetting Devices" /***************** 80 character line width template *************************/ "2Resetting Devices\n" " The RESET command (abbreviation RE) resets a device or the entire simulator\n" " to a predefined condition. If switch -p is specified, the device is reset\n" " to its power-up state:\n\n" "++RESET reset all devices\n" "++RESET -p powerup all devices\n" "++RESET ALL reset all devices\n" "++RESET reset specified device\n\n" " Typically, RESET stops any in-progress I/O operation, clears any interrupt\n" " request, and returns the device to a quiescent state. It does not clear\n" " main memory or affect I/O connections.\n" #define HLP_EXAMINE "*Commands Examining_and_Changing_State" #define HLP_IEXAMINE "*Commands Examining_and_Changing_State" #define HLP_DEPOSIT "*Commands Examining_and_Changing_State" #define HLP_IDEPOSIT "*Commands Examining_and_Changing_State" /***************** 80 character line width template *************************/ "2Examining and Changing State\n" " There are four commands to examine and change state:\n\n" "++EXAMINE (abbreviated E) examines state\n" "++DEPOSIT (abbreviated D) changes state\n" "++IEXAMINE (interactive examine, abbreviated IE) examines state and allows\n" "++++the user to interactively change it\n" "++IDEPOSIT (interactive deposit, abbreviated ID) allows the user to\n" "++++interactively change state\n\n" " All four commands take the form\n\n" "++command {modifiers} \n\n" " Deposit must also include a deposit value at the end of the command.\n\n" " There are four kinds of modifiers: switches, device/unit name, search\n" " specifier, and for EXAMINE, output file. Switches have been described\n" " previously. A device/unit name identifies the device and unit whose\n" " address space is to be examined or modified. If no device is specified,\n" " the CPU (main memory)is selected; if a device but no unit is specified,\n" " unit 0 of the device is selected.\n\n" " The search specifier provides criteria for testing addresses or registers\n" " to see if they should be processed. A specifier consists of a logical\n" " operator, a relational operator, or both, optionally separated by spaces.\n\n" "++{ } \n\n" /***************** 80 character line width template *************************/ " where the logical operator is & (and), | (or), or ^ (exclusive or), and the\n" " relational operator is = or == (equal), ! or != (not equal), >= (greater\n" " than or equal), > (greater than), <= (less than or equal), or < (less than).\n" " If a logical operator is specified without a relational operator, it is\n" " ignored. If a relational operator is specified without a logical operator,\n" " no logical operation is performed. All comparisons are unsigned.\n\n" " The output file modifier redirects command output to a file instead of the\n" " console. An output file modifier consists of @ followed by a valid file\n" " name.\n\n" " Modifiers may be specified in any order. If multiple modifiers of the\n" " same type are specified, later modifiers override earlier modifiers. Note\n" " that if the device/unit name comes after the search specifier, the search\n" " values will interpreted in the radix of the CPU, rather than of the\n" " device/unit.\n\n" " The \"object list\" consists of one or more of the following, separated by\n" " commas:\n\n" /***************** 80 character line width template *************************/ "++register the specified register\n" "++register[sub1-sub2] the specified register array locations,\n" "++++++++ starting at location sub1 up to and\n" "++++++++ including location sub2\n" "++register[sub1/length] the specified register array locations,\n" "++++++++ starting at location sub1 up to but\n" "++++++++ not including sub1+length\n" "++register[ALL] all locations in the specified register\n" "++++++++ array\n" "++register1-register2 all the registers starting at register1\n" "++++++++ up to and including register2\n" "++address the specified location\n" "++address1-address2 all locations starting at address1 up to\n" "++++++++ and including address2\n" "++address/length all location starting at address up to\n" "++++++++ but not including address+length\n" "++STATE all registers in the device\n" "++ALL all locations in the unit\n" "++$ the last value displayed by an EXAMINE\n" "++++++++ command interpreted as an address\n" "3Switches\n" " Switches can be used to control the format of display information:\n\n" /***************** 80 character line width template *************************/ "++-a display as ASCII\n" "++-c display as character string\n" "++-m display as instruction mnemonics\n" "++-o or -8 display as octal\n" "++-d or -10 display as decimal\n" "++-h or -16 display as hexadecimal\n" "++-2 display as binary\n\n" " The simulators typically accept symbolic input (see documentation with each\n" " simulator).\n\n" "3Examples\n" " Examples:\n\n" "++ex 1000-1100 examine 1000 to 1100\n" "++de PC 1040 set PC to 1040\n" "++ie 40-50 interactively examine 40:50\n" "++ie >1000 40-50 interactively examine the subset\n" "+++++++++ of locations 40:50 that are >1000\n" "++ex rx0 50060 examine 50060, RX unit 0\n" "++ex rx sbuf[3-6] examine SBUF[3] to SBUF[6] in RX\n" "++de all 0 set main memory to 0\n" "++de &77>0 0 set all addresses whose low order\n" "+++++++++ bits are non-zero to 0\n" "++ex -m @memdump.txt 0-7777 dump memory to file\n\n" " Note: to terminate an interactive command, simply type a bad value\n" " (eg, XYZ) when input is requested.\n" #define HLP_EVALUATE "*Commands Evaluating_Instructions" /***************** 80 character line width template *************************/ "2Evaluating Instructions\n" " The EVAL command evaluates a symbolic instruction and returns the equivalent\n" " numeric value. This is useful for obtaining numeric arguments for a search\n" " command:\n\n" "++EVAL \n\n" " Examples:\n\n" "+On the VAX simulator:\n" "++sim> eval addl2 r2,r3\n" "++0: 005352C0\n" "++sim> eval addl2 #ff,6(r0)\n" "++0: 00FF8FC0\n" "++4: 06A00000\n" "++sim> eval 'AB\n" "++0: 00004241\n\n" "+On the PDP-8:\n" "++sim> eval tad 60\n" "++0: 1060\n" "++sim> eval tad 300\n" "++tad 300\n" "++Can't be parsed as an instruction or data\n\n" " 'tad 300' fails, because with an implicit PC of 0, location 300 can't be\n" " reached with direct addressing.\n" /***************** 80 character line width template *************************/ "2Loading and Saving Programs\n" #define HLP_LOAD "*Commands Loading_and_Saving_Programs LOAD" "3LOAD\n" " The LOAD command (abbreviation LO) loads a file in binary loader format:\n\n" "++LOAD {implementation options}\n\n" " The types of formats supported are implementation specific. Options (such\n" " as load within range) are also implementation specific.\n\n" #define HLP_DUMP "*Commands Loading_and_Saving_Programs DUMP" "3DUMP\n" " The DUMP command (abbreviation DU) dumps memory in binary loader format:\n\n" "++DUMP {implementation options}\n\n" " The types of formats supported are implementation specific. Options (such\n" " as dump within range) are also implementation specific.\n" /***************** 80 character line width template *************************/ "2Saving and Restoring State\n" #define HLP_SAVE "*Commands Saving_and_Restoring_State SAVE" "3SAVE\n" " The SAVE command (abbreviation SA) save the complete state of the simulator\n" " to a file. This includes the contents of main memory and all registers,\n" " and the I/O connections of devices:\n\n" "++SAVE \n\n" #define HLP_RESTORE "*Commands Saving_and_Restoring_State RESTORE" "3RESTORE\n" " The RESTORE command (abbreviation REST, alternately GET) restores a\n" " previously saved simulator state:\n\n" "++RESTORE \n" "4Switches\n" " Switches can influence the output and behavior of the RESTORE command\n\n" "++-Q Suppresses version warning messages\n" "++-D Suppress detaching and attaching devices during a restore\n" "++-F Overrides the related file timestamp validation check\n" "\n" "4Notes:\n" " 1) SAVE file format compresses zeroes to minimize file size.\n" " 2) The simulator can't restore active incoming telnet sessions to\n" " multiplexer devices, but the listening ports will be restored across a\n" " save/restore.\n" /***************** 80 character line width template *************************/ "2Running A Simulated Program\n" #define HLP_RUN "*Commands Running_A_Simulated_Program RUN" "3RUN {start_pc_addr} {UNTIL stop_pc_addr|\"output-string\"}\n" " The RUN command (abbreviated RU) resets all devices, deposits its argument\n" " (if given) in the PC, and starts execution. If no argument is given,\n" " execution starts at the current PC.\n\n" " The optional UNTIL argument specifies a stop criteria for execution.\n" " There are two forms of execution stop criteria:\n" "+1. A temporary breakpoint (which exists only until it is encountered).\n" "+2. A string which will stop execution when the simulator has output\n" "++the indicated string.\n" #define HLP_GO "*Commands Running_A_Simulated_Program GO" "3GO {start_pc_addr} {UNTIL stop_pc_addr|\"output-string\"}\n" " The GO command does not reset devices, deposits its argument (if given)\n" " in the PC, and starts execution. If no argument is given, execution\n" " starts at the current PC.\n\n" " The optional UNTIL argument specifies a stop criteria for execution.\n" " There are two forms of execution stop criteria:\n" "+1. A temporary breakpoint (which exists only until it is encountered).\n" "+2. A string which will stop execution when the simulator has output\n" "++the indicated string.\n" #define HLP_CONTINUE "*Commands Running_A_Simulated_Program CONTINUE" "3CONTINUE\n" " The CONT command (abbreviated CO) does not reset devices and resumes\n" " execution at the current PC.\n" #define HLP_STEP "*Commands Running_A_Simulated_Program STEP" "3STEP\n" " The STEP command (abbreviated S) resumes execution at the current PC for\n" " the number of %Is given by its argument. If no argument is\n" " supplied, one %I is executed.\n" "4Switches\n" " If the STEP command is invoked with the -T switch, the step command will\n" " cause execution to run for microseconds rather than %I.\n" #define HLP_NEXT "*Commands Running_A_Simulated_Program NEXT" "3NEXT\n" " The NEXT command (abbreviated N) resumes execution at the current PC for\n" " one instruction, attempting to execute through a subroutine calls.\n" " If the next instruction to be executed is not a subroutine call,\n" " one instruction is executed.\n" #define HLP_BOOT "*Commands Running_A_Simulated_Program BOOT" "3BOOT\n" " The BOOT command (abbreviated BO) resets all devices and bootstraps the\n" " device and unit given by its argument. If no unit is supplied, unit 0 is\n" " bootstrapped. The specified unit must be attached.\n" /***************** 80 character line width template *************************/ "2Stopping The Simulator\n" " Programs run until the simulator detects an error or stop condition, or\n" " until the user forces a stop condition.\n" "3Simulator Detected Stop Conditions\n" " These simulator-detected conditions stop simulation:\n\n" "++- HALT instruction. If a HALT instruction is decoded, simulation stops.\n" "++- Breakpoint. The simulator may support breakpoints (see below).\n" "++- I/O error. If an I/O error occurs during simulation of an I/O\n" "+++operation, and the device stop-on-I/O-error flag is set, simulation\n" "+++usually stops.\n\n" "++- Processor condition. Certain processor conditions can stop\n" "+++simulation; these are described with the individual simulators.\n" "3User Specified Stop Conditions\n" " Typing the interrupt character stops simulation. The interrupt character\n" " is defined by the WRU (where are you) console option and is initially set\n" " to 005 (^E).\n\n" /***************** 80 character line width template *************************/ #define HLP_BREAK "*Commands Stopping_The_Simulator User_Specified_Stop_Conditions BREAK" #define HLP_NOBREAK "*Commands Stopping_The_Simulator User_Specified_Stop_Conditions BREAK" "4Breakpoints\n" " A simulator may offer breakpoint capability. A simulator may define\n" " breakpoints of different types, identified by letter (for example, E for\n" " execution, R for read, W for write, etc). At the moment, most simulators\n" " support only E (execution) breakpoints.\n\n" " Associated with a breakpoint are a count and, optionally, one or more\n" " actions. Each time the breakpoint is taken, the associated count is\n" " decremented. If the resulting count is less than or equal to 0, the\n" " breakpoint occurs; otherwise, it is deferred. When the breakpoint occurs,\n" " the optional actions are automatically executed.\n\n" " A breakpoint is set by the BREAK or the SET BREAK commands:\n\n" "++BREAK {-types} {{[count]},{addr range...}}{;action;action...}\n" "++SET BREAK {-types} {{[count]},{addr range...}}{;action;action...}\n\n" " If no type is specified, the simulator-specific default breakpoint type\n" " (usually E for execution) is used. If no address range is specified, the\n" " current PC is used. As with EXAMINE and DEPOSIT, an address range may be a\n" " single address, a range of addresses low-high, or a relative range of\n" " address/length.\n" /***************** 80 character line width template *************************/ "5Displaying Breakpoints\n" " Currently set breakpoints can be displayed with the SHOW BREAK command:\n\n" "++SHOW {-C} {-types} BREAK {ALL|{,...}}\n\n" " Locations with breakpoints of the specified type are displayed.\n\n" " The -C switch displays the selected breakpoint(s) formatted as commands\n" " which may be subsequently used to establish the same breakpoint(s).\n\n" "5Removing Breakpoints\n" " Breakpoints can be cleared by the NOBREAK or the SET NOBREAK commands.\n" "5Examples\n" "++BREAK set E break at current PC\n" "++BREAK -e 200 set E break at 200\n" "++BREAK 2000/2[2] set E breaks at 2000,2001 with count = 2\n" "++BREAK 100;EX AC;D MQ 0 set E break at 100 with actions EX AC and\n" "+++++++++D MQ 0\n" "++BREAK 100; delete action on break at 100\n\n" /***************** 80 character line width template *************************/ #define HLP_DEBUG "*Commands Stopping_The_Simulator User_Specified_Stop_Conditions DEBUG" #define HLP_NODEBUG "*Commands Stopping_The_Simulator User_Specified_Stop_Conditions DEBUG" "4Debug\n" " The DEBUG snd NODEBUG commands are aliases for the \"SET DEBUG\" and\n" " \"SET NODEBUG\" commands. Additionally, support is provided that is\n" " equivalent to the \"SET DEBUG=opt1{;opt2}\" and\n" " \"SET NODEBUG=opt1{;opt2}\" commands.\n\n" #define HLP_RUNLIMIT "*Commands Stopping_The_Simulator User_Specified_Stop_Conditions RUNLIMIT" "4RUNLIMIT\n" " A simulator user may want to limit the maximum execution time that a\n" " simulator may run for. This might be appropriate to limit a runaway\n" " diagnostic which didn't achieve explicit success or failure within\n" " some user specified time. The RUNLIMIT command provides ways to\n" " limit execution.\n\n" "++RUNLIMIT n {%C|MICROSECONDS|SECONDS|MINUTES|HOURS}\n" "++NORUNLIMIT\n\n" " Equivalently:\n\n" "++SET RUNLIMIT n {%C|MICROSECONDS|SECONDS|MINUTES|HOURS}\n" "++SET NORUNLIMIT\n\n" " The run limit state can be examined with:\n\n" "++SHOW RUNLIMIT\n\n" " If the units of the run limit are not specified, the default units are\n" " %C. Once an execution run limit has been reached, any subsequent\n" " GO, RUN, CONTINUE, STEP or BOOT commands will cause the simulator to\n" " exit. A previously defined RUNLIMIT can be cleared with the NORUNLIMIT\n" " command or the establishment of a new run limit.\n" /***************** 80 character line width template *************************/ "2Connecting and Disconnecting Devices\n" " Except for main memory and network devices, units are simulated as\n" " unstructured binary disk files in the host file system. Before using a\n" " simulated unit, the user must specify the file to be accessed by that unit.\n" #define HLP_ATTACH "*Commands Connecting_and_Disconnecting_Devices ATTACH" "3ATTACH\n" " The ATTACH (abbreviation AT) command associates a unit and a file:\n" "++ATTACH \n\n" " Some devices have more detailed or specific help available with:\n\n" "++HELP ATTACH\n\n" "4Switches\n" "5-n\n" " If the -n switch is specified when an attach is executed, a new file is\n" " created, and an appropriate message is printed.\n" "5-e\n" " If the file does not exist, and the -e switch was not specified, a new\n" " file is created, and an appropriate message is printed. If the -e switch\n" " was specified, a new file is not created, and an error message is printed.\n" "5-r\n" " If the -r switch is specified, or the file is write protected, ATTACH tries\n" " to open the file read only. If the file does not exist, or the unit does\n" " not support read only operation, an error occurs. Input-only devices, such\n" " as paper-tape readers, and devices with write lock switches, such as disks\n" " and tapes, support read only operation; other devices do not. If a file is\n" " attached read only, its contents can be examined but not modified.\n" "5-a\n" " If the -a switch is specified, and the device being attached is a\n" " sequential output only device (like a line printer, paper tape punch,\n" " etc.), the file being attached will be opened for write and positioned\n" " at the end of the file's current contents, thus adding to any existing\n" " file data beyond what may have already been there.\n" "5-q\n" " If the -q switch is specified when creating a new file (-n) or opening one\n" " read only (-r), any messages announcing these facts will be suppressed.\n" "5-f\n" " For simulated magnetic tapes, the ATTACH command can specify the format of\n" " the attached tape image file:\n\n" "++ATTACH -f \n\n" " The currently supported tape image file formats are:\n\n" "++SIMH SIMH simulator format\n" "++E11 E11 simulator format\n" "++TPC TPC format\n" "++P7B Pierce simulator 7-track format\n\n" /***************** 80 character line width template *************************/ " For some simulated disk devices, the ATTACH command can specify the format\n" " of the attached disk image file:\n\n" "++ATTACH -f \n\n" " The currently supported disk image file formats are:\n\n" "++SIMH SIMH simulator format\n" "++VHD Virtual Disk format\n" "++RAW platform specific access to physical disk or\n" "++ CDROM drives\n" " The disk format can also be set with the SET command prior to ATTACH:\n\n" "++SET FORMAT=\n" "++ATT \n\n" /***************** 80 character line width template *************************/ " The format of an attached tape or disk file can be displayed with the SHOW\n" " command:\n" "++SHOW FORMAT\n" " For Telnet-based terminal emulation devices, the ATTACH command associates\n" " the master unit with a TCP/IP listening port:\n\n" "++ATTACH \n\n" " The port is a decimal number between 1 and 65535 that is not already used\n" " other TCP/IP applications.\n" " For Ethernet emulators, the ATTACH command associates the simulated Ethernet\n" " with a physical Ethernet device:\n\n" "++ATTACH \n" /***************** 80 character line width template *************************/ #define HLP_DETACH "*Commands Connecting_and_Disconnecting_Devices DETACH" "3DETACH\n" " The DETACH (abbreviation DET) command breaks the association between a unit\n" " and a file, port, or network device:\n\n" "++DETACH ALL detach all units\n" "++DETACH detach specified unit\n" " The EXIT command performs an automatic DETACH ALL.\n" "2Controlling Simulator Operating Environment\n" "3Working Directory\n" #define HLP_CD "*Commands Controlling_Simulator_Operating_Environment Working_Directory CD" "4CD\n" " Set the current working directory:\n" "++CD path\n" "4SET_DEFAULT\n" " Set the current working directory:\n" "++SET DEFAULT path\n" #define HLP_PWD "*Commands Controlling_Simulator_Operating_Environment Working_Directory PWD" "4PWD\n" "++PWD\n" " Display the current working directory:\n" "2Listing Files\n" #define HLP_DIR "*Commands Listing_Files DIR" "3DIR\n" "++DIR {path} list directory files\n" #define HLP_LS "*Commands Listing_Files LS" "3LS\n" "++LS {path} list directory files\n" "2Displaying Files\n" #define HLP_TYPE "*Commands Displaying_Files TYPE" "3TYPE\n" "++TYPE file display a file contents\n" "4Switches\n" " The -O switch start displaying file contents at the specified\n" " file offset.\n\n" " The -N switch will display up to a specified number of lines\n" " from the file.\n\n" "++TYPE -{O}{N} {offset} {lines} file\n\n" #define HLP_CAT "*Commands Displaying_Files CAT" "3CAT\n" "++CAT file display a file contents\n" "4Switches\n" " The -O switch start displaying file contents at the specified\n" " file offset.\n\n" " The -N switch will display up to a specified number of lines\n" " from the file.\n\n" "++TYPE -{O}{N} {offset} {lines} file\n\n" "2Removing Files\n" #define HLP_DELETE "*Commands Removing_Files DEL" "3DELETE\n" "++DEL{ete} file deletes a file\n" "4Switches\n" " The -Q switch will suppress file not found warning messages\n\n" #define HLP_RM "*Commands Removing_Files RM" "3RM\n" "++RM file deletes a file\n" "4Switches\n" " The -Q switch will suppress file not found warning messages\n\n" "2Copying Files\n" #define HLP_COPY "*Commands Copying_Files COPY" "3COPY\n" "++COPY sfile dfile copies a file\n" #define HLP_CP "*Commands Copying_Files CP" "3CP\n" "++CP sfile dfile copies a file\n" "2Renaming Files\n" #define HLP_RENAME "*Commands Renaming_Files RENAME" "3RENAME\n" "++RENAME origname newname renames a file\n" #define HLP_MOVE "*Commands Renaming_Files MOVE" "3MOVE\n" "++MOVE origname newname renames a file\n" "+or\n" "++MV origname newname renames a file\n" "2Creating Directories\n" #define HLP_MKDIR "*Commands Creating_Directories MKDIR" "3MKDIR\n" "++MKDIR path creates a directory\n" "2Deleting Directories\n" #define HLP_RMDIR "*Commands Deleting_Directories RMDIR" "3RMDIR\n" "++RMDIR path deleting a directory\n" #define HLP_SET "*Commands SET" "2SET\n" /***************** 80 character line width template *************************/ #define HLP_SET_CONSOLE "*Commands SET CONSOLE" "3Console\n" "+SET CONSOLE arg{,arg...} set console options\n" "+SET CONSOLE WRU=value specify console drop to simh character\n" "+SET CONSOLE BRK=value specify console Break character\n" "+SET CONSOLE DEL=value specify console delete character\n" #if (defined(__GNUC__) && !defined(__OPTIMIZE__) && !defined(_WIN32))/* Debug build? */ "+SET CONSOLE DBGINT=value specify SIGINT character in debugger\n" #endif "+SET CONSOLE PCHAR=bitmask bit mask of printable characters in\n" "++++++++ range [31,0]\n" "+SET CONSOLE SPEED=speed{*factor}\n" "++++++++ specify console input data rate\n" "+SET CONSOLE TELNET=port specify console telnet port\n" "+SET CONSOLE TELNET=LOG=log_file\n" "++++++++ specify console telnet logging to the\n" "++++++++ specified destination {LOG,STDOUT,STDERR,\n" "++++++++ DEBUG or filename)\n" "+SET CONSOLE TELNET=NOLOG disables console telnet logging\n" "+SET CONSOLE TELNET=BUFFERED[=bufsize]\n" "++++++++ specify console telnet buffering\n" "+SET CONSOLE TELNET=NOBUFFERED\n" "++++++++ disables console telnet buffering\n" "+SET CONSOLE TELNET=UNBUFFERED\n" "++++++++ disables console telnet buffering\n" "+SET CONSOLE NOTELNET disable console telnet\n" "+SET CONSOLE SERIAL=serialport[;config]\n" "++++++++ specify console serial port and optionally\n" "++++++++ the port config (i.e. ;9600-8n1)\n" "+SET CONSOLE NOSERIAL disable console serial session\n" /***************** 80 character line width template *************************/ #define HLP_SET_REMOTE "*Commands SET REMOTE" "3Remote\n" "+SET REMOTE TELNET=port specify remote console telnet port\n" "+SET REMOTE NOTELNET disables remote console\n" "+SET REMOTE BUFFERSIZE=bufsize\n" "++++++++ specify remote console command output buffer\n" "++++++++ size\n" "+SET REMOTE CONNECTIONS=n specify number of concurrent remote\n" "++++++++ console sessions\n" "+SET REMOTE TIMEOUT=n specify number of seconds without input\n" "++++++++ before automatic continue\n" "+SET REMOTE MASTER enable master mode remote console\n" "+SET REMOTE NOMASTER disable remote master mode console\n" #define HLP_SET_DEFAULT "*Commands SET Working_Directory" "3Working Directory\n" "+SET DEFAULT set the current directory\n" "+CD set the current directory\n" #define HLP_SET_LOG "*Commands SET Log" "3Log\n" " Interactions with the simulator session (at the \"sim>\" prompt\n" " can be recorded to a log file\n\n" "+SET LOG log_file specify the log destination\n" "++++++++ (STDOUT,DEBUG or filename)\n" "+SET NOLOG disables any currently active logging\n" "4Switches\n" " By default, log output is written at the end of the specified log file.\n" " A new log file can created if the -N switch is used on the command line.\n\n" " By default, log output is written in text mode. The log file can be\n" " opened for binary mode writing if the -B switch is used on the command line.\n" #define HLP_SET_DEBUG "*Commands SET Debug" /***************** 80 character line width template *************************/ "3Debug\n" "+SET DEBUG debug_file specify the debug destination\n" "++++++++ (STDOUT,STDERR,LOG or filename)\n" "+SET NODEBUG disables any currently active debug output\n" "4Switches\n" " Debug message output contains a timestamp which indicates the number of\n" " simulated %C which have been executed prior to the debug event.\n\n" " Debug message output can be enhanced to contain additional, potentially\n" " useful information.\n" "5-T\n" " The -T switch causes debug output to contain a time of day displayed\n" " as hh:mm:ss.msec.\n" "5-A\n" " The -A switch causes debug output to contain a time of day displayed\n" " as seconds.msec.\n" "5-R\n" " The -R switch causes the time of day displayed due to the -T or -A\n" " switches to be relative to the start time of debugging. If neither\n" " -T or -A is explicitly specified, -T is implied.\n" "5-P\n" " The -P switch adds the output of the PC (Program Counter) to each debug\n" " message.\n" "5-N\n" " The -N switch causes a new/empty file to be written to. The default\n" " is to append to an existing debug log file.\n" "5-D\n" " The -D switch causes data blob output to also display the data as\n" " RADIX-50 characters.\n" "5-F\n" " The -F switch causes duplicate successive lines of debug NOT to be\n" " summarized to reduce repetative noise from the debug data stream.\n" "5-E\n" " The -E switch causes data blob output to also display the data as\n" " EBCDIC characters.\n" "5-B\n" " The -B switch causes debug data output to be written to a circular\n" " buffer in memory. This avoids the potential delays for disk I/O to\n" " and the disk storage that a long running debug might consume.\n" " The size of the circular memory buffer that is used is specified on\n" " the SET DEBUG command line, for example:\n\n" "++SET DEBUG -B \n\n" #define HLP_SET_BREAK "*Commands SET Breakpoints" "3Breakpoints\n" "+SET BREAK set breakpoints\n" "+SET NOBREAK clear breakpoints\n" /***************** 80 character line width template *************************/ #define HLP_SET_THROTTLE "*Commands SET Throttle" "3Throttle\n" " Simulator instruction execution rate can be controlled by specifying\n" " one of the following throttle commands:\n\n" "+SET THROTTLE xM execute x million %C per second\n" "+SET THROTTLE xK execute x thousand %C per second\n" "+SET THROTTLE x%% occupy x percent of the host capacity\n" "++++++++executing instructions\n" "+SET THROTTLE x/t sleep for t milliseconds after executing x\n" "++++++++%C\n\n" "+SET NOTHROTTLE set simulation rate to maximum\n\n" " Throttling is only available on host systems that implement a precision\n" " real-time delay function.\n\n" " xM, xK and x%% modes require the simulator to execute sufficient\n" " %C to actually calibrate the desired execution rate relative\n" " to wall clock time. Very short running programs may complete before\n" " calibration completes and therefore before the simulated execution rate\n" " can match the desired rate.\n\n" " The SET NOTHROTTLE command turns off throttling. The SHOW THROTTLE\n" " command shows the current settings for throttling and the calibration\n" " results\n\n" " Some simulators implement a different form of host CPU resource management\n" " called idling. Idling suspends simulated execution whenever the program\n" " running in the simulator is doing nothing, and runs the simulator at full\n" " speed when there is work to do. Throttling and idling are mutually\n" " exclusive.\n" #define HLP_SET_CLOCK "*Commands SET Clock" "3Clock\n" #if defined (SIM_ASYNCH_CLOCKS) "+SET CLOCK asynch enable asynchronous clocks\n" "+SET CLOCK noasynch disable asynchronous clocks\n" #endif "+SET CLOCK nocatchup disable catchup clock ticks\n" "+SET CLOCK catchup enable catchup clock ticks\n" "+SET CLOCK calib=n%% specify idle calibration skip %%\n" "+SET CLOCK calib=ALWAYS specify calibration independent of idle\n" "+SET CLOCK stop=n stop execution after n %C\n\n" " The SET CLOCK STOP command allows execution to have a bound when\n" " execution starts with a BOOT, NEXT or CONTINUE command.\n" #define HLP_SET_ASYNCH "*Commands SET Asynch" "3Asynch\n" "+SET ASYNCH enable asynchronous I/O\n" "+SET NOASYNCH disable asynchronous I/O\n" #define HLP_SET_ENVIRON "*Commands SET Environment" "3Environment\n" "4Explicitily Changing a Variable\n" "+SET ENVIRONMENT name=val set environment variable\n" "+SET ENVIRONMENT name clear environment variable\n" "4Arithmetic Computations into a Variable\n\n" "+SET ENVIRONMENT -A name=expression\n\n" " Expression can contain any of these C language operators:\n\n" "++ ( Open Parenthesis\n" "++ ) Close Parenthesis\n" "++ - Subtraction\n" "++ + Addition\n" "++ * Multiplication\n" "++ / Division\n" "++ %% Modulus\n" "++ && Logical AND\n" "++ || Logical OR\n" "++ & Bitwise AND\n" "++ | Bitwise Inclusive OR\n" "++ ^ Bitwise Exclusive OR\n" "++ >> Bitwise Right Shift\n" "++ << Bitwise Left Shift\n" "++ == Equality\n" "++ != Inequality\n" "++ <= Less than or Equal\n" "++ < Less than\n" "++ >= Greater than or Equal\n" "++ > Greater than\n" "++ ! Logical Negation\n" "++ ~ Bitwise Compliment\n\n" " Operator precedence is consistent with C language precedence.\n\n" " Expression can contain arbitrary combinations of constant\n" " values, simulator registers and environment variables \n" "5Examples:\n" "++SET ENV -A A=7+2\n" "++SET ENV -A A=A-1\n" "++ECHO A=%%A%%\n" "++A=8\n" "4Gathering Input From A User\n" " Input from a user can be obtained by:\n\n" "+set environment -P \"Prompt String\" name=default\n\n" " The -P switch indicates that the user should be prompted\n" " with the indicated prompt string and the input provided\n" " will be saved in the environment variable 'name'. If no\n" " input is provided, the value specified as 'default' will be\n" " used.\n" #define HLP_SET_ON "*Commands SET Command_Status_Trap_Dispatching" "3Command Status Trap Dispatching\n" "+SET ON enables error checking after command\n" "++++++++ execution\n" "+SET NOON disables error checking after command\n" "++++++++ execution\n" "+SET ON INHERIT enables inheritance of ON state and\n" "++++++++ actions into do command files\n" "+SET ON NOINHERIT disables inheritance of ON state and\n" "++++++++ actions into do command files\n" #define HLP_SET_VERIFY "*Commands SET Command_Execution_Display" #define HLP_SET_VERIFY "*Commands SET Command_Execution_Display" "3Command Execution Display\n" "+SET VERIFY re-enables display of command file\n" "++++++++ processed commands\n" "+SET VERBOSE re-enables display of command file\n" "++++++++ processed commands\n" "+SET NOVERIFY disables display of command file processed\n" "++++++++ commands\n" "+SET NOVERBOSE disables display of command file processed\n" "++++++++ commands\n" #define HLP_SET_MESSAGE "*Commands SET Command_Error_Status_Display" "3Command Error Status Display\n" "+SET MESSAGE re-enables display of command file error\n" "++++++++ messages\n" "+SET NOMESSAGE disables display of command file error\n" "++++++++ messages\n" #define HLP_SET_QUIET "*Commands SET Command_Output_Display" "3Command Output Display\n" "+SET QUIET disables suppression of some output and\n" "++++++++ messages\n" "+SET NOQUIET re-enables suppression of some output and\n" "++++++++ messages\n" #define HLP_SET_PROMPT "*Commands SET Command_Prompt" "3Command Prompt\n" "+SET PROMPT \"string\" sets an alternate simulator prompt string\n" "3Device and Unit\n" "+SET OCT|DEC|HEX|BIN set device display radix\n" "+SET ENABLED enable device\n" "+SET DISABLED disable device\n" "+SET DEBUG{=arg} set device debug flags\n" "+SET NODEBUG={arg} clear device debug flags\n" "+SET arg{,arg...} set device parameters (see show modifiers)\n" "+SET ENABLED enable unit\n" "+SET DISABLED disable unit\n" "+SET arg{,arg...} set unit parameters (see show modifiers)\n" "+HELP SET displays the device specific set commands\n" "++++++++ available\n" #define HLP_NOAUTOSIZE "*Commands SET NoAutosize" "3NoAutosize\n" "+SET NOAUTOSIZE disables disk autosizing for all disks\n"; static const char simh_help2[] = /***************** 80 character line width template *************************/ #define HLP_SHOW "*Commands SHOW" "2SHOW\n" "+sh{ow} {-c} br{eak} show breakpoints\n" "+sh{ow} con{figuration} show configuration\n" "+sh{ow} cons{ole} {arg} show console options\n" "+sh{ow} {-ei} dev{ices} show devices\n" "+sh{ow} fea{tures} show system devices with descriptions\n" "+sh{ow} m{odifiers} show modifiers for all devices\n" "+sh{ow} s{how} show SHOW commands for all devices\n" "+sh{ow} n{ames} show logical names\n" "+sh{ow} q{ueue} show event queue\n" "+sh{ow} ti{me} show simulated time\n" "+sh{ow} th{rottle} show simulation rate\n" "+sh{ow} a{synch} show asynchronous I/O state\n" "+sh{ow} ve{rsion} show simulator version\n" "+sh{ow} def{ault} show current directory\n" "+sh{ow} re{mote} show remote console configuration\n" "+sh{ow} RADIX show device display radix\n" "+sh{ow} DEBUG show device debug flags\n" "+sh{ow} MODIFIERS show device modifiers\n" "+sh{ow} NAMES show device logical name\n" "+sh{ow} SHOW show device SHOW commands\n" "+sh{ow} {arg,...} show device parameters\n" "+sh{ow} {arg,...} show unit parameters\n" "+sh{ow} ethernet show ethernet devices\n" "+sh{ow} serial show serial devices\n" "+sh{ow} synchronous show DDCMP synchronous interface devices\n" "+sh{ow} multiplexer {dev} show open multiplexer device info\n" "+sh{ow} video show video capabilities\n" "+sh{ow} clocks show calibrated timer information\n" "+sh{ow} throttle show throttle info\n" "+sh{ow} on show on condition actions\n" "+sh{ow} do show do nesting state\n" "+sh{ow} runlimit show execution limit states\n" "+h{elp} show displays the device specific show commands\n" "++++++++ available\n" #define HLP_SHOW_CONFIG "*Commands SHOW" #define HLP_SHOW_DEVICES "*Commands SHOW" #define HLP_SHOW_FEATURES "*Commands SHOW" #define HLP_SHOW_QUEUE "*Commands SHOW" #define HLP_SHOW_TIME "*Commands SHOW" #define HLP_SHOW_MODIFIERS "*Commands SHOW" #define HLP_SHOW_NAMES "*Commands SHOW" #define HLP_SHOW_SHOW "*Commands SHOW" #define HLP_SHOW_VERSION "*Commands SHOW" #define HLP_SHOW_DEFAULT "*Commands SHOW" #define HLP_SHOW_CONSOLE "*Commands SHOW" #define HLP_SHOW_REMOTE "*Commands SHOW" #define HLP_SHOW_BREAK "*Commands SHOW" #define HLP_SHOW_LOG "*Commands SHOW" #define HLP_SHOW_DEBUG "*Commands SHOW" #define HLP_SHOW_THROTTLE "*Commands SHOW" #define HLP_SHOW_ASYNCH "*Commands SHOW" #define HLP_SHOW_ETHERNET "*Commands SHOW" #define HLP_SHOW_SERIAL "*Commands SHOW" #define HLP_SHOW_SYNC "*Commands SHOW" #define HLP_SHOW_MULTIPLEXER "*Commands SHOW" #define HLP_SHOW_VIDEO "*Commands SHOW" #define HLP_SHOW_CLOCKS "*Commands SHOW" #define HLP_SHOW_ON "*Commands SHOW" #define HLP_SHOW_DO "*Commands SHOW" #define HLP_SHOW_RUNLIMIT "*Commands SHOW" #define HLP_SHOW_SEND "*Commands SHOW" #define HLP_SHOW_EXPECT "*Commands SHOW" #define HLP_HELP "*Commands HELP" /***************** 80 character line width template *************************/ "2HELP\n" "+h{elp} type this message\n" "+h{elp} type help for command\n" "+h{elp} type help for device\n" "+h{elp} registers type help for device register variables\n" "+h{elp} attach type help for device specific ATTACH command\n" "+h{elp} set type help for device specific SET commands\n" "+h{elp} show type help for device specific SHOW commands\n" "+h{elp} type help for device specific command\n" /***************** 80 character line width template *************************/ "2Altering The Simulated Configuration\n" " In most simulators, the SET DISABLED command removes the\n" " specified device from the configuration. A DISABLED device is invisible\n" " to running programs. The device can still be RESET, but it cannot be\n" " ATTAChed, DETACHed, or BOOTed. SET ENABLED restores a disabled\n" " device to a configuration.\n\n" " Most multi-unit devices allow units to be enabled or disabled:\n\n" "++SET ENABLED\n" "++SET DISABLED\n\n" " When a unit is disabled, it will not be displayed by SHOW DEVICE.\n\n" #define HLP_ASSIGN "*Commands Logical_Names" #define HLP_DEASSIGN "*Commands Logical_Names" "2Logical Names\n" " The standard device names can be supplemented with logical names. Logical\n" " names must be unique within a simulator (that is, they cannot be the same\n" " as an existing device name). To assign a logical name to a device:\n\n" "++ASSIGN assign log-name to device\n\n" " To remove a logical name:\n\n" "++DEASSIGN remove logical name\n\n" " To show the current logical name assignment:\n\n" "++SHOW NAMES show logical name, if any\n\n" " To show all logical names:\n\n" "++SHOW NAMES\n\n" /***************** 80 character line width template *************************/ #define HLP_DO "*Commands Executing_Command_Files" "2Executing Command Files\n" " The simulator can execute command files with the DO command:\n\n" "++DO {arguments...} execute commands in file\n\n" " The DO command allows command files to contain substitutable arguments.\n" " The string %%n, where n is between 1 and 9, is replaced with argument n\n" " from the DO command line. The string %%0 is replaced with .\n" " The string %%* is replaced by the whole set of arguments (%%1 ... %%9).\n" " The sequences \\%% and \\\\ are replaced with the literal characters %% and \\,\n" " respectively. Arguments with spaces can be enclosed in matching single\n" " or double quotation marks.\n\n" " DO commands may be nested up to ten invocations deep.\n\n" "3Switches\n" " If the switch -v is specified, the commands in the file are echoed before\n" " they are executed.\n\n" " If the switch -e is specified, command processing (including nested command\n" " invocations) will be aborted if a command error is encountered.\n" " (Simulation stop never abort processing; use ASSERT to catch unexpected\n" " stops.) Without the switch, all errors except ASSERT failures will be\n" " ignored, and command processing will continue.\n\n" " If the switch -o is specified, the on conditions and actions from the\n" " calling command file will be inherited in the command file being invoked.\n" " If the switch -q is specified, the quiet mode will be explicitly enabled\n" " for the called command file, otherwise quiet mode is inherited from the\n" " calling context.\n" /***************** 80 character line width template *************************/ "3Variable_Insertion\n" " Built In variables %%DATE%%, %%TIME%%, %%DATETIME%%, %%LDATE%%, %%LTIME%%,\n" " %%CTIME%%, %%DATE_YYYY%%, %%DATE_YY%%, %%DATE_YC%%, %%DATE_MM%%, %%DATE_MMM%%,\n" " %%DATE_MONTH%%, %%DATE_DD%%, %%DATE_D%%, %%DATE_WYYYY%%, %%DATE_WW%%,\n" " %%TIME_HH%%, %%TIME_MM%%, %%TIME_SS%%, %%TIME_MSEC%%, %%STATUS%%, %%TSTATUS%%,\n" " %%SIM_VERIFY%%, %%SIM_QUIET%%, %%SIM_MESSAGE%% %%SIM_MESSAGE%%\n" " %%SIM_NAME%%, %%SIM_BIN_NAME%%, %%SIM_BIN_PATH%%m %%SIM_OSTYPE%%\n\n" "+Token %%0 expands to the command file name.\n" "+Token %%n (n being a single digit) expands to the n'th argument\n" "+Token %%* expands to the whole set of arguments (%%1 ... %%9)\n\n" "+The input sequence \"%%%%\" represents a literal \"%%\". All other\n" "+character combinations are rendered literally.\n\n" "+Omitted parameters result in null-string substitutions.\n\n" "+Tokens preceeded and followed by %% characters are expanded as environment\n" "+variables, and if an environment variable isn't found then it can be one of\n" "+several special variables:\n\n" "++%%DATE%% yyyy-mm-dd\n" "++%%TIME%% hh:mm:ss\n" "++%%DATETIME%% yyyy-mm-ddThh:mm:ss\n" "++%%LDATE%% mm/dd/yy (Locale Formatted)\n" "++%%LTIME%% hh:mm:ss am/pm (Locale Formatted)\n" "++%%CTIME%% Www Mmm dd hh:mm:ss yyyy (Locale Formatted)\n" "++%%UTIME%% nnnn (Unix time - seconds since 1/1/1970)\n" "++%%DATE_YYYY%% yyyy (0000-9999)\n" "++%%DATE_YY%% yy (00-99)\n" "++%%DATE_MM%% mm (01-12)\n" "++%%DATE_MMM%% mmm (JAN-DEC)\n" "++%%DATE_MONTH%% month (January-December)\n" "++%%DATE_DD%% dd (01-31)\n" "++%%DATE_WW%% ww (01-53) ISO 8601 week number\n" "++%%DATE_WYYYY%% yyyy (0000-9999) ISO 8601 week year number\n" "++%%DATE_D%% d (1-7) ISO 8601 day of week\n" "++%%DATE_JJJ%% jjj (001-366) day of year\n" "++%%DATE_19XX_YY%% yy A year prior to 2000 with the same\n" "++++++++++ calendar days as the current year\n" "++%%DATE_19XX_YYYY%% yyyy A year prior to 2000 with the same\n" "++++++++++ calendar days as the current year\n" "++%%TIME_HH%% hh (00-23)\n" "++%%TIME_MM%% mm (00-59)\n" "++%%TIME_SS%% ss (00-59)\n" "++%%TIME_MSEC%% msec (000-999)\n" "++%%STATUS%% Status value from the last command executed\n" "++%%TSTATUS%% The text form of the last status value\n" "++%%SIM_VERIFY%% The Verify/Verbose mode of the current Do command file\n" "++%%SIM_VERBOSE%% The Verify/Verbose mode of the current Do command file\n" "++%%SIM_QUIET%% The Quiet mode of the current Do command file\n" "++%%SIM_MESSAGE%% The message display status of the current Do command file\n" "++%%SIM_NAME%% The name of the current simulator\n" "++%%SIM_BIN_NAME%% The program name of the current simulator\n" "++%%SIM_BIN_PATH%% The program path that invoked the current simulator\n" "++%%SIM_OSTYPE%% The Operating System running the current simulator\n\n" "+Environment variable lookups are done first with the precise name between\n" "+the %% characters and if that fails, then the name between the %% characters\n" "+is upcased and a lookup of that valus is attempted.\n\n" "+The first Space delimited token on the line is extracted in uppercase and\n" "+then looked up as an environment variable. If found it the value is\n" "+supstituted for the original string before expanding everything else. If\n" "+it is not found, then the original beginning token on the line is left\n" "+untouched.\n\n" "+Environment variable string substitution:\n\n" "++%%XYZ:str1=str2%%\n\n" "+would expand the XYZ environment variable, substituting each occurrence\n" "+of \"str1\" in the expanded result with \"str2\". \"str2\" can be the empty\n" "+string to effectively delete all occurrences of \"str1\" from the expanded\n" "+output. \"str1\" can begin with an asterisk, in which case it will match\n" "+everything from the beginning of the expanded output to the first\n" "+occurrence of the remaining portion of str1.\n\n" "+May also specify substrings for an expansion.\n\n" "++%%XYZ:~10,5%%\n\n" "+would expand the XYZ environment variable, and then use only the 5\n" "+characters that begin at the 11th (offset 10) character of the expanded\n" "+result. If the length is not specified, then it defaults to the\n" "+remainder of the variable value. If either number (offset or length) is\n" "+negative, then the number used is the length of the environment variable\n" "+value added to the offset or length specified.\n\n" "++%%XYZ:~-10%%\n\n" "+would extract the last 10 characters of the XYZ variable.\n\n" "++%%XYZ:~0,-2%%\n\n" "+would extract all but the last 2 characters of the XYZ variable.\n" "4Parameter and Environment Variable File Parsing\n" " The value of environment variables can be parsed as filenames\n" " and have their values be expanded to full paths and/or into pieces.\n" " Parsing and expansion of file names.\n\n" "++%%~I%% - expands the value of %%I%% removing any surrounding quotes (\")\n" "++%%~fI%% - expands the value of %%I%% to a fully qualified path name\n" "++%%~pI%% - expands the value of %%I%% to a path only\n" "++%%~nI%% - expands the value of %%I%% to a file name only\n" "++%%~xI%% - expands the value of %%I%% to a file extension only\n\n" "++%%~tI%% - expands the value of %%I%% to date/time of file\n\n" "++%%~zI%% - expands the value of %%I%% to size of file\n\n" " The modifiers can be combined to get compound results:\n\n" "++%%~pnI%% - expands the value of %%I%% to a path and name only\n" "++%%~nxI%% - expands the value of %%I%% to a file name and extension only\n\n" " In the above example above %%I%% can be replaced by other\n" " environment variables or numeric parameters to a DO command\n" " invokation.\n" " Examples:\n\n" "++sim> set env FNAME='xyzzy.ini'\n" "++sim> echo ~FNAME=%%~FNAME%%\n" "++xyzzy.ini\n" "++sim> echo ~fFNAME=%%~fFNAME%%\n" "++~fFNAME=/home/user/xyzzy.ini\n" "++sim> echo ~nxFNAME=%%~nxFNAME%%\n" "++~nxFNAME=xyzzy.ini\n" "++sim> echo ~fFNAME=%%~pnFNAME%%\n" "++~pnFNAME=/home/user/xyzzy\n\n" #define HLP_GOTO "*Commands Executing_Command_Files GOTO" "3GOTO\n" " Commands in a command file execute in sequence until either an error\n" " trap occurs (when a command completes with an error status), or when an\n" " explict request is made to start command execution elsewhere with the\n" " GOTO command:\n\n" "++GOTO