2020-10-10 19:31:31 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2020 CismonX <admin@cismon.net>
|
|
|
|
#
|
|
|
|
# Copying and distribution of this file, with or without modification, are
|
|
|
|
# permitted in any medium without royalty, provided the copyright notice and
|
|
|
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
|
|
|
#
|
2020-03-14 20:31:20 +00:00
|
|
|
|
2020-06-07 19:33:14 +00:00
|
|
|
proc u6a_dump_mnemonics { src_code } {
|
|
|
|
global U6AC_BIN
|
|
|
|
if { [ catch { exec $U6AC_BIN -S - << $src_code } result ] == 0 } {
|
|
|
|
return $result
|
|
|
|
} else {
|
|
|
|
fail "failed to dump mnemonics of program"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-14 20:31:20 +00:00
|
|
|
proc u6a_run { src_code u6ac_opts u6a_opts has_input } {
|
2020-03-15 08:21:18 +00:00
|
|
|
global U6A_BIN U6AC_BIN U6A_RUN B64_ENCODE B64_DECODE
|
2020-03-14 20:31:20 +00:00
|
|
|
set u6ac "$U6AC_BIN $u6ac_opts"
|
|
|
|
set u6a "$U6A_BIN $u6a_opts"
|
2020-03-15 08:21:18 +00:00
|
|
|
set run_cmd [ list $U6A_RUN $u6ac $u6a $B64_ENCODE $B64_DECODE $src_code ]
|
2020-10-10 19:31:31 +00:00
|
|
|
if { $has_input } {
|
2020-03-14 20:31:20 +00:00
|
|
|
lappend run_cmd -
|
|
|
|
set stty_init -echo
|
|
|
|
} else {
|
|
|
|
set stty_init { raw -echo }
|
|
|
|
}
|
|
|
|
global spawn_id
|
|
|
|
spawn {*}$run_cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
proc u6a_stop { send_eof } {
|
|
|
|
global spawn_id
|
2020-10-10 19:31:31 +00:00
|
|
|
if { $send_eof } {
|
2020-03-14 20:31:20 +00:00
|
|
|
send \x04
|
|
|
|
expect eof
|
|
|
|
}
|
|
|
|
catch wait result
|
2020-10-10 19:31:31 +00:00
|
|
|
if { [ set exit_code [ lindex $result 3 ] ] } {
|
2020-03-14 20:31:20 +00:00
|
|
|
fail "program exited with code $exit_code"
|
|
|
|
}
|
|
|
|
}
|