aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-09-05 17:28:22 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-09-05 17:28:22 +0200
commit9c0a347262ad5aa8564570ac672450b3e46c8570 (patch)
treeb8f3d1f8e252f564ad77cbf12e73ddf87fece586
parentd5c877247834fc25689ca6cf7530cd8d1b870d3a (diff)
downloadAGH-engineering-thesis-9c0a347262ad5aa8564570ac672450b3e46c8570.tar.gz
AGH-engineering-thesis-9c0a347262ad5aa8564570ac672450b3e46c8570.zip
put procedures in tclasm.tcl in some order
-rw-r--r--tclasm.tcl71
1 files changed, 44 insertions, 27 deletions
diff --git a/tclasm.tcl b/tclasm.tcl
index ed4ed8d..17aa8aa 100644
--- a/tclasm.tcl
+++ b/tclasm.tcl
@@ -60,6 +60,10 @@ proc __to_binary {number length} {
return $result
}
+
+# _im and _with_im are needed to construct higher-level
+# multiinstructions, that use an immediate value
+
proc _im {value} {
puts 1[__to_binary $value 15]
}
@@ -82,29 +86,7 @@ proc _with_im {command number} {
}
-proc _const {value_part} {
- puts 010100000[__to_binary $value_part 7]
-}
-
-proc const {value} {
- _with_im _const $value
-}
-
-
-proc tee {} {
- puts 0001000000000000
-}
-
-
-proc add {} {
- puts 0011000000000000
-}
-
-
-proc sub {} {
- puts 0011000000000001
-}
-
+# Load and store instructions, different variants */
proc _store {address_part} {
puts 011111100[__to_binary $address_part 7]
@@ -142,6 +124,23 @@ proc load+ {address} {
}
+# Instructions, that do not change stack size
+
+proc halt {} {
+ puts 0000000000000000
+}
+
+
+proc nop {} {
+ puts 0000000000000001
+}
+
+
+proc swap {} {
+ puts 0000000000000010
+}
+
+
proc _set_sp {address_part} {
puts 010000000[__to_binary $address_part 7]
}
@@ -151,11 +150,29 @@ proc set_sp {address} {
}
-proc halt {} {
- puts 0000000000000000
+# Instructions, that grow stack
+
+proc tee {} {
+ puts 0001000000000000
}
-proc swap {} {
- puts 0000000000000010
+proc _const {value_part} {
+ puts 010100000[__to_binary $value_part 7]
+}
+
+proc const {value} {
+ _with_im _const $value
+}
+
+
+# Instructions, that shrink stack
+
+proc add {} {
+ puts 0011000000000000
+}
+
+
+proc sub {} {
+ puts 0011000000000001
}