+tmp="$(mktemp 'tempXXX')"
+cat "$scriptfile" |\
+ sed -r "s/\s*;.*//g; /^\s*$/ d; s/\s+/ /g; s/^\s+//" |\
+ awk "
+ /^$inst0\s/ {printf \"0%02d00 ; [%02d] = [%02d] + 1\n\",\$2,\$2,\$2}
+ /^$inst1\s/ {printf \"1%02d%02d ; [%02d] = [%02d] + [%02d]\n\",\$2,\$3,\$2,\$2,\$3}
+ /^$inst2\s/ {printf \"2%02d%02d ; [%02d] = max([%02d] - [%02d], 0)\n\",\$2,\$3,\$2,\$2,\$3}
+ /^$inst3\s/ {printf \"3%02d%02d ; [%02d] = [%02d]\n\",\$2,\$3,\$2,\$3}
+ /^$inst4\s/ {printf \"4%02d%02d ; [%02d] = [%02d] + 1, if [%02d] = 0\n\",\$2,\$3,\$2,\$2,\$3}
+ /^$inst5\s/ {printf \"5%02d%02d ; [%02d] = [[%02d]]\n\",\$2,\$3,\$2,\$3}
+ /^$inst6\s/ {printf \"6%02d%02d ; [[%02d]] = [%02d]\n\",\$2,\$3,\$2,\$3}
+ /^$inst7\s/ {printf \"700%02d ; display [%02d]\n\",\$2,\$2}
+ /^$inst8\s/ {printf \"8%02d00 ; read [%02d]\n\",\$2,\$2}
+ /^$inst9/ {print \"90000 ; halt\"}
+ !/^$inst0\s|^$inst1\s|^$inst2\s|^$inst3\s|^$inst4\s|^$inst5\s|^$inst6\s|^$inst7\s|^$inst8\s|^$inst9/
+ " >> "$tmp"
+sed -i "/\; CMKS START/,/\; CMKS END/{/\; CMKS START/!{/\; CMKS END/!d}}; /\; CMKS START/r $tmp" "$targetfile"
+rm "$tmp"