SIMH software modifications/additions

The combination of the SIMH simulator and the console interface application was choosen because the implementation of the necessary hooks in the simulation software can easily be implemented as the SIMH source code is available.
Note that this software is not supported by the SIMH project. This means that with a new release of SIMH, you will have to do some patching yourself, or wait until I make the updates available since I will have to patch too!
For more information on the SIMH project, see   SIMH - The Computer History Simulation Project.

I tried to keep the patchwork in SIMH as minimal as possible, and the patches are only checked for the PDP-11 processor implementation in SIMH. So, if you are thinking of the HP-1000 console, things might be easy or they might be less easy.
When all operates the way it should, I will compile a document that describes the patches.
I called my project "real console", so the word "realcons" throughout the software should ring a bell ...

Short description of the files

As you can see from the SIMH version in the screenshot, I started this project a bit earlier. However, I keep track of the developments of SIMH, so the table below gives a summary of the changes you must apply to the most current release, which is indicated in the header of the table.
You can download the mentioned source files, the makefile for the PDP-11 version and the build file (based on SIMH 3.2-0) from here: real320-1.zip  (version #1, 66 kbytes). ---»  Note that this version used for the short movies on the page "Action!"
Just replace "scp.c" of SIMH in its root directory, replace "pdp11_cpu.c" in the PDP11 directory, and put the realcons.[ch] in the same (top) directory where scp.c is. To build the pdp11.exe file, the 'realcons' module must be included in the makefile. This modified makefile is also in the zip file.
Click  here  to get the latest (based on SMH 3.2.1) zip file.

The following table gives you all the details.

fileremarks   (based on SIMH 3.2.1)
  makefile
  • in the Common Libraries section add "realcons.c" to the SIM line :
    SIM = scp.c realcons.c sim_console.c sim_fio.c sim_timer.c sim_sock.c \
  • Remove all other processor related instruction lines.
  realcons.c
  realcons.h
  • new added files to implement the interface and the required definitions
 
  scp.c
  • add the following two lines after the four #include definitions
    #include "realcons.h"
    #include <stdlib.h>
  • add the following line in the Global data section
    REALCONS realcons_data;
  • add in the table static CTAB cmd_table[] after the lines
        { "RESET", &reset_cmd, 0,
            "r{eset} {ALL|}    reset simulator\n" },

    the following two lines:
        { "REALCONS", &real_cons_cmd, 0,
            "real console <COM#> {n}   connect to REAL on COM#, n*10k opcodes interval\n" },
  • add in main (int argc, char *argv[]) before the line *cbuf = 0; the line
    init_realcons_port();
  • add in main() in the while (stat != SCPE_EXIT) loop before the printf ("sim> ");     /*print prompt*/
    if ( realcons_data.source == KEYBOARD_SOURCE )
    and change the function call read_line in the line else cptr = read_line (cbuf, CBUFSIZE, stdin); to read_source
  • in the function t_stat dep_reg change the function call read_line in the line cptr = read_line (gbuf, CBUFSIZE, stdin); to read_source
  • in the function t_stat dep_addr change the function call read_line in the line cptr = read_line (gbuf, CBUFSIZE, stdin); to read_source
  • insert before the procedure t_stat run_cmd (int32 flag, char *cptr) the following procedure:
    t_stat real_cons_cmd (int32 flag, char *cptr)
    {
        code to initialize the specified REALCONS COM-port
    }
  • insert after the function void int_handler (int sig) the following function:
    void realcons_stop_cpu(void)
    {
        stop_cpu = 1;
    }
  • add in the function t_stat ex_addr in the local variables section the line
    uint16 dataword;
    and, to send data to the real console IF that is connected :
    if ( realcons_data.response == FALSE )
        {

            the original code block, but exclude the "return" statement
        }
    and add the following block plus the return statement :
    else
       {    // send output to real-console
            if (!(flag & EX_E)) return SCPE_OK;
           GET_RADIX (rdx, dptr->dradix);
            dataword = (uint16)(sim_eval[0] & 0xFFFF);
            rc_send_data(dataword);
            realcons_data.response = FALSE;
            reason = SCPE_OK;
       }
    return reason;
  • before the line r = sim_instr(); insert the line
    rc_send_fnc_sts(FSTS_RUN_LED, FSTS_LED_ON, TRUE);
  • after the line r = sim_instr(); insert the two lines
    rc_send_fnc_sts(FSTS_CONSOLE_LED, FSTS_LED_ON, TRUE);
    rc_clear_toggles();
  • In the function t_stat run_cmd (int32 flag, char *cptr)
    change the line if (flag == RU_BOOT) {
    into the line
    if ( (flag == RU_BOOT) && (realcons_data.halt_active == FALSE) ) {
    and change the line
    if ((flag == RU_RUN) || (flag == RU_BOOT)) {
    into the line
    if ((flag == RU_RUN) ||
        ((flag == RU_BOOT) && (realcons_data.halt_active == FALSE)) ) {
  pdp11_cpu.c
  • add the #include "..\realcons.h" statement after #include "pdp11_defs.h"
  • in the function t_stat sim_instr(void), in the section /* Fetch and decode next instruction */
    after the 2 lines
    IR = ReadW (PC | isenable);
    PC = (PC + 2) & 0177777;

    add the following lines :
    rc_show_addrs_data(PC, (uint16)IR, FALSE);
    if ( halt_from_RealConsole() == TRUE )   reason = SCPE_STOP;
    if (cm == MD_KER)
    {   // kernel mode --> "virtual" LED on
        rc_send_fnc_sts(FSTS_VIRTUAL_LED, FSTS_LED_ON, FALSE);
    }
    else
    {   // user or supervisor mode --> "user" LED on
        rc_send_fnc_sts(FSTS_USER_LED, FSTS_LED_ON, FALSE);
    }
  • at the end (far away) of the function t_stat sim_instr(void), in the section /* Simulation halted */,
    just before the return reason; statement, add the following lines:
    if ( (reason == STOP_HALT) || (reason == STOP_WAIT) || (reason == SCPE_STOP)
           || (reason == STOP_VECABORT) || (reason == STOP_SPABORT) )
    {   // during HALT, general register R0 contents are displayed.
        rc_show_addrs_data(saved_PC, (uint16)R[0], TRUE);
    }
    else
    {   // during Single Instruction operation, the Processor Status Word is displayed.
        rc_show_addrs_data(saved_PC, (uint16)PSW, TRUE);
    }
    if (cm == MD_KER)
    {   // kernel mode --> "virtual" LED on
        rc_send_fnc_sts(FSTS_VIRTUAL_LED, FSTS_LED_ON, TRUE);
    }
    else
    {   // user or supervisor mode --> "user" LED on
        rc_send_fnc_sts(FSTS_USER_LED, FSTS_LED_ON, TRUE);
    }
  • PROC and BUS LEDs to be added ...