summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-25 01:17:19 -0700
committerGitHub <[email protected]>2023-04-25 01:17:19 -0700
commit0fef6547096fe75a4f1a358fd53a46ebf6d2dc07 (patch)
treeac9beb9cbbfb6294459e94cdd219e78450ecc097
parentfeat: phongtorial (diff)
downloadmarie-0fef6547096fe75a4f1a358fd53a46ebf6d2dc07.tar.xz
marie-0fef6547096fe75a4f1a358fd53a46ebf6d2dc07.zip
feat: add test 1 program a
-rw-r--r--test_1_program_a.mas138
1 files changed, 138 insertions, 0 deletions
diff --git a/test_1_program_a.mas b/test_1_program_a.mas
new file mode 100644
index 0000000..c87bf24
--- /dev/null
+++ b/test_1_program_a.mas
@@ -0,0 +1,138 @@
+/ get user's x and y
+input
+store x
+input
+store y
+
+/ std::cout << y / x;
+load y
+store divide_top_to_remainder
+load x
+store divide_bottom
+jns divide
+load divide_result
+output
+
+/ I know this is sus, but we got space until line 150 ...
+/
+/ y = y % x * 10; std::cout << y / x;
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+jns pass
+
+halt
+
+pass, hex 0
+ / y % x
+ load y
+ store divide_top_to_remainder
+ load x
+ store divide_bottom
+ jns divide
+ load divide_top_to_remainder
+
+ / y = (y % x) * 10
+ store multiply_multiplier
+ load ten
+ store multiply_multiplicand
+ jns multiply
+ load multiply_result
+ store y
+
+ / std::cout << y / x;
+ store divide_top_to_remainder
+ load one
+ subt one
+ store divide_result
+ load x
+ store divide_bottom
+ jns divide
+ load divide_result
+ output
+
+ jumpi pass
+
+multiply, hex 0
+ / result = 0
+ clear
+ store multiply_result
+
+ / counter = multiplicand
+ load multiply_multiplicand
+ store multiply_counter
+_multiply, load multiply_result
+ / result += 1
+ add multiply_multiplier
+ store multiply_result
+
+ / counter -= 1
+ load multiply_counter
+ subt one
+ store multiply_counter
+
+ / if (AC == 0) { goto _multiply; } else { return; }
+ skipcond 400
+ jump _multiply
+
+ jumpi multiply
+
+divide, hex 0
+_divide, load divide_result
+ / result += 1
+ add one
+ store divide_result
+
+ / remainder -= divisor
+ load divide_top_to_remainder
+ subt divide_bottom
+ store divide_top_to_remainder
+
+ / if (AC < 0) { goto _divide; }
+ skipcond 000
+ jump _divide
+
+ / result -= 1
+ load divide_result
+ subt one
+ store divide_result
+
+ / remainder += divisor
+ load divide_top_to_remainder
+ add divide_bottom
+ store divide_top_to_remainder
+
+ jumpi divide
+
+/ user inputs
+x, dec 81
+y, dec 100
+
+/ multiplication related variables
+multiply_multiplier, dec 0
+multiply_multiplicand, dec 0
+multiply_result, dec 0
+multiply_counter, dec 0
+
+/ division related variables
+divide_bottom, dec 0
+divide_result, dec 0
+divide_top_to_remainder, dec 0
+
+/ constants
+one, dec 1
+ten, dec 10