GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
alu_cc.h
Go to the documentation of this file.
1#ifndef ALU_CC_H
2#define ALU_CC_H
3
4#include "ge.h"
5
6/*
7 * GE-120 condition code.
8 *
9 * The machine keeps a 2-bit condition code in the special-conditions
10 * register ffFI, bits 4 (high) and 5 (low). At clock TO10 ffFI is
11 * snapshotted into ffFA, and a Jump-on-Condition (JC) instruction tests
12 * it via verified_condition() in signals.h:
13 *
14 * cc = (FA4 << 1) | FA5
15 * JC mask bit M7 -> cc 0, M6 -> cc 1, M5 -> cc 2, M4 -> cc 3.
16 *
17 * AUTHORITATIVE CC mapping (decoded from CPU manual chapter 5, §5.5.2 / §5.6.1
18 * / §5.10.2 qualitative results tables):
19 *
20 * COMPARE ops (CMC/CI/CMP/CMR/CMQ):
21 * cc=0 "not possible" (never set by compare ops)
22 * cc=1 first < second (FA04=0, FA05=1)
23 * cc=2 first == second (FA04=1, FA05=0)
24 * cc=3 first > second (FA04=1, FA05=1)
25 *
26 * ADD-MAGNITUDE ops (AB add-binary; AD add-decimal-unsigned; AMR):
27 * cc=0 result zero, no overflow (FA04=0, FA05=0)
28 * cc=1 result nonzero, no overflow (FA04=0, FA05=1)
29 * cc=2 overflow, partial result zero (FA04=1, FA05=0)
30 * cc=3 overflow, partial result nonzero (FA04=1, FA05=1)
31 *
32 * SIGNED-RESULT ops (SB subtract-binary; AP/SP/MP/DP/CMP packed;
33 * SMR; PKS/UPKS/EDT sign):
34 * cc=0 "not possible" (never set by signed-result ops)
35 * cc=1 result < 0 (negative) (FA04=0, FA05=1)
36 * cc=2 result == 0 (FA04=1, FA05=0)
37 * cc=3 result > 0 (positive) (FA04=1, FA05=1)
38 *
39 * The enum names are defined to match all three tables simultaneously.
40 * ALU_CC_LOW == ALU_CC_NEG == 1; ALU_CC_EQUAL == ALU_CC_ZERO == 2;
41 * ALU_CC_HIGH == ALU_CC_POS == 3.
42 *
43 * ALU_CC_OVF == 0: used for the overflow / "not-possible" slot. The
44 * per-op overflow CC encoding is uncertain for some ops (see TODO comments
45 * in individual functions); kept as 0 pending hardware verification.
46 *
47 * When wiring JC in Wave 5, remember the mask mapping in
48 * verified_condition(): M7->cc0, M6->cc1, M5->cc2, M4->cc3.
49 */
50enum alu_cc {
51 ALU_CC_LOW = 1, ALU_CC_NEG = 1, /* first<second / result<0 */
52 ALU_CC_EQUAL = 2, ALU_CC_ZERO = 2, /* first==second / result==0 */
53 ALU_CC_HIGH = 3, ALU_CC_POS = 3, /* first>second / result>0 */
54 ALU_CC_OVF = 0, /* overflow / "not possible" slot;
55 per-op overflow CC is uncertain —
56 keep as 0 and leave a TODO comment */
57};
58
59/* Store a 2-bit condition code (0..3) into ffFI bits 4 (hi) and 5 (lo). */
60void alu_set_cc(struct ge *ge, uint8_t cc);
61
62/* Read the current 2-bit condition code from ffFI bits 4,5. */
63uint8_t alu_get_cc(struct ge *ge);
64
65#endif /* ALU_CC_H */
uint8_t alu_get_cc(struct ge *ge)
Definition alu_cc.c:18
void alu_set_cc(struct ge *ge, uint8_t cc)
Definition alu_cc.c:4
alu_cc
Definition alu_cc.h:50
@ ALU_CC_EQUAL
Definition alu_cc.h:52
@ ALU_CC_POS
Definition alu_cc.h:53
@ ALU_CC_OVF
Definition alu_cc.h:54
@ ALU_CC_ZERO
Definition alu_cc.h:52
@ ALU_CC_NEG
Definition alu_cc.h:51
@ ALU_CC_LOW
Definition alu_cc.h:51
@ ALU_CC_HIGH
Definition alu_cc.h:53
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:96