From 884fc5170385ad3179ad7f8c07b3a647a90ef12d Mon Sep 17 00:00:00 2001 From: Mark Allott Date: Thu, 11 Sep 2025 09:08:53 +0100 Subject: [PATCH 1/8] Ignore Rider idea folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5c8a8e9..42ad913 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ riderModule.iml YODA_Python/venv/ YODA_TypeScript/node_modules/ YODA_Python/__pycache__/ +.idea/ From cf0ac99fd196e2c8bd267007844a9dd74216dec3 Mon Sep 17 00:00:00 2001 From: Mark Allott Date: Thu, 11 Sep 2025 13:40:16 +0100 Subject: [PATCH 2/8] Add boot-allzero and partial files --- Mark-Henry-Manual-Method/boot-allzero | Bin 0 -> 256 bytes Mark-Henry-Manual-Method/boot004 | Bin 0 -> 4 bytes Mark-Henry-Manual-Method/boot008 | Bin 0 -> 8 bytes Mark-Henry-Manual-Method/boot016 | Bin 0 -> 16 bytes Mark-Henry-Manual-Method/boot032 | Bin 0 -> 32 bytes Mark-Henry-Manual-Method/boot064 | Bin 0 -> 64 bytes Mark-Henry-Manual-Method/boot128 | Bin 0 -> 128 bytes 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Mark-Henry-Manual-Method/boot-allzero create mode 100644 Mark-Henry-Manual-Method/boot004 create mode 100644 Mark-Henry-Manual-Method/boot008 create mode 100644 Mark-Henry-Manual-Method/boot016 create mode 100644 Mark-Henry-Manual-Method/boot032 create mode 100644 Mark-Henry-Manual-Method/boot064 create mode 100644 Mark-Henry-Manual-Method/boot128 diff --git a/Mark-Henry-Manual-Method/boot-allzero b/Mark-Henry-Manual-Method/boot-allzero new file mode 100644 index 0000000000000000000000000000000000000000..65f57c2ee985713476ac0b6e3483e6fe472e2176 GIT binary patch literal 256 LcmZQz7})>-0RR92 literal 0 HcmV?d00001 diff --git a/Mark-Henry-Manual-Method/boot004 b/Mark-Henry-Manual-Method/boot004 new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/Mark-Henry-Manual-Method/boot008 b/Mark-Henry-Manual-Method/boot008 new file mode 100644 index 0000000000000000000000000000000000000000..1b1cb4d44c57c2d7a5122870fa6ac3e62ff7e94e GIT binary patch literal 8 KcmZQzfB*mh2mk>9 literal 0 HcmV?d00001 diff --git a/Mark-Henry-Manual-Method/boot016 b/Mark-Henry-Manual-Method/boot016 new file mode 100644 index 0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911d0c8cc43a4170a9 GIT binary patch literal 16 KcmZQzKm`B*5C8!H literal 0 HcmV?d00001 diff --git a/Mark-Henry-Manual-Method/boot032 b/Mark-Henry-Manual-Method/boot032 new file mode 100644 index 0000000000000000000000000000000000000000..4e4e4935707a596987ec1cc32e3d0d587dbe4f04 GIT binary patch literal 32 KcmZQzzz+ZbAOHaX literal 0 HcmV?d00001 diff --git a/Mark-Henry-Manual-Method/boot064 b/Mark-Henry-Manual-Method/boot064 new file mode 100644 index 0000000000000000000000000000000000000000..9017fd98b5f67d928cc64c59b2c025472ce74f8c GIT binary patch literal 64 LcmZQzpbP*206+i% literal 0 HcmV?d00001 diff --git a/Mark-Henry-Manual-Method/boot128 b/Mark-Henry-Manual-Method/boot128 new file mode 100644 index 0000000000000000000000000000000000000000..00bc0474794e909101dcb2b0c7c809cfbe2bd665 GIT binary patch literal 128 LcmZQz7+3%R0Du4i literal 0 HcmV?d00001 From 31592280185295046319284acfbf3833cf76ffcd Mon Sep 17 00:00:00 2001 From: Mark Allott Date: Thu, 11 Sep 2025 15:07:00 +0100 Subject: [PATCH 3/8] Solution description and exercise 1 boot file --- Mark-Henry-Manual-Method/Solution.md | 123 +++++++++++++++++++++++++++ Mark-Henry-Manual-Method/boot-ex1 | Bin 0 -> 256 bytes 2 files changed, 123 insertions(+) create mode 100644 Mark-Henry-Manual-Method/Solution.md create mode 100644 Mark-Henry-Manual-Method/boot-ex1 diff --git a/Mark-Henry-Manual-Method/Solution.md b/Mark-Henry-Manual-Method/Solution.md new file mode 100644 index 0000000..17dc025 --- /dev/null +++ b/Mark-Henry-Manual-Method/Solution.md @@ -0,0 +1,123 @@ +# Manual solutions by Mark and Henry + +## Step 1 - prepare the ground + +All projects benefit from a little preparation and good groundwork... Reading the readme and the manual (I know, shock, horror actually reading!!), it states that the boot files we need to be executed should all be 256 bytes long. Therefore, as a first step, creating a template boot file would benefit later exercises, where the template could be copied and edited _manually_, i.e. there's no actual coding per se, just old fashioned mangling of the boot files, a la flicking of switches to set the program states as happened on _really_ old systems! + +### Step 1.1 - template boot file +To create the boot file, as we were using a combination of dotnet on MXLinux and node on OSX, we both had a supply of lovely unix-style commands that can be utilised to generate the file. One simple way to generate the file is to create a small file with an initial number of zero-byte entries, then concatenate these files in order to create the ultimate goal of a file (called `boot-allzero`) that contains 256 zero bytes. The command `printf` was used initially to create a small 4-byte long file, then this was used to essentially double-up the length of the file (through intermediate files) until the magic file was generated. +Starting in our "solution folder" called `Mark-Henry-Manual-Method`, a shell was opened and the following commands executed sequentially: + +```shell +printf "\x00\x00\x00\x00" > boot004 +cat boot004 > boot008 && cat boot004 >> boot008 +cat boot008 > boot016 && cat boot008 >> boot016 +cat boot016 > boot032 && cat boot016 >> boot032 +cat boot032 > boot064 && cat boot032 >> boot064 +cat boot064 > boot128 && cat boot064 >> boot128 +cat boot128 > boot-allzero && cat boot128 >> boot-allzero +``` +Checking the final file, we can use the following command to verify it is as expected: +```shell +hexdump boot-allzero +0000000 0000 0000 0000 0000 0000 0000 0000 0000 +* +0000100 +``` +This confirms the boot-file is indeed 256 bytes long and contains all zeros :) +### Step 1.2 - Verify YODA compiles and works as expected +Before starting the exercises proper, it would be nice to know that the machine can be run successfully. Opening a fresh terminal window, then navigating into the YODA folder, the following commands were executed to ensure the program compiles using the selected methods: dotnet and TypeScript. +#### Step 1.2.1 - dotnet checks +1. From the terminal, navigate into the YODA folder +2. At the terminal, use the command `dotnet build SimpleInstructionMachine.csproj` to build the project. If all works correctly, the something like the following shall be output to the terminal window: +```terminaloutput +Restore complete (0.5s) +SimpleInstructionMachine succeeded (0.3s) → bin/Debug/net9.0/SimpleInstructionMachine.dll + +Build succeeded in 1.2s +``` +3. Next step is to get it to run, without specifying any boot file, which ought to inform us whether it is ready and if it succeeded in booting, which it shouldn't be able to as no boot fille has been supplied yet. Issuing the following command at the termninal `dotnet run` should result in something like the following output: +```terminaloutput +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: . + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +No boot file found. + + +Program completed successfully +``` +4. Success! Well, kind of... It runs without nasty errors, but doesn't do anything + +#### Step 1.2.2 - TypeScript checks +1. From the terminal, navigate into the YODA_TypeScript folder +2. First thing we need to do is make sure we have the toolchain needed to make this work. First up is node (or nvm, if you happen to operate in differing versions of node). To check if it is installed, try executing `node --version` from the terminal window. If successful, then node is installed; if not then you need to follow the required steps to install node for your own system as it's beyond the scope of what we're trying to do today! +3. Next, as we have the program in TypeScript we need to convert to JavaScript so node knows how to run it... From the terminal, try the command `tsc --version` - if a value is returned, then we're good to go. Otherwise, try using npm to install it globally using the following command: `npm install -g typescript`. If that completes successfully, then the typescript package should now be able to compile the TypeScript source to JavaScript for us. +4. From the manual, we now need to ensure that the remainder of the required files are present, so we need to run `npm install` and wait for it to fetch/install everything else we need +5. If all is well up to this point, then we should be ready to execute `npm start` to ensure that the program runs without any nasty errors. If it works as expected, then you should see something like the following output: +```terminaloutput +> simple-instruction-machine@1.0.0 start +> ts-node main.ts + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: . + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +No boot file found. + + +Program completed successfully +``` +6. Success again (hopefully)! Again, it runs without errors, but not boot file has been supplied, so it's not really doing anything. + +## Step 1.3 - Exercise 1 +Now it's time to generate a dummy boot file and check it works. We do this by doing the following from the terminal in the `Mark-Henry-Manual-Method` folder: +```shell +cp boot-allzero boot-ex1 +cp boot-ex1 boot +``` +We've now created a boot file for use in Exercise 1 (boot-ex1) from the template and then copied that to the actual boot file the simulator will use. Time to test the simulator properly, with a blank boot file. First, from the dotnet platform: +```terminaloutput +dotnet run ../Mark-Henry-Manual-Method/ --debug +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). + + +Program completed successfully +``` +Then, from node: +```terminaloutput +npm start ../Mark-Henry-Manual-Method/ + +> simple-instruction-machine@1.0.0 start +> ts-node main.ts ../Mark-Henry-Manual-Method/ + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). + + +Program completed successfully +``` +~~~~ \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/boot-ex1 b/Mark-Henry-Manual-Method/boot-ex1 new file mode 100644 index 0000000000000000000000000000000000000000..65f57c2ee985713476ac0b6e3483e6fe472e2176 GIT binary patch literal 256 LcmZQz7})>-0RR92 literal 0 HcmV?d00001 From c3f3992a9bdccec31047a35472070ddf51c31f69 Mon Sep 17 00:00:00 2001 From: Mark Allott Date: Thu, 11 Sep 2025 17:52:52 +0100 Subject: [PATCH 4/8] Update Solution description and add exercise 2 boot file --- Mark-Henry-Manual-Method/Solution.md | 55 ++++++++++++++++++++++++++- Mark-Henry-Manual-Method/boot-ex2 | Bin 0 -> 256 bytes 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 Mark-Henry-Manual-Method/boot-ex2 diff --git a/Mark-Henry-Manual-Method/Solution.md b/Mark-Henry-Manual-Method/Solution.md index 17dc025..e79ed1a 100644 --- a/Mark-Henry-Manual-Method/Solution.md +++ b/Mark-Henry-Manual-Method/Solution.md @@ -78,7 +78,7 @@ Program completed successfully ``` 6. Success again (hopefully)! Again, it runs without errors, but not boot file has been supplied, so it's not really doing anything. -## Step 1.3 - Exercise 1 +## Exercise 1 Now it's time to generate a dummy boot file and check it works. We do this by doing the following from the terminal in the `Mark-Henry-Manual-Method` folder: ```shell cp boot-allzero boot-ex1 @@ -120,4 +120,55 @@ Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). Program completed successfully ``` -~~~~ \ No newline at end of file +## Exercise 2 +A blank boot file is now working, so time to throw a virtual spanner in the works to make sure the simulator operates as expected and generates error files when given a weird instruction. To set this up, we need to generate the boot file for example 2 from the template, then edit the file and insert the dodgy instruction as follows: +```shell +cp boot-allzero boot-ex2 +hexedit boot-ex2 +``` +Once opened, change the first byte in the boot file to `FF`, as per the instructions, then save the file and exit hexedit. Once back in the terminal, the following command was executed to copy the modified file to become the new boot file: +```shell +cp boot-ex2 boot +``` +Now the boot file is prepared, time to test using dotnet first: +```terminaloutput +dotnet run ../Mark-Henry-Manual-Method/ --debug +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). +Your program has crashed, things aren't looking to good for the space craft. + +Unknown command 255 +Instruction Pointer: 0 +Opcode: 255 + +A crash dump containing all the memory has been written to : crash_dump and crash_dump.txt +``` +Then, with node: +```terminaloutput +npm start ../Mark-Henry-Manual-Method/ debug + +> simple-instruction-machine@1.0.0 start +> ts-node main.ts ../Mark-Henry-Manual-Method/ debug + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). +Your program has crashed! +Unknown command 255 +Instruction Pointer: 0 +Opcode: 255 +``` +In both cases, we received the correct output, i.e. opCode `0xFF` is invalid, both in dotnet and node and crash dumps were written into the appropriate locations detailing what was wrong :) diff --git a/Mark-Henry-Manual-Method/boot-ex2 b/Mark-Henry-Manual-Method/boot-ex2 new file mode 100644 index 0000000000000000000000000000000000000000..551efc7e0b7f179a2aad5478bc5d4d56e72b2567 GIT binary patch literal 256 Lcmey*FtPyv01p8G literal 0 HcmV?d00001 From 502b1ca2d5dc0322767a86ee71ec662b1bd27593 Mon Sep 17 00:00:00 2001 From: Mark Allott Date: Fri, 12 Sep 2025 07:13:51 +0100 Subject: [PATCH 5/8] Update Solution description file, add boot file for exercise 3 --- Mark-Henry-Manual-Method/Solution.md | 79 +++++++++++++++++++++++++++ Mark-Henry-Manual-Method/boot-ex3 | Bin 0 -> 256 bytes 2 files changed, 79 insertions(+) create mode 100644 Mark-Henry-Manual-Method/boot-ex3 diff --git a/Mark-Henry-Manual-Method/Solution.md b/Mark-Henry-Manual-Method/Solution.md index e79ed1a..9745141 100644 --- a/Mark-Henry-Manual-Method/Solution.md +++ b/Mark-Henry-Manual-Method/Solution.md @@ -172,3 +172,82 @@ Instruction Pointer: 0 Opcode: 255 ``` In both cases, we received the correct output, i.e. opCode `0xFF` is invalid, both in dotnet and node and crash dumps were written into the appropriate locations detailing what was wrong :) + +## Exercise 3 +In order to complete this exercise, we debated which of the opCodes representing the SaveToFile instructions might be best to use. As the exercise hints strongly which opCode might be the one to use, we opted for the Immediate/Immediate/Immediate option, as this would allow us to specify the file, a location in memory for the data and a length all in one "easy" instruction. To accomplish this, we created the new boot file, then edited the file using hexedit again: +```shell +cp boot-allzero boot-ex3 +hexedit boot-ex3 +``` +Once inside hexedit, starting at address 0, the following entries were input: +`17`, `00`, `20`, `05`, `01`. +Now the program is in-place, using hexedit again, this time at address 0x20, the following entries were made: `05`, `04`, `03`, `02`, `01`. Once completed, the file was saved and hexedit was exited. Now we have the file,time to do a quick check on the contents: +```terminaloutput +hexdump boot-ex3 +0000000 0017 0520 0001 0000 0000 0000 0000 0000 +0000010 0000 0000 0000 0000 0000 0000 0000 0000 +0000020 0405 0203 0001 0000 0000 0000 0000 0000 +0000030 0000 0000 0000 0000 0000 0000 0000 0000 +* +0000100 +``` +Hmm... That doesn't look right! A quick review of the `man` page for hexdump hints why: the default output groups contents into pairs of bytes, which means the values are going to appear grouped as if they were 16-bit values. Time to try a different output option: +```terminaloutput +hexdump -C boot-ex3 +00000000 17 00 20 05 01 00 00 00 00 00 00 00 00 00 00 00 |.. .............| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 05 04 03 02 01 00 00 00 00 00 00 00 00 00 00 00 |................| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +* +00000100 +``` +Ok - that looks much better. All bytes are being displayed sequentially and it also tries to convert the values into ASCII text as well! The prepared boot file was then copied as the new boot file using: +```shell +cp boot-ex3 boot +``` +Now the boot file is ready, time to test it again, dotnet first, followed by node: +```terminaloutput +dotnet run ../Mark-Henry-Manual-Method/ --debug +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). +00000000 SaveToFile:: Writing 5 bytes starting at 00000020 to file 0. +00000004 Wait:: + + +Program completed successfully + + +npm start ../Mark-Henry-Manual-Method/ debug + +> simple-instruction-machine@1.0.0 start +> ts-node main.ts ../Mark-Henry-Manual-Method/ debug + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). +0 SaveToFile:: Writing 5 bytes from 20. +4 Wait:: + + +Program completed successfully +``` +Looks like the program has done as requested, so time to check it: +```terminaloutput +hexdump -C ../Mark-Henry-Manual-Method/0 +00000000 05 04 03 02 01 |.....| +00000005 +``` +Looks like we have the right contents in the specified file, so we'll count that as successful! \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/boot-ex3 b/Mark-Henry-Manual-Method/boot-ex3 new file mode 100644 index 0000000000000000000000000000000000000000..bb7a4f51b7c35388ae339465466be9f7f2cf4765 GIT binary patch literal 256 ZcmWe Date: Fri, 12 Sep 2025 07:47:45 +0100 Subject: [PATCH 6/8] Update Solution description file, add boot file for exercise 4 and output file --- Mark-Henry-Manual-Method/9.txt | 1 + Mark-Henry-Manual-Method/Solution.md | 69 ++++++++++++++++++++++++++- Mark-Henry-Manual-Method/boot-ex4 | Bin 0 -> 256 bytes 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Mark-Henry-Manual-Method/9.txt create mode 100644 Mark-Henry-Manual-Method/boot-ex4 diff --git a/Mark-Henry-Manual-Method/9.txt b/Mark-Henry-Manual-Method/9.txt new file mode 100644 index 0000000..4dd7de8 --- /dev/null +++ b/Mark-Henry-Manual-Method/9.txt @@ -0,0 +1 @@ +5 4 3 2 1 LIFTOFF \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/Solution.md b/Mark-Henry-Manual-Method/Solution.md index 9745141..8fec935 100644 --- a/Mark-Henry-Manual-Method/Solution.md +++ b/Mark-Henry-Manual-Method/Solution.md @@ -250,4 +250,71 @@ hexdump -C ../Mark-Henry-Manual-Method/0 00000000 05 04 03 02 01 |.....| 00000005 ``` -Looks like we have the right contents in the specified file, so we'll count that as successful! \ No newline at end of file +Looks like we have the right contents in the specified file, so we'll count that as successful! + +## Exercise 4 +As this looks like a very similar exercise as the previous one, we re-used the previous file, copying it to provide the boot-ex4 file we needed, then edited it: +```shell +cp boot-ex3 boot-ex4 +hexedit boot-ex4 +``` +Inside hexedit, instead of using the hex editing facility, time to use the character side - that'll make life so much easier! Once there, at address 0x20, the string `5 4 3 2 1 LIFTOFF` was entered, noting that it needed 17 bytes (0x11 hex) to store it. Now the string is entered, time alter the opCode instructions so they perform the correct operation: switching back to the hex side, address 0x01 was altered to `09` and address 0x03 was altered to `11`, ensuring the output is directed to file 9 and has a length of 17 bytes. Saving the file in hexedit and quitting, we checked the file for correctness: +```terminaloutput +hexdump -C boot-ex4 +00000000 17 09 20 11 01 00 00 00 00 00 00 00 00 00 00 00 |.. .............| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 35 20 34 20 33 20 32 20 31 20 4c 49 46 54 4f 46 |5 4 3 2 1 LIFTOF| +00000030 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |F...............| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +* +00000100 +``` +That looks good, so time to copy it as the boot file: +```shell +cp boot-ex4 boot +``` +Now, test again with dotnet and node: +```terminaloutput +dotnet run ../Mark-Henry-Manual-Method/ --debug +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). +00000000 SaveToFile:: Writing 17 bytes starting at 00000020 to file 9. +00000004 Wait:: + + +Program completed successfully + + +npm start ../Mark-Henry-Manual-Method/ debug + +> simple-instruction-machine@1.0.0 start +> ts-node main.ts ../Mark-Henry-Manual-Method/ debug + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). +0 SaveToFile:: Writing 17 bytes from 20. +4 Wait:: + + +Program completed successfully +``` +As the output should be a text file, we checked the output using the following: +```terminaloutput +cat 9.txt +5 4 3 2 1 LIFTOFF +``` +Again, that looks good, so we'll take that as a success :) \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/boot-ex4 b/Mark-Henry-Manual-Method/boot-ex4 new file mode 100644 index 0000000000000000000000000000000000000000..22cf763b25f23b480f46981ec6432a7e708925a3 GIT binary patch literal 256 kcmWgVR1jojzzs|lOcab2j1&wNd_3Jk{N3DeD;<(D0A&&b`~Uy| literal 0 HcmV?d00001 From 117935233d2279e6e0507301996ecf5a3b4eb809 Mon Sep 17 00:00:00 2001 From: Mark Allott Date: Fri, 12 Sep 2025 08:46:59 +0100 Subject: [PATCH 7/8] Update Solution description, add boot files for exercise 5 and fuel file --- Mark-Henry-Manual-Method/1 | 1 + Mark-Henry-Manual-Method/Solution.md | 89 +++++++++++++++++++++++- Mark-Henry-Manual-Method/boot-ex5 | Bin 0 -> 256 bytes Mark-Henry-Manual-Method/boot-refuel123 | Bin 0 -> 256 bytes 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Mark-Henry-Manual-Method/1 create mode 100644 Mark-Henry-Manual-Method/boot-ex5 create mode 100644 Mark-Henry-Manual-Method/boot-refuel123 diff --git a/Mark-Henry-Manual-Method/1 b/Mark-Henry-Manual-Method/1 new file mode 100644 index 0000000..e25f181 --- /dev/null +++ b/Mark-Henry-Manual-Method/1 @@ -0,0 +1 @@ +y \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/Solution.md b/Mark-Henry-Manual-Method/Solution.md index 8fec935..b1781fd 100644 --- a/Mark-Henry-Manual-Method/Solution.md +++ b/Mark-Henry-Manual-Method/Solution.md @@ -317,4 +317,91 @@ As the output should be a text file, we checked the output using the following: cat 9.txt 5 4 3 2 1 LIFTOFF ``` -Again, that looks good, so we'll take that as a success :) \ No newline at end of file +Again, that looks good, so we'll take that as a success :) + +## Exercise 5 +After looking at the description, we decided to make this a "2 boot file" approach - one to actually write the fuel quantity to file 1, then another to decrement the fuel value. To start with, we created the two new boot files to be edited using the following commands: +```shell +cp boot-allzero boot-refuel123 +cp boot-allzero boot-ex5 +``` +Looking at the instructions, the first step of writing a program to "refuel" should be very similar to writing output in earlier exercises, so we'll re-use the same methods. Starting with the command: +```shell +hexedit boot-refuel123 +``` +We then entered, starting from address 0x00, the following: `17`, `01`, `20`, `01`, then at address 0x20, the value `7B` (hex for 123 decimal) was entered and the file saved and hexedit quit. Checking the file works as expected, the following was executed: +```terminaloutput +cp boot-refuel123 boot + +dotnet run ../Mark-Henry-Manual-Method/ --debug && hexdump -C ../Mark-Henry-Manual-Method/1 +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). +00000000 SaveToFile:: Writing 1 bytes starting at 00000020 to file 1. + + +Program completed successfully +00000000 7b |{| +00000001 +``` +Now we have the "refuel" program working as expected, time to move on to the program to read the fuel level, decrement it, then write out the new value. The plan is to: +1. Use one of the LoadFromFile opCodes to load the current fuel value into a "data area" in the simulator's memory +2. Decrement the value in the "data area" +3. Write out the new value to the file +4. Use a "high" memory address that sits between the end of the program and under the stack area. For no real reason, address 0xC0 was used, as it fits those requirements pretty well. + +The decision was made to use the "immediate" memory access methods as these work very nicely for us. Running `hexedit boot-ex5` allows us to enter the following hex values for the program: `23`, `01`, `C0`, `71`, `C0`, `17`, `01`, `C0`, `01`. Saving the file and quitting hexedit, the following commands were executed: +```terminaloutput +cp boot-ex5 boot + +dotnet run ../Mark-Henry-Manual-Method/ --debug && hexdump -C ../Mark-Henry-Manual-Method/1 +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). +00000000 LoadFromFile:: Reading from file 1 into 000000c0. +00000003 Dec:: Decreasing value in 000000c0 from 123 to 122 +00000005 SaveToFile:: Writing 1 bytes starting at 000000c0 to file 1. + + +Program completed successfully +00000000 7a |z| +00000001 +``` +All looking good so far - dotnet opens the file, decrements and writes it back. Time for node to do the same: +```terminaloutput +npm start ../Mark-Henry-Manual-Method/ debug && hexdump -C ../Mark-Henry-Manual-Method/1 + +> simple-instruction-machine@1.0.0 start +> ts-node main.ts ../Mark-Henry-Manual-Method/ debug + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). +0 LoadFromFile:: Reading into c0. +3 Dec:: 122 -> 121 +5 SaveToFile:: Writing 1 bytes from c0. + + +Program completed successfully +00000000 79 |y| +00000001 +``` +Success - node also does exactly as expected and we've now used 2 fuel units! Hope that won't compromise the launch too much... Although we could always refuel ;) \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/boot-ex5 b/Mark-Henry-Manual-Method/boot-ex5 new file mode 100644 index 0000000000000000000000000000000000000000..05f084f5c3a6c34a579cf5996888cc1ef4454f0a GIT binary patch literal 256 TcmY#pJWzN*obdo7!^i{x Date: Fri, 12 Sep 2025 15:49:39 +0100 Subject: [PATCH 8/8] Update Solution description, add boot file for exercise 6 --- Mark-Henry-Manual-Method/Solution.md | 168 ++++++++++++++++++++++++++- Mark-Henry-Manual-Method/boot-ex6 | Bin 0 -> 256 bytes 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 Mark-Henry-Manual-Method/boot-ex6 diff --git a/Mark-Henry-Manual-Method/Solution.md b/Mark-Henry-Manual-Method/Solution.md index b1781fd..2e30070 100644 --- a/Mark-Henry-Manual-Method/Solution.md +++ b/Mark-Henry-Manual-Method/Solution.md @@ -404,4 +404,170 @@ Program completed successfully 00000000 79 |y| 00000001 ``` -Success - node also does exactly as expected and we've now used 2 fuel units! Hope that won't compromise the launch too much... Although we could always refuel ;) \ No newline at end of file +Success - node also does exactly as expected and we've now used 2 fuel units! Hope that won't compromise the launch too much... Although we could always refuel ;) + +## Exercise 6 +Time for some LCD fun - to get this to work will require the output for the LCD to be stored in a memory area, the LCD display to be set, then flag the display to refresh, wait, then clear the LCD refresh. Rinse and repeat until the display cycle completes the sequence. + +One way to do this would be to have a loop that cycles around until the next digit to be displayed is the `NULL` byte. Whilst sensible to do that, time is of the essence here and working out how many bytes are needed for jumping around isn't exactly conducive to saving time. Therefore, the simpler approach of telling the program to update the LCD with specific values 5 times makes for a quicker approach. Therefore the following pseudo-code for the program makes for a little easier working out the byte sequences for hexedit mangling later: +```terminaloutput +Address | Operation +0x00 | Write_ID F8 C0 // Write value from C0 to F8 (LCD Seg1) +0x03 | Write_II FD 01 // Write 0x01 to FD (set LCD Refresh) +0x06 | Wait +0x07 | Write_II FD 00 // Write 0x00 to FD (clear LCD Refresh) + +0x0A | Write_ID F8 C1 // Write value from C1 to F8 (LCD Seg1) +0x0D | Write_II FD 01 // Write 0x01 to FD (set LCD Refresh) +0x10 | Wait +0x11 | Write_II FD 00 // Write 0x00 to FD (clear LCD Refresh) + +0x14 | Write_ID F8 C2 // Write value from C2 to F8 (LCD Seg1) +0x17 | Write_II FD 01 // Write 0x01 to FD (set LCD Refresh) +0x1a | Wait +0x1b | Write_II FD 00 // Write 0x00 to FD (clear LCD Refresh) + +0x1e | Write_ID F8 C3 // Write value from C3 to F8 (LCD Seg1) +0x21 | Write_II FD 01 // Write 0x01 to FD (set LCD Refresh) +0x24 | Wait +0x25 | Write_II FD 00 // Write 0x00 to FD (clear LCD Refresh) + +0x28 | Write_ID F8 C4 // Write value from C4 to F8 (LCD Seg1) +0x2b | Write_II FD 01 // Write 0x01 to FD (set LCD Refresh) +0x2e | Wait +0x2f | Write_II FD 00 // Write 0x00 to FD (clear LCD Refresh) +0x32 | 0x00 // Done +~~~~ +0xC0 | 54321 (text data) +``` +Translating that into physcial hex codes that we can use in hexedit would be as follows: +```terminaloutput +Address | Hex Codes +0x00 | 32 F8 C0 33 FD 01 01 33 FD 00 +0x0A | 32 F8 C1 33 FD 01 01 33 FD 00 +0x14 | 32 F8 C2 33 FD 01 01 33 FD 00 +0x1e | 32 F8 C3 33 FD 01 01 33 FD 00 +0x28 | 32 F8 C4 33 FD 01 01 33 FD 00 +~~~~ +0xC0 | 35 34 33 32 31 +``` +Next up, we need a blank boot file, so we run `cp boot-all-zero boot-ex6` to create it, then `hexedit boot-ex6` to fill in the needed hex codes from the table above. Once done, we save and exit and check our boot file matches our expectations: +```terminaloutput +hd boot-ex6 +00000000 32 f8 c0 33 fd 01 01 33 fd 00 32 f8 c1 33 fd 01 |2..3...3..2..3..| +00000010 01 33 fd 00 32 f8 c2 33 fd 01 01 33 fd 00 32 f8 |.3..2..3...3..2.| +00000020 c3 33 fd 01 01 33 fd 00 32 f8 c4 33 fd 01 01 33 |.3...3..2..3...3| +00000030 fd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +* +000000c0 35 34 33 32 31 00 00 00 00 00 00 00 00 00 00 00 |54321...........| +000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +* +00000100 +``` +That looks good, so we copy that as the new boot file by running `cp boot-ex6 boot` and run via dotnet and node to check it does actually work as expected: +```terminaloutput +dotnet run ../Mark-Henry-Manual-Method/ --debug +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory has been initialised using the boot file (../Mark-Henry-Manual-Method/boot). +00000000 Write:: 53 into F8 +00000003 Write:: 1 into FD +--------------------- +| 5 | | | | | +--------------------- +00000006 Wait:: +00000007 Write:: 0 into FD +0000000a Write:: 52 into F8 +0000000d Write:: 1 into FD +--------------------- +| 4 | | | | | +--------------------- +00000010 Wait:: +00000011 Write:: 0 into FD +00000014 Write:: 51 into F8 +00000017 Write:: 1 into FD +--------------------- +| 3 | | | | | +--------------------- +0000001a Wait:: +0000001b Write:: 0 into FD +0000001e Write:: 50 into F8 +00000021 Write:: 1 into FD +--------------------- +| 2 | | | | | +--------------------- +00000024 Wait:: +00000025 Write:: 0 into FD +00000028 Write:: 49 into F8 +0000002b Write:: 1 into FD +--------------------- +| 1 | | | | | +--------------------- +0000002e Wait:: +0000002f Write:: 0 into FD + + +Program completed successfully + +npm start ../Mark-Henry-Manual-Method/ debug + +> simple-instruction-machine@1.0.0 start +> ts-node main.ts ../Mark-Henry-Manual-Method/ debug + +Starting landing computer running York's Obscenely Dumb Architecture (YODA) - Release Build 12x.11g-34 + Anti-gravity module +Folder Path: ../Mark-Henry-Manual-Method/ + +Connecting to Engine Control System.... SUCCESS! +Connecting to Landing Control System.... SUCCESS! +Connecting to Interplanetary Communication System.... SUCCESS! +All systems are GO! + +Memory initialised using boot file (../Mark-Henry-Manual-Method/boot). +0 Write:: 53 into f8 +3 Write:: 1 into fd +--------------------- +| 5 | | | | | +--------------------- +6 Wait:: +7 Write:: 0 into fd +a Write:: 52 into f8 +d Write:: 1 into fd +--------------------- +| 4 | | | | | +--------------------- +10 Wait:: +11 Write:: 0 into fd +14 Write:: 51 into f8 +17 Write:: 1 into fd +--------------------- +| 3 | | | | | +--------------------- +1a Wait:: +1b Write:: 0 into fd +1e Write:: 50 into f8 +21 Write:: 1 into fd +--------------------- +| 2 | | | | | +--------------------- +24 Wait:: +25 Write:: 0 into fd +28 Write:: 49 into f8 +2b Write:: 1 into fd +--------------------- +| 1 | | | | | +--------------------- +2e Wait:: +2f Write:: 0 into fd + + +Program completed successfully +``` + +That all looks good for the end of exercise 6. No more time to do any further exercises on the night \ No newline at end of file diff --git a/Mark-Henry-Manual-Method/boot-ex6 b/Mark-Henry-Manual-Method/boot-ex6 new file mode 100644 index 0000000000000000000000000000000000000000..cd3e02b44f9c38760fb067bf8aa5b4cb5df1a179 GIT binary patch literal 256 qcmXr|alrU5Bct(O2BRMb;jBY&)?qm72$aPzsDP=7v5_GKE&>3>C>DkQ literal 0 HcmV?d00001