From 780f056e61323a41abcaf0dd53a44f99bcac197c Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Wed, 16 Sep 2020 14:42:32 +0200 Subject: add function calling (call, ret and drop instructions) with a testbench + bugfix in stack machine --- tclasm.tcl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tclasm.tcl') diff --git a/tclasm.tcl b/tclasm.tcl index f80863d..0dec4b0 100755 --- a/tclasm.tcl +++ b/tclasm.tcl @@ -273,6 +273,11 @@ proc tee {} { } +proc get_frame {} { + puts 0001000000000001 +} + + proc _const {value_part} { puts 010100000[__to_binary $value_part 7] } @@ -282,6 +287,15 @@ proc const {value} { } +proc _call {address_part} { + puts 010100001[__to_binary $address_part 7] +} + +proc call {address} { + _with_im _call $address +} + + # Instructions, that shrink stack proc add {} { @@ -304,6 +318,16 @@ proc mul {} { } +proc drop {} { + puts 0011000000000100 +} + + +proc ret {} { + puts 0011000010000000 +} + + proc _cond_jump {address_part} { puts 011100001[__to_binary $address_part 7] } -- cgit v1.2.3