|
GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
|
Binary and decimal (unpacked) arithmetic helpers for the GE-120/130. More...
Go to the source code of this file.
Functions | |
| static uint8_t | field_byte (const struct ge *ge, uint16_t base_addr, uint8_t len, uint8_t pos) |
Read one byte from a multi-byte big-endian field at position pos (0 = least-significant byte = rightmost, len-1 = most-significant). | |
| static void | field_byte_set (struct ge *ge, uint16_t base_addr, uint8_t len, uint8_t pos, uint8_t val) |
| Write one byte into a multi-byte big-endian field. | |
| void | alu_ab (struct ge *ge, uint16_t a_addr, uint8_t a_len, uint16_t b_addr, uint8_t b_len) |
| AB – Add Binary (opcode 0xFE). | |
| void | alu_sb (struct ge *ge, uint16_t a_addr, uint8_t a_len, uint16_t b_addr, uint8_t b_len) |
| SB – Subtract Binary (opcode 0xFF). | |
| static uint8_t | dec_digit (const struct ge *ge, uint16_t base_addr, uint8_t len, uint8_t pos) |
| void | alu_ad (struct ge *ge, uint16_t a_addr, uint8_t a_len, uint16_t b_addr, uint8_t b_len) |
| AD – Add Decimal (opcode 0xFA). | |
| void | alu_sd (struct ge *ge, uint16_t a_addr, uint8_t a_len, uint16_t b_addr, uint8_t b_len) |
| SD – Subtract Decimal (opcode 0xFB). | |
Binary and decimal (unpacked) arithmetic helpers for the GE-120/130.
Manual references: cpu_6.txt §5.5.1 – Decimal arithmetics (AD, SD) cpu_6.txt §5.5.2 – Binary arithmetics (AB, SB) cpu_6.txt §5.10.2 – Qualitative results summary table
Operand model (§5.5.1 / §5.5.2): addr points to the RIGHTMOST (least-significant) byte. The field occupies memory[addr - len + 1 .. addr]. All operations are performed right-to-left (LSD first).
Length rules (verified from manual text): If L2 > L1: truncate operand 2 to L1 (treat as if L2 = L1). If L2 < L1: zero-extend operand 2 on the left.
CC encoding (§5.10.2): cc = (FA04 << 1) | FA05 Stored by alu_set_cc() into ffFI bits 4 (hi) and 5 (lo).
Definition in file alu_bin.c.
| void alu_ab | ( | struct ge * | ge, |
| uint16_t | a_addr, | ||
| uint8_t | a_len, | ||
| uint16_t | b_addr, | ||
| uint8_t | b_len | ||
| ) |
AB – Add Binary (opcode 0xFE).
Adds the binary integer at [b_addr-b_len+1..b_addr] to the binary integer at [a_addr-a_len+1..a_addr]. Result stored in the first operand field. Second operand is not modified.
| ge | Emulator state |
| a_addr | Address of the rightmost byte of the first (destination) operand |
| a_len | Length of the first operand in bytes (1..16) |
| b_addr | Address of the rightmost byte of the second (source) operand |
| b_len | Length of the second operand in bytes (1..16) |
| void alu_ad | ( | struct ge * | ge, |
| uint16_t | a_addr, | ||
| uint8_t | a_len, | ||
| uint16_t | b_addr, | ||
| uint8_t | b_len | ||
| ) |
AD – Add Decimal (opcode 0xFA).
Adds two unsigned, unpacked (zoned) decimal fields right-to-left. Zones are ignored during the arithmetic. Result stored in the first operand field (zones of the result positions are set to 0x00 per the "zones not processed" rule; the caller / CPU sequencer is responsible for zone restoration if required).
Carry beyond the field boundary is silently dropped. Second operand is not modified.
| void alu_sb | ( | struct ge * | ge, |
| uint16_t | a_addr, | ||
| uint8_t | a_len, | ||
| uint16_t | b_addr, | ||
| uint8_t | b_len | ||
| ) |
SB – Subtract Binary (opcode 0xFF).
Subtracts the second operand from the first operand; result stored in the first operand field. If the mathematical result is negative it is stored in two's-complement form (complemented to 2^(8*a_len)). Second operand is not modified.
| void alu_sd | ( | struct ge * | ge, |
| uint16_t | a_addr, | ||
| uint8_t | a_len, | ||
| uint16_t | b_addr, | ||
| uint8_t | b_len | ||
| ) |
SD – Subtract Decimal (opcode 0xFB).
Subtracts the second unpacked decimal field from the first. If a borrow propagates beyond the most-significant position the result wraps modulo 10^a_len (consistent with the manual's description of unsigned positive integers with no sign handling in AD/SD).
Note: the manual states operands are treated as positive integers; the handling of underflow (borrow beyond the field) is not explicitly described for SD in the available OCR text. The implementation wraps modulo 10^L1 and sets cc=1 (non-zero) on underflow; this should be verified against page images. Second operand is not modified.
|
inlinestatic |
|
inlinestatic |
Read one byte from a multi-byte big-endian field at position pos (0 = least-significant byte = rightmost, len-1 = most-significant).
The field is stored big-endian in memory: MSB at address (base_addr - len + 1), LSB at address base_addr. So byte at position pos from LSB is at address (base_addr - pos).