Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions site/topics/control-logic/instructions-microcodes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,34 @@ The 13 Instructions
* Output the operand (data) from the instruction register and put it into register A


.. warning::

This load *direct* instruction has a limitation caused by the underlying hardware --- only positive integers can
be loaded directly to the register.

.. figure:: instruction_register_operand_padded_zeros.png
:width: 333 px
:align: center

Since each operand is only 4 bits wide, but the data bus is expecting 8 bits, the 4 most significant bits
are padded with zeros.


Consider the 8 bit number ``0b11111111``. Although this number may be ``255`` or ``-1``, depending on if it is
a signed integer, adding ``0b00000001`` to this number results in ``0b1_00000000`` regardless. This number is
``256``, but because only 8 bits can be represented and the overflow carry bit is ignored, the number is
ultimately truncated to ``0``.

However, consider the 4 bit number ``0b1111``, which may be ``15`` or ``-1``. The programmer may intend for this
bit pattern to mean ``-1``, but the operand for the load direct instructions are only four bits wide and are
padded with zeros, thus this bit pattern would become ``0b00001111`` when it is added to the register. This 8
bit number, signed or not, is ``15`` and adding ``1`` to this number results in ``0b00010000``.

One may try to address this issue with hardware and additional logic, but one must ask --- is this additional
complexity worth it?



* ``0011`` --- ``LDBR``

* Load data into register B from some specified RAM address
Expand Down
4 changes: 2 additions & 2 deletions site/topics/programming/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
VALID_SYNTAX = {
r"NOOP",
r"LDAR\s+\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"LDAD\s+-?\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"LDAD\s+\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"LDBR\s+\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"LDBD\s+-?\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"LDBD\s+\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"SAVA\s+\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"SAVB\s+\b(0x[0-9a-fA-F]+|0b[0-1]+|[0-9]+)\b",
r"ADAB",
Expand Down