Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
Directives | ||
========== | ||
|
||
This section covers the directives supported by the simulator. Specifically, | ||
the simulator supports the following directives: | ||
|
||
* :ref:`directive-db` | ||
* :ref:`directive-dw` | ||
* :ref:`directive-org` | ||
* :ref:`directive-equ` | ||
|
||
.. _directive-db: | ||
|
||
DB: Define Byte | ||
^^^^^^^^^^^^^^^ | ||
|
||
This directive allows you to reserve memory space for *one byte* (8 bits). The | ||
receive directive receives two operands. Operand 1 sets the name or identifier | ||
assigned to the space. Operand 2 sets the initialization value of the reserved | ||
space. This operand can be a numeric value, a character or an array of | ||
characters. In the case of a single character, the initial value stored will | ||
correspond to the ASCII code of the character encoded in single quotes (``''``). In the | ||
case of an array, the values corresponding to the ASCII codes of those encoded | ||
between double quotes (``""```) will be encoded. If you want to encode a numeric value | ||
explicitly within the array, you must do it using the escape combination ``\x``. | ||
|
||
+-----------------------------------+------------------------------------------------------------------+ | ||
| Directive | Result | | ||
+===================================+==================================================================+ | ||
| ``DB var1, 0x01`` | Reserseves one byte with an initial value of 0x01 | | ||
+-----------------------------------+------------------------------------------------------------------+ | ||
| ``DB char1, '1'`` | Reserseves one byte with an initial value of 0x31 | | ||
+-----------------------------------+------------------------------------------------------------------+ | ||
| ``DB string, "Hello"`` | Reserseves five bytes with values {0x48, 0x65, 0x6C, 0x6C, 0x6F} | | ||
+-----------------------------------+------------------------------------------------------------------+ | ||
| ``DB string, "\x01\x02\x03\x04"`` | Reserseves four bytes with values {0x01, 0x02, 0x03, 0x04} | | ||
+-----------------------------------+------------------------------------------------------------------+ | ||
|
||
.. _directive-dw: | ||
|
||
DW: Define Word | ||
^^^^^^^^^^^^^^^ | ||
|
||
This directive allows you to reserve memory space for *two bytes* (16 bits). The | ||
receive directive receives two operands. Operand 1 sets the name or identifier | ||
assigned to the space. Operand 2 sets the initialization value of the reserved | ||
space. This operand can only be of numeric type. | ||
|
||
+---------------------+-----------------------------------------------+ | ||
| Directive | Result | | ||
+============================+========================================+ | ||
| ``DW var1, 2048`` | Reserseves two bytes with values {0x80, 0x00} | | ||
+---------------------+-----------------------------------------------+ | ||
| ``DW var2, 0x1FFF`` | Reserseves two bytes with values {0x1F, 0xFF} | | ||
+---------------------+-----------------------------------------------+ | ||
|
||
.. _directive-org: | ||
|
||
ORG: Advance Program Counter | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This directive allows moving the program counter to a given address. The | ||
directive contains a single operand that sets the address from which subsequent | ||
instructions are to be encoded. | ||
|
||
+-----------------+-------------------------------------------------------------------------+ | ||
| Directive | Result | | ||
+=================+=========================================================================+ | ||
| ``ORG 0x100`` | The subsequent instructions will be encoded starting from address 0x100 | | ||
+-----------------+-------------------------------------------------------------------------+ | ||
|
||
|
||
.. _directive-equ: | ||
|
||
EQU: 8-bits bitwise AND | ||
^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
The EQU directive gives a symbolic name or tag to an expression. This tag can | ||
be later used in subsequent lines of assembly code and will be substituted by | ||
the value given. The directive receives two operands. The first sets the label | ||
or symbolic name. The second defines the expression by which occurrences of the | ||
label will be replaced in the code. These occurrences will only be evaluated in | ||
lines of code following the definition of the label. | ||
|
||
+---------------------------+------------------------------------------------------------------+ | ||
| Directive | Result | | ||
+===========================+==================================================================+ | ||
| ``EOS EQU 255`` | Any occurrence of ``EOS`` will be sustitued by ``255`` | | ||
+---------------------------+------------------------------------------------------------------+ | ||
| ``TMRPRELOAD EQU 0x0003`` | Any occurrence of ``TMRPRELOAD`` will be sustitued by ``0x0003`` | | ||
+---------------------------+------------------------------------------------------------------+ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,5 @@ The simulator has the following features: | |
|
||
assembler | ||
instruction-set | ||
directives | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters