diff options
author | Wojciech Kosior <kwojtus@protonmail.com> | 2020-09-01 10:54:59 +0200 |
---|---|---|
committer | Wojciech Kosior <kwojtus@protonmail.com> | 2020-09-01 11:04:22 +0200 |
commit | ee1f6c47e1eff920068f4bceaf604f9535a2e8a9 (patch) | |
tree | 580eb001a72601d254bb29cc348a529490f84808 /tests/stack_machine_mul/instructions.s.tcl | |
parent | cd02ddff8886aa1db29f80d3cc5cf99a349d8258 (diff) | |
download | AGH-engineering-thesis-ee1f6c47e1eff920068f4bceaf604f9535a2e8a9.tar.gz AGH-engineering-thesis-ee1f6c47e1eff920068f4bceaf604f9535a2e8a9.zip |
start anew
Diffstat (limited to 'tests/stack_machine_mul/instructions.s.tcl')
-rwxr-xr-x | tests/stack_machine_mul/instructions.s.tcl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/stack_machine_mul/instructions.s.tcl b/tests/stack_machine_mul/instructions.s.tcl new file mode 100755 index 0000000..8473aef --- /dev/null +++ b/tests/stack_machine_mul/instructions.s.tcl @@ -0,0 +1,42 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### store 4 values to memory; load 2 of them back, multiply them and store the +### result; load another 2, multiply them and store the result; +### this is similar to addition and substraction tests + +set_sp h7FFFC + +## store first 2 factors +const 483091365 +store@ h1EEE0 +const 74683203 +store@ h1EEE4 + +## store other 2 factors +const 8436 +store@ h1EEEC +const -14020 +store@ h1EEF0 + +## perform the first multiplication +load@ h1EEE0 +stack down +load@ h1EEE4 +# multiplying 483091365 by 74683203 should yield 36078810479842095 +# if we take lowest 32 bits of 36078810479842095 we get 2861683503 +mul +stack up +store@ h1EEE8 + +## perform the second multiplication +load@ h1EEEC +stack down +load@ h1EEF0 +# multiplying 8436 by -14020 should yield -118272720 (which fits in 32 bits) +mul +stack up +store@ h1EEF4 + +halt |