mirror of
https://github.com/rzzzwilson/pymlac.git
synced 2025-06-10 09:32:41 +00:00
Reverted to better old copy
This commit is contained in:
182
vimlac/dcpu.c
182
vimlac/dcpu.c
@@ -1,105 +1,56 @@
|
||||
/******************************************************************************\
|
||||
* dcpu.c *
|
||||
* -------- *
|
||||
* dcpu.c *
|
||||
* ------- *
|
||||
* *
|
||||
* This file is used to decode and execute a display processor instruction. *
|
||||
* *
|
||||
\******************************************************************************/
|
||||
|
||||
#include "imlac.h"
|
||||
#include "vimlac.h"
|
||||
#include "dcpu.h"
|
||||
#include "memory.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
/******
|
||||
* Emulated registers, state, memory, etc.
|
||||
******/
|
||||
|
||||
static WORD r_DPC;
|
||||
static WORD Prev_r_DPC;
|
||||
static WORD DRSindex = 0;
|
||||
static WORD r_PC;
|
||||
static WORD Prev_r_PC;
|
||||
static int r_DRSindex;
|
||||
|
||||
/* 40Hz sync stuff */
|
||||
static bool Sync40HzOn = false;
|
||||
|
||||
/******
|
||||
* Environment stuff. PTR and TTY in and out files, etc
|
||||
******/
|
||||
|
||||
static bool dcpu_on; /* true if display processor is running */
|
||||
static bool dcpu_sync_on; /* true if 40HZ flag set */
|
||||
static bool cpu_is_on; /* true if display processor is running */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to get the display CPU status.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
bool
|
||||
dcpu_running(void)
|
||||
{
|
||||
return dcpu_on == true;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to start the display CPU.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
void
|
||||
dcpu_start(void)
|
||||
{
|
||||
dcpu_on = true;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to stop the display CPU.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
void
|
||||
dcpu_stop(void)
|
||||
{
|
||||
dcpu_on = false;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Functions to get various registers.
|
||||
Description : Functions to get/set various registers.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
WORD
|
||||
dcpu_get_DPC(void)
|
||||
dcpu_get_PC(void)
|
||||
{
|
||||
return r_DPC;
|
||||
}
|
||||
|
||||
|
||||
WORD
|
||||
dcpu_get_prev_DPC(void)
|
||||
{
|
||||
return Prev_r_DPC;
|
||||
return r_PC;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
dcpu_set_DPC(WORD new_dpc)
|
||||
dcpu_set_PC(WORD value)
|
||||
{
|
||||
r_DPC = new_dpc;
|
||||
r_PC = value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
dcpu_set_DRSindex(WORD drsindex)
|
||||
dcpu_set_DRSindex(int value)
|
||||
{
|
||||
DRSindex = drsindex;
|
||||
r_DRSindex = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,55 +63,44 @@ Description : Function to handle unrecognized instruction.
|
||||
static void
|
||||
illegal(void)
|
||||
{
|
||||
WORD oldDPC = Prev_r_DPC & MEMMASK;
|
||||
WORD oldPC = Prev_r_PC & MEMMASK;
|
||||
|
||||
/* memdump(LogOut, oldPC - 8, 16); */
|
||||
|
||||
error("INTERNAL ERROR: "
|
||||
"unexpected display processor opcode %06.6o at address %06.6o",
|
||||
mem_get(oldDPC, false), oldDPC);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description :
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
static int
|
||||
i_LAW_LWC(bool indirect, WORD address)
|
||||
{
|
||||
return 1;
|
||||
"unexpected main processor opcode %06.6o at address %06.6o",
|
||||
mem_get(oldPC, false), oldPC);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to execute one display processor instruction.
|
||||
Parameters :
|
||||
Returns : The number of cycles the instruction took.
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
int
|
||||
dcpu_execute_one(void)
|
||||
{
|
||||
WORD instruction;
|
||||
WORD opcode;
|
||||
WORD address;
|
||||
bool indirect;
|
||||
WORD instruction = 0;
|
||||
bool indirect = false;
|
||||
WORD opcode = 0;
|
||||
WORD address = 0;
|
||||
|
||||
/******
|
||||
* If main processor not running, return immediately.
|
||||
* If processor not running, return immediately.
|
||||
******/
|
||||
|
||||
if (!dcpu_on)
|
||||
if (!cpu_is_on)
|
||||
return 0;
|
||||
|
||||
/******
|
||||
* Fetch the instruction. Split into initial opcode and address.
|
||||
******/
|
||||
|
||||
Prev_r_DPC = r_DPC;
|
||||
instruction = mem_get(r_DPC++, false);
|
||||
r_DPC = r_DPC & MEMMASK;
|
||||
Prev_r_PC = r_PC;
|
||||
instruction = mem_get(r_PC++, false);
|
||||
r_PC = r_PC & MEMMASK;
|
||||
|
||||
indirect = (bool) (instruction & 0100000); /* high bit set? */
|
||||
opcode = (instruction >> 11) & 017; /* high 5 bits */
|
||||
@@ -170,12 +110,70 @@ dcpu_execute_one(void)
|
||||
* Now decode it.
|
||||
******/
|
||||
|
||||
#ifdef JUNK
|
||||
switch (opcode)
|
||||
{
|
||||
default: illegal();
|
||||
}
|
||||
#endif
|
||||
++instruction;
|
||||
indirect = !indirect;
|
||||
++opcode;
|
||||
++address;
|
||||
illegal();
|
||||
|
||||
return 0; /* CAN'T REACH */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to get CPU state.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
bool
|
||||
dcpu_on(void)
|
||||
{
|
||||
return cpu_is_on;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to start the CPU.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
void
|
||||
dcpu_start(void)
|
||||
{
|
||||
cpu_is_on = true;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to stop the CPU.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
void
|
||||
dcpu_stop(void)
|
||||
{
|
||||
cpu_is_on = false;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Description : Function to stop the CPU.
|
||||
Parameters :
|
||||
Returns :
|
||||
Comments :
|
||||
******************************************************************************/
|
||||
void
|
||||
dcpu_set_drsindex(int index)
|
||||
{
|
||||
r_DRSindex = index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user