|
GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
|
ALU helpers for GE-120/GE-130 register and memory-field operations. More...
Go to the source code of this file.
Functions | |
| static uint16_t | mem_read16 (struct ge *ge, uint16_t addr) |
| mem_read16 - read a big-endian 16-bit word from memory. | |
| static void | mem_write16 (struct ge *ge, uint16_t addr, uint16_t val) |
| mem_write16 - write a big-endian 16-bit word to memory. | |
| void | alu_lr (struct ge *ge, uint16_t *reg, uint16_t addr) |
| alu_lr - Load Register (LR, 0xBC) | |
| void | alu_str (struct ge *ge, uint16_t reg_val, uint16_t addr) |
| alu_str - Store Register (STR, 0x84) | |
| void | alu_cmr (struct ge *ge, uint16_t reg_val, uint16_t value) |
| alu_cmr - Compare Memory to Register (CMR, 0xBD) | |
| void | alu_amr (struct ge *ge, uint16_t *reg, uint16_t value) |
| alu_amr - Add Memory to Register (AMR, 0xBE) | |
| void | alu_smr (struct ge *ge, uint16_t *reg, uint16_t value) |
| alu_smr - Subtract Memory from Register (SMR, 0xBF) | |
| void | alu_la (struct ge *ge, uint16_t *reg, uint16_t addr) |
| alu_la - Load Address (LA, 0x68) | |
| void | alu_sr (struct ge *ge, uint16_t *r7, uint16_t field, uint16_t len, uint8_t model) |
| alu_sr - Search Right (SR, 0xD9) | |
| void | alu_sl (struct ge *ge, uint16_t *r7, uint16_t field, uint16_t len, uint8_t model) |
| alu_sl - Search Left (SL, 0xDB) | |
| void | alu_mvq (struct ge *ge, uint16_t dst, uint16_t src, uint8_t len) |
| alu_mvq - Move Quartets (MVQ, 0xF8) | |
| void | alu_cmq (struct ge *ge, uint16_t a, uint16_t b, uint8_t len) |
| alu_cmq - Compare Quartets (CMQ, 0xF9) | |
ALU helpers for GE-120/GE-130 register and memory-field operations.
Source documentation: Document: cpu_6.txt (GE-130 P.D.S., S.P.S.-GEISI, cod. 3896128) Sections: §5.6.4 (register ops), §5.5.1.3-4 (MVQ/CMQ), §5.5.4 (SR/SL search), §5.10.2 (qualitative results table)
See alu_reg.h for full API and CC-encoding documentation.
Definition in file alu_reg.c.
| void alu_amr | ( | struct ge * | ge, |
| uint16_t * | reg, | ||
| uint16_t | value | ||
| ) |
alu_amr - Add Memory to Register (AMR, 0xBE)
register = register + value (16-bit binary, unsigned) Overflow beyond 16 bits is discarded (carry lost).
CC result (§5.6.4.2): FA04 FA05 0 0 → result == 0, no overflow → ALU_CC_EQUAL (0) 0 1 → result != 0, no overflow → ALU_CC_LOW (1) 1 0 → overflow, partial result ==0 → ALU_CC_HIGH (2) 1 1 → overflow, partial result !=0 → ALU_CC_OVF (3)
URPE = carry out of bit-15 (the "overflow" bit) URPU = carry into bit-15 (bit-14 carry out; used in arithmetic logic)
| ge | machine state |
| reg | pointer to the 16-bit register (modified in place) |
| value | value to add |
| void alu_cmq | ( | struct ge * | ge, |
| uint16_t | a, | ||
| uint16_t | b, | ||
| uint8_t | len | ||
| ) |
alu_cmq - Compare Quartets (CMQ, 0xF9)
Compares the digit nibbles (low 4 bits) of two byte fields, right-to-left. Neither operand is altered.
CC result (§5.5.1.4): FA04 FA05 0 0 → "Not possible" (never emitted) 0 1 → first operand < second → ALU_CC_LOW (1) 1 0 → first operand == second → ALU_CC_HIGH (2) 1 1 → first operand > second → ALU_CC_OVF (3)
The comparison is lexicographic on digit nibbles, left-to-right (most significant digit first), consistent with treating the field as a multi-digit decimal integer.
| ge | machine state |
| a | address of the rightmost byte of the first operand |
| b | address of the rightmost byte of the second operand |
| len | number of bytes to compare |
| void alu_cmr | ( | struct ge * | ge, |
| uint16_t | reg_val, | ||
| uint16_t | value | ||
| ) |
alu_cmr - Compare Memory to Register (CMR, 0xBD)
Compares reg_val against value (both treated as unsigned 16-bit integers). Sets CC only; neither operand is modified.
CC result (§5.6.4.4 table, FA04=bit4, FA05=bit5): FA04 FA05 0 0 → "Not possible" (never emitted) 0 1 → Register < memory → ALU_CC_LOW (1) 1 0 → Register == memory → ALU_CC_HIGH is wrong; the manual says 10 = "Reg equal to memory" → ALU_CC_HIGH (2) 1 1 → Register > memory → ALU_CC_OVF (3)
NOTE: The CC encoding is: (FA04<<1)|FA05, so: Reg < mem → cc=1 Reg == mem → cc=2 Reg > mem → cc=3
| ge | machine state |
| reg_val | the register value (first operand) |
| value | the memory value (second operand) |
| void alu_la | ( | struct ge * | ge, |
| uint16_t * | reg, | ||
| uint16_t | addr | ||
| ) |
alu_la - Load Address (LA, 0x68)
Stores the effective address (already computed by caller) into *reg. No memory data fetch is performed — this is like IBM S/360 LA. Qualitative result: not affected.
| ge | machine state |
| reg | pointer to the target register |
| addr | the effective address to load |
| void alu_lr | ( | struct ge * | ge, |
| uint16_t * | reg, | ||
| uint16_t | addr | ||
| ) |
alu_lr - Load Register (LR, 0xBC)
Loads the 16-bit value from memory at [addr, addr+1] into *reg. The byte at addr is the high byte (MSB); addr+1 is the low byte (LSB). Qualitative result: not affected.
| ge | machine state |
| reg | pointer to the target 16-bit register (e.g. &ge->rV1) |
| addr | memory address of the high (rightmost significant) byte |
| void alu_mvq | ( | struct ge * | ge, |
| uint16_t | dst, | ||
| uint16_t | src, | ||
| uint8_t | len | ||
| ) |
alu_mvq - Move Quartets (MVQ, 0xF8)
Copies the low 4 bits (digit nibble) of each byte from src field to dst field, right-to-left, preserving the zone nibble of the destination. Length is the number of bytes (len = L1+1).
UNCERTAINTY (OCR): The manual states MVQ does not use or change the zones (§5.5.1 context, §3.084/3.098); the digit nibbles are moved. The phrasing is that the zones are "not processed." This implementation preserves the destination zone nibble and writes only the digit nibble from source. If the real hardware copies the full byte (ignoring-zone meaning something different), this needs a hardware trace correction.
CC result (§5.10.2 table): FA04 FA05 0 0 → transferred result == 0 → ALU_CC_EQUAL (0) 0 1 → transferred result != 0 → ALU_CC_LOW (1) "Result" refers to whether all transferred digit nibbles are zero.
| ge | machine state |
| dst | address of the rightmost byte of destination |
| src | address of the rightmost byte of source |
| len | number of bytes to process |
| void alu_sl | ( | struct ge * | ge, |
| uint16_t * | r7, | ||
| uint16_t | field, | ||
| uint16_t | len, | ||
| uint8_t | model | ||
| ) |
alu_sl - Search Left (SL, 0xDB)
Scan mem[field .. field+len-1] right-to-left for a byte equal to model. If found at position i (0=leftmost): *r7 = field + i - 1 (address before match, i.e. the address preceding the found character in the direction of search). For i==0 (leftmost byte matches): *r7 = field - 1 (one before field start). If not found: *r7 = field - 1 (one before the field start).
NOTE: The manual says for SL "the address stored is the one of the character following the end of the research field in the direction of the research" — direction is right-to-left, so "following end" means field-1 when not found. This is the symmetric of SR.
| ge | machine state |
| r7 | pointer to register 7 (receives result address) |
| field | memory address of the leftmost byte of the search field |
| len | number of bytes in the search field |
| model | byte value to search for |
| void alu_smr | ( | struct ge * | ge, |
| uint16_t * | reg, | ||
| uint16_t | value | ||
| ) |
alu_smr - Subtract Memory from Register (SMR, 0xBF)
register = register - value (2's-complement form, 16-bit) Result is left in 2's-complement (negative result stays complemented).
CC result (§5.6.4.3): FA04 FA05 0 0 → "Not possible" (never emitted) 0 1 → result < 0 (negative; complemented form) → ALU_CC_LOW (1) 1 0 → result == 0 → ALU_CC_HIGH (2) 1 1 → result > 0 → ALU_CC_OVF (3)
URPE = borrow out (1 if borrow from bit-16, i.e. result wrapped) URPU = borrow into bit-15
| ge | machine state |
| reg | pointer to the 16-bit register (modified in place) |
| value | value to subtract from *reg |
| void alu_sr | ( | struct ge * | ge, |
| uint16_t * | r7, | ||
| uint16_t | field, | ||
| uint16_t | len, | ||
| uint8_t | model | ||
| ) |
alu_sr - Search Right (SR, 0xD9)
Scan mem[field .. field+len-1] left-to-right for a byte equal to model. If found at position i: *r7 = field + i + 1 (address following the match). If not found: *r7 = field + len (address following the field). No CC change.
| ge | machine state |
| r7 | pointer to register 7 (receives result address) |
| field | memory address of the leftmost byte of the search field |
| len | number of bytes in the search field |
| model | byte value to search for |
| void alu_str | ( | struct ge * | ge, |
| uint16_t | reg_val, | ||
| uint16_t | addr | ||
| ) |
alu_str - Store Register (STR, 0x84)
Stores the 16-bit reg_val into memory at [addr, addr+1]. High byte → mem[addr], low byte → mem[addr+1]. Qualitative result: not affected.
| ge | machine state |
| reg_val | value to store (register content) |
| addr | memory address of the high byte |
|
inlinestatic |