From 2e7293cfc065b7598ecf34c42a23aea11d661a55 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 2 Sep 2016 08:57:24 -0500 Subject: [PATCH] stuff --- KT8/asm.rb | 17 +++++++++++++++++ KT8/test.asm | 1 + KT8/test.code | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 KT8/asm.rb create mode 100644 KT8/test.asm create mode 100644 KT8/test.code diff --git a/KT8/asm.rb b/KT8/asm.rb new file mode 100644 index 0000000..7114690 --- /dev/null +++ b/KT8/asm.rb @@ -0,0 +1,17 @@ +puts "Assembly file:" +insSet={"LOADA"=>"0", "LOADB"=>"1", "SAVE"=>"2", "LOWBITS"=>"3", "ADD"=>"40", "SUB"=>"41", "AND"=>"42", "OR"=>"43", "XOR"=>"44", "INVA"=>"45", "INVB"=>"46", "PASSA"=>"47", "PASSB"=>"48", "LSHIFT"=>"49", "RSHIFT"=>"4a", "CLEAR"=>"4b", "INC"=>"4c", "DEC"=>"4d"} +file=gets.chomp! +outFile=file.gsub(".asm", ".code") +file=File.open(file, "r") +outFile=File.open(outFile, "w") +outFile.puts "v2.0 raw" +file.each_line do |line| + line = line.split(" ") + if insSet[line[0][0]].length == 1 + outFile.puts insSet[line[0]]+line[1] + else + outFile.puts insSet[line[0][0]] + end +end +file.close +outFile.close \ No newline at end of file diff --git a/KT8/test.asm b/KT8/test.asm new file mode 100644 index 0000000..d78efeb --- /dev/null +++ b/KT8/test.asm @@ -0,0 +1 @@ +LOADA f \ No newline at end of file diff --git a/KT8/test.code b/KT8/test.code new file mode 100644 index 0000000..1de227a --- /dev/null +++ b/KT8/test.code @@ -0,0 +1,2 @@ +v2.0 raw +00