aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-09-02 09:09:20 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-09-02 09:09:20 +0200
commita0610e8be796b2e8225d2560209940815d1bd722 (patch)
treedb3e995bf042be58cfc172a81d8c479d60534233
parent9ae139a9a5bfdbcd2f5d47a266faff28e100f786 (diff)
downloadAGH-engineering-thesis-a0610e8be796b2e8225d2560209940815d1bd722.tar.gz
AGH-engineering-thesis-a0610e8be796b2e8225d2560209940815d1bd722.zip
add cond_jump instruction, rework jump instruction
-rwxr-xr-xtclasm.tcl29
1 files changed, 21 insertions, 8 deletions
diff --git a/tclasm.tcl b/tclasm.tcl
index 8c89eeb..d326c00 100755
--- a/tclasm.tcl
+++ b/tclasm.tcl
@@ -214,6 +214,11 @@ proc _jump {{im_modification im=im} {cond non-cond} {swap_regs no_swap}} {
puts 01$cond$swap_regs[__encode_immediate $im_modification]
}
+# example: _cond_jump im=h16A swap
+proc _cond_jump {{im_modification im=im} {swap_regs no_swap}} {
+ _jump $im_modification cond $swap_regs
+}
+
# example: _extended_instruction nop swap # it's really no longer a true nop...
# _extended_instruction halt
proc _extended_instruction {instruction {swap_regs no_swap}} {
@@ -281,16 +286,24 @@ proc load {{im_modification im=im}} {
_load r1 @im $im_modification
}
-# example: jump im=h1dd
-# jump # im=im is the default if not specified
-proc jump {{im_modification im=im}} {
- _jump $im_modification non-cond
+# example: jump # if no address is given - im is used
+# jump h4FFFE
+proc jump {{address im_address}} {
+ if {"$address" == "im_address"} {
+ _jump im=im
+ } else {
+ _const _jump $address
+ }
}
-# example: cond_jump im=h00FE
-# cond_jump # im=im is the default if not specified
-proc cond_jump {{im_modification im=im}} {
- _jump $im_modification cond
+# example: cond_jump
+# cond_jump b100100110100111101 # same semantics as 'jump'
+proc cond_jump {{address im_address}} {
+ if {"$address" == "im_address"} {
+ _jump im=im cond
+ } else {
+ _const _cond_jump $address
+ }
}
foreach instruction {halt nop swap add sub div mul} {