GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
msl.c
Go to the documentation of this file.
1#include <stdint.h>
2#include <stdio.h>
3
4#include "msl.h"
5#include "msl-timings.h"
6#include "log.h"
7#include "ge.h"
8
9const struct msl_timing_state* msl_get_state(uint8_t SO)
10{
11 const struct msl_timing_state *state = &msl_timings[SO];
12
13 return state->chart ? state : NULL;
14}
15
16static void run_rows(struct ge *ge, const struct msl_timing_chart *rows)
17{
18 const struct msl_timing_chart *chart;
19 uint32_t i = 0;
20
21 do {
22 const char *clock_name = ge_clock_name(ge->current_clock);
23 chart = &rows[i++];
24
25 if (chart->clock != ge->current_clock)
26 continue;
27
29
30 if (chart->additional) {
31 if (!chart->additional(ge)) {
32 ge_log(LOG_CONDS, " time %-4s - additional false\n", clock_name);
33 continue;
34 }
35 ge_log(LOG_CONDS, " time %-4s - additional true\n", clock_name);
36 }
37
38 if (chart->condition) {
39 if (!chart->condition(ge)) {
40 ge_log(LOG_CONDS, " time %-4s - condition false\n", clock_name);
41 continue;
42 }
43 ge_log(LOG_CONDS, " time %-4s - condition true\n", clock_name);
44 }
45
46
48 chart->command(ge);
49 } while (chart->clock < END_OF_STATUS);
50}
51
52void msl_run_state(struct ge* ge, const struct msl_timing_state *state)
53{
54 if (!state->chart)
55 return;
56
57 if (state->chart_ref && ge->current_clock == TO00)
58 ge_log(LOG_CONDS, " chart (%s)\n", state->chart_ref);
59
60 run_rows(ge, state->chart);
61}
const char * ge_clock_name(enum clock c)
The clock period name name.
Definition ge.c:433
void ge_print_registers_verbose(struct ge *ge)
Definition ge.c:459
void ge_log(ge_log_type type, const char *format,...)
Log message.
Definition log.c:122
@ LOG_CONDS
MSL conditions trace.
Definition log.h:22
@ LOG_CMDS
MSL commands trace.
Definition log.h:29
const char * msl_comment_for_command(msl_command_cb command)
struct msl_timing_state msl_timings[0xff]
Timing chart definitions.
Definition msl-timings.c:9
const struct msl_timing_state * msl_get_state(uint8_t SO)
Gets timing state␐␐␐␐␐␐␐␐␐.
Definition msl.c:9
static void run_rows(struct ge *ge, const struct msl_timing_chart *rows)
Definition msl.c:16
void msl_run_state(struct ge *ge, const struct msl_timing_state *state)
Select the first matching manual-sheet variant for an instruction state.
Definition msl.c:52
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:172
enum clock current_clock
Definition ge.h:174
Timing chart row.
Definition msl-timings.h:16
msl_command_cb command
Pointer to the command function.
Definition msl-timings.h:21
msl_condition_cb condition
Condition for the command.
Definition msl-timings.h:33
msl_condition_cb additional
Additional condition for the command.
Definition msl-timings.h:45
enum clock clock
Clock at which the command should be perfomed.
Definition msl-timings.h:18
Timing chart.
Definition msl-timings.h:65
const struct msl_timing_chart * chart
The state's timing chart.
Definition msl-timings.h:67
const char * chart_ref
Sheets this chart was transcribed from.
Definition msl-timings.h:77