From d741868078fc15fb6aff1a7c0a8827a442a4ed8b Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 13:23:22 -0300 Subject: [PATCH 1/7] add sec title --- site/topics/programming/programming-assembly.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index c94ccc37..128ba6f7 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -17,6 +17,12 @@ Counting Program +Count to 10 +=========== + + + + For Next Time ============= From 37ba131ddbf6076639e1bc9d2cf4dbe706410b26 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 14:46:03 -0300 Subject: [PATCH 2/7] add 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 767545aa80ef36a195b952d28ede1d84f09b6e9e Mon Sep 17 00:00:00 2001 From: James Alexander Hughes Date: Wed, 12 Mar 2025 15:04:59 -0300 Subject: [PATCH 3/7] ideas --- .../programming/programming-assembly.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 128ba6f7..c40c6106 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -20,6 +20,25 @@ Counting Program Count to 10 =========== +cleary assembler makes it easier +juggling the complexity of machine code and complex problems is hard +with the assembler, now it's much easier +consider a more vomplex problem combining some of the above ideas +count to 10, then stop + + 1 -- 10 + + +loop, but branching + +Below is the code + +CODE + +here, the jump S is used to loop +notice the storing of the value before doing sub 10 + +When running, it will appear that it counts 0 -- 10, but only because output reg starts at 0 From cef8fe20349a7fee7e821c31812b2d67f2bbb5a1 Mon Sep 17 00:00:00 2001 From: James Alexander Hughes Date: Wed, 12 Mar 2025 15:06:29 -0300 Subject: [PATCH 4/7] add code table --- .../programming/programming-assembly.rst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index c40c6106..296db674 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -33,12 +33,27 @@ loop, but branching Below is the code -CODE + .. list-table:: Count to 10 + :header-rows: 1 + :align: center + + * - Assembly + - Machine Code + + * - .. literalinclude:: counting_10.esap + :language: text + :lineno-match: + + - .. literalinclude:: counting_10.hex + :language: text + :lineno-match: + + here, the jump S is used to loop notice the storing of the value before doing sub 10 -When running, it will appear that it counts 0 -- 10, but only because output reg starts at 0 +When running, it will appear that it counts 0 -- 10, but only because output reg starts at 0 From 91e13ff42d93ccd22b81a32dcc3c3dec808cb6e6 Mon Sep 17 00:00:00 2001 From: James Alexander Hughes Date: Wed, 12 Mar 2025 15:13:02 -0300 Subject: [PATCH 5/7] intro problem --- .../programming/programming-assembly.rst | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 296db674..5a0afd58 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -20,18 +20,31 @@ Counting Program Count to 10 =========== -cleary assembler makes it easier -juggling the complexity of machine code and complex problems is hard -with the assembler, now it's much easier -consider a more vomplex problem combining some of the above ideas -count to 10, then stop +* With the use of the assembler, the programs are easier to write and understand +* This is important as solving complex problems is challenging enough as is - 1 -- 10 + * The tedium of machine code only makes solving complex problems that much more difficult -loop, but branching +* Since an assembler exists for the ESAP system, consider the more complex problem of counting to 10 -Below is the code + * Output the numbers ``1`` to ``10`` + * This may sound simple, but it is challenging when programming at such a low level + + +* This problem combines two of the previous problems + + * Counting forever + + * Required looping + + + * Checking if a value is less than 10 + + * Required branching + + +* Below is the assembly and corresponding machine code for a solution to this problem .. list-table:: Count to 10 :header-rows: 1 From 892829a7df77ca540b91226e1b50cc7e6af53157 Mon Sep 17 00:00:00 2001 From: James Alexander Hughes Date: Wed, 12 Mar 2025 15:27:15 -0300 Subject: [PATCH 6/7] discuss program nuance --- site/topics/programming/programming-assembly.rst | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 5a0afd58..5cf55b01 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -62,11 +62,21 @@ Count to 10 :lineno-match: +* Notice how the count value must be preserved before the subtraction can happen +* Here, the ``JMPS`` instruction is used like a kind of while loop -here, the jump S is used to loop -notice the storing of the value before doing sub 10 + * While the count is less than 10, jump -When running, it will appear that it counts 0 -- 10, but only because output reg starts at 0 + +* Note that, when running the program, it will appear to count ``0`` -- ``10`` + + * This is due to the simulator and how the output register starts with a ``0`` + + +* Additionally, the starting instructions of ``LDAD 0`` and ``SAVA 0xF`` could have been excluded + + * The simulator initializes RAM with ``0``\s + * However, having clear and intentional code is preferred From 17eab4897907c43982bbe80d6e1868c5d7ed566d Mon Sep 17 00:00:00 2001 From: James Hughes Date: Wed, 12 Mar 2025 16:21:16 -0300 Subject: [PATCH 7/7] clean: --- site/topics/programming/programming-assembly.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/topics/programming/programming-assembly.rst b/site/topics/programming/programming-assembly.rst index 5cf55b01..8a22fbab 100644 --- a/site/topics/programming/programming-assembly.rst +++ b/site/topics/programming/programming-assembly.rst @@ -26,7 +26,7 @@ Count to 10 * The tedium of machine code only makes solving complex problems that much more difficult -* Since an assembler exists for the ESAP system, consider the more complex problem of counting to 10 +* Consider the more complex problem of counting to 10 * Output the numbers ``1`` to ``10`` * This may sound simple, but it is challenging when programming at such a low level @@ -36,12 +36,12 @@ Count to 10 * Counting forever - * Required looping + * requires looping * Checking if a value is less than 10 - * Required branching + * requires branching * Below is the assembly and corresponding machine code for a solution to this problem