diff options
-rw-r--r-- | tclasm.tcl | 71 |
1 files changed, 44 insertions, 27 deletions
@@ -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 } |