From e2c881cd2e2034c8c332e2fedd4b41a7d804ff9e Mon Sep 17 00:00:00 2001 From: Luxferre Date: Wed, 30 Apr 2025 11:23:16 +0300 Subject: [PATCH] updated the compound interest example --- README.md | 15 +++++++-------- examples/assembled/compound.mu8 | 13 ++++++------- examples/compound.mu8a | 11 +++++------ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 101a7f8..6f5d739 100644 --- a/README.md +++ b/README.md @@ -416,14 +416,13 @@ calculator from the official mu808 examples will transform into: 5000 DATA 0,0 5001 DATA 50100,1 5002 DATA 40002,30000 -5003 DATA 90002,10004 -5004 DATA 50001,5 -5005 DATA 70005,40005 -5006 DATA 130001,50005 -5007 DATA 70000,30005 -5008 DATA 130000,50005 -5009 DATA 30005,50000 -5010 DATA -1,0 +5003 DATA 90002,10005 +5004 DATA 70127,1270005 +5005 DATA 130001,50005 +5006 DATA 70000,30005 +5007 DATA 130000,50005 +5008 DATA 30005,50000 +5009 DATA -1,0 ``` To make the conversion easier, the official mu808 assembler, `mu808asm.py`, now supports the `t74` mode that accepts a plain MU8 machine code file and outputs diff --git a/examples/assembled/compound.mu8 b/examples/assembled/compound.mu8 index 9aa94e6..737cbf3 100644 --- a/examples/assembled/compound.mu8 +++ b/examples/assembled/compound.mu8 @@ -1,9 +1,8 @@ 1 5 100 0 1 2 4 2 3 0 -3 9 2 1 4 -4 5 1 0 5 -5 7 5 4 5 -6 13 1 5 5 -7 7 0 3 5 -8 13 0 5 5 -9 3 5 5 0 +3 9 2 1 5 +4 7 127 127 5 +5 13 1 5 5 +6 7 0 3 5 +7 13 0 5 5 +8 3 5 5 0 diff --git a/examples/compound.mu8a b/examples/compound.mu8a index 2aa4536..6c7f35f 100644 --- a/examples/compound.mu8a +++ b/examples/compound.mu8a @@ -4,10 +4,9 @@ set 100 0 1 ; store the constant 100 at loc 1 inp 2 3 0 ; prompt for the percentage into loc 2 and the period into loc 3 -div 2 1 4 ; divide the percentage value at loc 2 by the constant at loc 1 into loc 4 -set 1 0 5 ; set the loc 5 to 1 -fma 5 4 5 ; add the constant at loc 5 to the value at loc 4 into loc 5 -nel 1 5 5 ; replace loc 5 with its ln -fma 0 3 5 ; replace loc 5 with loc 3 * ln loc 5 -nel 0 5 5 ; replace loc 4 with its nexp +div 2 1 5 ; divide the percentage value at loc 2 by the constant at loc 1 into loc 5 +inc 5 ; increment loc 5 +log 5 5 ; replace loc 5 with its ln +mul 3 5 ; replace loc 5 with loc 3 * ln loc 5 +exp 5 5 ; replace loc 5 with its nexp out 5 5 0 ; output the resulting value