Contents > General-purpose Computer > Assembly Language
An arithmetic or logic instruction computes an 8-bit function of A or of A and B, and it puts the result in A:
Instruction | Name | Pseudocode | Opcode |
---|---|---|---|
ADD | Add (without carry) | A += B; | 10 |
AND | Bitwise AND | A &= B; | 11 |
DEC | Decrement | --A; | 12 |
INC | Increment | ++A; | 13 |
LS2 | Logical Left Shift by 2 | A <<= 2; | 14 |
LS3 | Logical Left Shift by 3 | A <<= 3; | 15 |
LS4 | Logical Left Shift by 4 | A <<= 4; | 16 |
OR | Bitwise OR | A |= B; | 17 |
RS1 | Logical Right Shift by 1 | A >>>= 1; | 18 |
RS5 | Logical Right Shift by 5 | A >>>= 5; | 19 |
SUB | Subtract (without borrow) | A -= B; | 1A |
XOR | Bitwise XOR | A ^= B; | 1B |
The carry-outs of ADD and INC, the borrow-outs of SUB and DEC, and the shift-outs of the shift instructions are lost. There is no add-with-carry instruction nor a subtract-with-borrow instruction. All shift instructions shift-in 0.
Every arithmetic and logic instruction assigns the zero flag, z, to 1 if the resultant value in A is zero, and to 0, otherwise. Similarly, it assigns the negative flag, n, to 1 if the resultant value in A is negative (if bit-7 is 1), and to 0, otherwise.
The instructions correspond to opcodes with bits 0001xxxx. Of the sixteen possible opcodes, the computer implements the twelve listed above. They were selected to satisfy the requirements of a single program, one that runs Tetris. Potential additions include Bitwise NOT and shifts by other values.
© 2023 meatfighter.com |