diff options
| -rw-r--r-- | ascii_array_subdivision.mas | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/ascii_array_subdivision.mas b/ascii_array_subdivision.mas new file mode 100644 index 0000000..f31f57e --- /dev/null +++ b/ascii_array_subdivision.mas @@ -0,0 +1,167 @@ +/ "size: " +load s +output +load i +output +load z +output +load e +output +load colon +output +load space +output + +/ input for size of array +input +output +store size +store counter +load newline +output + +/ "In char " +accept_character, load I + output + load n + output + load space + output + load c + output + load h + output + load a + output + load r + output + load space + output + + / character (s) to fill array + input + output + storei arrai + load newline + output + load arrai + add one + store arrai + load counter + subt one + store counter + skipcond 400 + jump accept_character + + / store half size for line splitting + load size + store divide_top_to_remainder + jns divide + load divide_result + store half_size + + / reset array cursor + load base + store arrai + + load half_size + add half_size + store full_size + +print_half, load half_size + / prime half_size to print half of array + store counter +_print_half, load counter + / decrement counter which tracks half array left to prent + subt one + store counter + + / decrement full_size which tracks characters left to print + load full_size + subt one + store full_size + + / print the array character + loadi arrai + output + + / print a seperator space + load space + output + + / increment array cursor for next print iteration (if left) + load arrai + add one + store arrai + + / print the rest of the characters for the line, if any + load counter + skipcond 400 + jump _print_half + + / output a new line seperator for next subdivision + load newline + output + + / if further array exists, print that subdivision + load full_size + skipcond 400 + jump print_half + + halt + +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 + +/ mutable user dependents +arrai, hex 0a0 +base, hex 0a0 +size, dec 0 +half_size, dec 0 +full_size, dec 0 +counter, dec 0 + +/ constants and characters +one, dec 1 +newline, hex a +space, hex 20 +colon, hex 3a +I, hex 49 +n, hex 6e +c, hex 63 +h, hex 68 +a, hex 61 +r, hex 72 +s, hex 73 +i, hex 69 +z, hex 7a +e, hex 65 + +/ division related variables +divide_bottom, dec 2 +divide_result, dec 0 +divide_top_to_remainder, dec 0 |