This commit is contained in:
pjht 2016-09-02 08:57:24 -05:00
parent dfe8422b34
commit 2e7293cfc0
3 changed files with 20 additions and 0 deletions

17
KT8/asm.rb Normal file
View File

@ -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

1
KT8/test.asm Normal file
View File

@ -0,0 +1 @@
LOADA f

2
KT8/test.code Normal file
View File

@ -0,0 +1,2 @@
v2.0 raw
00