wire / wire-format / alu
The ALU performs arithmetic and logical operations on integer operands. Typical operations: ADD, SUB, AND, OR, XOR, NOT, SHL (shift left), SHR (shift right), SAR (arithmetic shift right), ROL (rotate left), ROR (rotate right), CMP (compare, sets flags), TEST (AND without storing result). Flags: ZF (zero), SF (sign), CF (carry), OF (overflow), PF (parity).
aka: ALU (Arithmetic Logic Unit)
spec: Computer architecture
The ALU performs arithmetic and logical operations on integer operands. Typical operations: ADD, SUB, AND, OR, XOR, NOT, SHL (shift left), SHR (shift right), SAR (arithmetic shift right), ROL (rotate left), ROR (rotate right), CMP (compare, sets flags), TEST (AND without storing result). Flags: ZF (zero), SF (sign), CF (carry), OF (overflow), PF (parity).
| field | size | meaning |
|---|---|---|
| Operation select | 4-6 bits | Selects the ALU operation (ADD, SUB, AND, OR, XOR, etc.). |
| Operand A | n bits | First operand (from register or immediate). |
| Operand B | n bits | Second operand (from register or immediate). |
| Result | n bits | Operation result. |
| Carry out | 1 bit | Carry/borrow out of the most significant bit. |
| Zero flag (ZF) | 1 bit | 1 if result is zero. |
| Sign flag (SF) | 1 bit | 1 if result is negative (MSB=1). |
| Overflow flag (OF) | 1 bit | 1 if signed overflow occurred. |
| Carry flag (CF) | 1 bit | 1 if unsigned carry/borrow occurred. |
| Parity flag (PF) | 1 bit | 1 if even number of 1 bits in low byte. |
example:
00 00 00 00
ALU (placeholder)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/alu
or /wire-format/alu.json