From bb16cdd8187a06a71fb5b3b3afe8c3c9ad3b81a3 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 4 Dec 2020 23:44:56 -0500 Subject: [PATCH] cmks --- Scripts/cormackscript | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/Scripts/cormackscript b/Scripts/cormackscript index 44c4a9f..9f7cc72 100755 --- a/Scripts/cormackscript +++ b/Scripts/cormackscript @@ -9,25 +9,37 @@ # Place the comments (important to get spaces right too): # ; CMKS START # ; CMKS END -# into your racket program, the 'compiled' code will be injected here. +# into your racket program, the 'assembled' code will be injected here. # -# For extra niceness, if you have the racket program installed it will auto execute it. +# For extra niceness, if you have the racket program installed it will auto execute it your file. # # A CormackScript file contains 3 columns separated by whitespace in the format [opcode|target|source] -# The inc, print and read instructions read from the first column -# The quit instruction can be standalone +# - The inc, print and read instructions read from the first column +# - The quit instruction can be standalone +# - you can comment with ; +# - extraneous whitespace is ignored # # Here's some sample code +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# ; setting up memory +# 6 ; [0]: first instruction +# 1 ; [1]: literal 1 +# 2 ; [2]: literal 2 +# 7 ; [3]: literal 7 +# 0 ; [4]: n +# 0 ; [5]: acc # -# mov 20 30 -# inc 1 -# read 21 -# print 21 +# ; actual instructions +# read 4 ; input n +# addeq 00 4 ; skip next if n = 0 +# add 00 2 ; skip next 2 instructions +# print 5 ; out acc # quit +# add 05 04 ; acc = acc + n +# sub 04 01 ; n = n - 1 +# sub 00 03 ; go back 7 (from next instr) +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-= # -# Note, for commands that only need one param you don't need to add empty columns -# oh yeah, you can also comment with ; - # You can redefine these to whatever you want inst0="inc" # [tt] = [tt] + 1 -- 2.20.1