From 0be245c3e8f668efd876ccc9cd8a9103570cd284 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 11:32:40 -0300 Subject: [PATCH 1/9] rework sections --- site/topics/programming/programming-assembly.rst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index c94ccc37..2292e6eb 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -7,13 +7,21 @@ Programming with Assembly -Arithmetic Program -================== +Revisiting Problems +=================== +Arithmetic +---------- + + +Counting +-------- + + +Check 10 +-------- -Counting Program -================ From 87efd1342f045b34aeb0a4986968aad5cb7a3c8c Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 11:33:00 -0300 Subject: [PATCH 2/9] add new sec --- site/topics/programming/programming-assembly.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 2292e6eb..d4ddb62f 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -24,6 +24,10 @@ Check 10 +Count to 10 +=========== + + For Next Time ============= From fbd4b8fdbec9a64f3ec95f2d3c03f8b0a5b179bd Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 11:54:56 -0300 Subject: [PATCH 3/9] arithmetic program --- site/topics/programming/arithmetic_31_32.esap | 16 ++++++++++++++++ site/topics/programming/arithmetic_31_32.hex | 17 +++++++++++++++++ .../topics/programming/programming-assembly.rst | 17 +++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 site/topics/programming/arithmetic_31_32.esap create mode 100644 site/topics/programming/arithmetic_31_32.hex diff --git a/site/topics/programming/arithmetic_31_32.esap b/site/topics/programming/arithmetic_31_32.esap new file mode 100644 index 00000000..bea8e384 --- /dev/null +++ b/site/topics/programming/arithmetic_31_32.esap @@ -0,0 +1,16 @@ +LDAR 0xE +LDBR 0xF +ADAB +SAVA 0xD +OUTU 0xD +LDAR 0xE +SUAB +SAVA 0xD +OUTS 0xD +HALT +NOOP +NOOP +NOOP +NOOP +31 +32 \ No newline at end of file diff --git a/site/topics/programming/arithmetic_31_32.hex b/site/topics/programming/arithmetic_31_32.hex new file mode 100644 index 00000000..a1676788 --- /dev/null +++ b/site/topics/programming/arithmetic_31_32.hex @@ -0,0 +1,17 @@ +v2.0 raw +0x1e +0x3f +0x70 +0x5d +0xdd +0x1e +0x80 +0x5d +0xed +0xf0 +0x00 +0x00 +0x00 +0x00 +0x1f +0x20 diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index d4ddb62f..1e3a639a 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -10,10 +10,27 @@ Programming with Assembly Revisiting Problems =================== +* Consider the problems already solved with machine code hex files +* Instead of writing machine code, the assembler allows one to write in the assembly language + + * The mnemonics can be used, making programming easier and making the program much easier to understand + + +* The assembly language is then assembled, with the assembler, to the machine code +* This machine code can then be loaded into the ESAP system for execution + Arithmetic ---------- +* Consider the problem of outputting the result of the calculations ``31 + 32`` and ``31 - 32`` + + * This problem was already discussed in the machine code topic + + + + + Counting -------- From b9ed8b4ed769e879f16b0414049db80934bb6aca Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 12:03:41 -0300 Subject: [PATCH 4/9] counting program --- site/topics/programming/counting_forever.esap | 6 ++++++ site/topics/programming/counting_forever.hex | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 site/topics/programming/counting_forever.esap create mode 100644 site/topics/programming/counting_forever.hex diff --git a/site/topics/programming/counting_forever.esap b/site/topics/programming/counting_forever.esap new file mode 100644 index 00000000..9f80552d --- /dev/null +++ b/site/topics/programming/counting_forever.esap @@ -0,0 +1,6 @@ +LDAD 0 +LDBD 1 +SAVA 0xF +OUTU 0xF +ADAB +JMPA 0x2 \ No newline at end of file diff --git a/site/topics/programming/counting_forever.hex b/site/topics/programming/counting_forever.hex new file mode 100644 index 00000000..40efe509 --- /dev/null +++ b/site/topics/programming/counting_forever.hex @@ -0,0 +1,7 @@ +v2.0 raw +0x20 +0x41 +0x5f +0xdf +0x70 +0x92 From 8fd5c0bfa9b0f2faf390dedc49b44696010d1a06 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 12:07:25 -0300 Subject: [PATCH 5/9] check 10 program --- site/topics/programming/check_10.esap | 16 ++++++++++++++++ site/topics/programming/check_10.hex | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 site/topics/programming/check_10.esap create mode 100644 site/topics/programming/check_10.hex diff --git a/site/topics/programming/check_10.esap b/site/topics/programming/check_10.esap new file mode 100644 index 00000000..49d2c262 --- /dev/null +++ b/site/topics/programming/check_10.esap @@ -0,0 +1,16 @@ + LDAR 0xF + LDBD 10 + SUAB + JMPS 0x6 + OUTU 0xD + HALT + OUTU 0xE + HALT + NOOP + NOOP + NOOP + NOOP + NOOP + 0 + 1 + 5 \ No newline at end of file diff --git a/site/topics/programming/check_10.hex b/site/topics/programming/check_10.hex new file mode 100644 index 00000000..13ac34d9 --- /dev/null +++ b/site/topics/programming/check_10.hex @@ -0,0 +1,17 @@ +v2.0 raw +0x1f +0x4a +0x80 +0xb6 +0xdd +0xf0 +0xde +0xf0 +0x00 +0x00 +0x00 +0x00 +0x00 +0x00 +0x01 +0x0a From 88f91c40ce93d09a76b3d9ab4edc8e09ff39eebb Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 12:40:58 -0300 Subject: [PATCH 6/9] count 10 program --- site/topics/programming/counting_10.esap | 11 +++++++++++ site/topics/programming/counting_10.hex | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 site/topics/programming/counting_10.esap create mode 100644 site/topics/programming/counting_10.hex diff --git a/site/topics/programming/counting_10.esap b/site/topics/programming/counting_10.esap new file mode 100644 index 00000000..3016b486 --- /dev/null +++ b/site/topics/programming/counting_10.esap @@ -0,0 +1,11 @@ +LDAD 0 +SAVA 0xF +LDAR 0xF +LDBD 1 +ADAB +SAVA 0xF +OUTU 0xF +LDBD 10 +SUAB +JMPS 0x2 +HALT \ No newline at end of file diff --git a/site/topics/programming/counting_10.hex b/site/topics/programming/counting_10.hex new file mode 100644 index 00000000..a592c8cc --- /dev/null +++ b/site/topics/programming/counting_10.hex @@ -0,0 +1,12 @@ +v2.0 raw +0x20 +0x5f +0x1f +0x41 +0x70 +0x5f +0xdf +0x4a +0x80 +0xb2 +0xf0 From cf225597149a102b16c864c034f579db2e5fa1b1 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 13:14:10 -0300 Subject: [PATCH 7/9] arithmetic explain --- .../programming/programming-assembly.rst | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 1e3a639a..04ecba63 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -28,8 +28,60 @@ Arithmetic * This problem was already discussed in the machine code topic + .. list-table:: Arithmetic Program + :header-rows: 1 + :align: center + * - Assembly + - Machine Code + * - .. literalinclude:: arithmetic_31_32.esap + :language: text + :lineno-match: + + - .. literalinclude:: arithmetic_31_32.hex + :language: text + :lineno-match: + + +* Above is a table comparing the assembly language program and the corresponding machine code + + * This machine code was generated by the assembler + * The line numbers do not align here as the hex file requires the ``v2.0 raw`` line + + +* Notice that the data (``31`` and ``32``) is stored at the end of RAM + + * This is not a requirement + * Although the Von Neumann architecture has instructions and data share the same memory space + * It is often desirable to try to physically separate instructions and data in some way + + * May help with interpretability of programs + + +* Also notice the ``NOOP``\s filling the space between the instructions and data + + * The assembler ignores white space, so any empty RAM addresses need to be explicitly set + + * This was done here to facilitate physically separate instructions and data + + + * Technically anything could be put in these addresses, data or instruction, as they follow ``HALT`` + + * The system would never be able to run these RAM addresses + + + * However, to make the program as clear and intentional as possible, ``NOOP``\s were used + + * Entering the data ``0x00`` would also work, as it is the same bit pattern as ``NOOP`` + * However, again, to make the assembly program more clear, ``NOOP`` is used + + +* Finally, notice the use of hex values to specify addresses, but decimal for the data + + * All values are in hex except ``31`` and ``32`` + * This is not a requirement as the assembler converts everything to the same machine code, regardless of base + * This decision was made here to help provide clarity to the program Counting From f54fc363095e8ea4f45bf459f3e171effebb2978 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 13:22:34 -0300 Subject: [PATCH 8/9] explain check 10 and counting --- .../programming/programming-assembly.rst | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 04ecba63..1194ae8d 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -87,10 +87,67 @@ Arithmetic Counting -------- +* Below is the program to count by ones forever + + * Like the above arithmetic problem, this was already discussed in the machine code topic + + + .. list-table:: Counting Forever Program + :header-rows: 1 + :align: center + + * - Assembly + - Machine Code + + * - .. literalinclude:: counting_forever.esap + :language: text + :lineno-match: + + - .. literalinclude:: counting_forever.hex + :language: text + :lineno-match: + + Check 10 -------- +* Below is the program to check if a number is ``< 10`` + + * This was discussed in the conditions and conditional jump topics + + + .. list-table:: Check ``< 10`` Program + :header-rows: 1 + :align: center + + * - Assembly + - Machine Code + + * - .. literalinclude:: check_10.esap + :language: text + :lineno-match: + + - .. literalinclude:: check_10.hex + :language: text + :lineno-match: + + +* In the above program, like before, the value to check is stored in address ``0xF`` + + * To check if a different value is less than 10, one would have to alter the code + + +* Here, addresses ``0xD`` and ``0xE`` store the value to be output based on if the value is less than 10 or not + + * Storing the value ``0`` is not strictly necessary here for several reasons, but it does help with intentionality + + * It's not needed because the ESAP system in Digital starts with a ``0`` in the output register + * Further, the ``NOOP``\s are ``0``, so any of those addresses could be used + + +* Again, ``NOOP``\s are included to allow separation of the instructions and data + Count to 10 From f539834591a02472a2590692039b0b534083d043 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 14:45:27 -0300 Subject: [PATCH 9/9] remove counting 10 --- site/topics/programming/counting_10.esap | 11 ----------- site/topics/programming/counting_10.hex | 12 ------------ 2 files changed, 23 deletions(-) delete mode 100644 site/topics/programming/counting_10.esap delete mode 100644 site/topics/programming/counting_10.hex diff --git a/site/topics/programming/counting_10.esap b/site/topics/programming/counting_10.esap deleted file mode 100644 index 3016b486..00000000 --- a/site/topics/programming/counting_10.esap +++ /dev/null @@ -1,11 +0,0 @@ -LDAD 0 -SAVA 0xF -LDAR 0xF -LDBD 1 -ADAB -SAVA 0xF -OUTU 0xF -LDBD 10 -SUAB -JMPS 0x2 -HALT \ No newline at end of file diff --git a/site/topics/programming/counting_10.hex b/site/topics/programming/counting_10.hex deleted file mode 100644 index a592c8cc..00000000 --- a/site/topics/programming/counting_10.hex +++ /dev/null @@ -1,12 +0,0 @@ -v2.0 raw -0x20 -0x5f -0x1f -0x41 -0x70 -0x5f -0xdf -0x4a -0x80 -0xb2 -0xf0