diff options
Diffstat (limited to '')
| -rwxr-xr-x | asm.rb | 4 |
1 files changed, 3 insertions, 1 deletions
| @@ -2,10 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | OPCODES = { | 3 | OPCODES = { |
| 4 | "acc=" => 0x000, | 4 | "acc=" => 0x000, |
| 5 | "load" => 0x100, | 5 | "ladd" => 0x100, |
| 6 | "store" => 0x200, | 6 | "store" => 0x200, |
| 7 | "ifeq" => 0x300, | 7 | "ifeq" => 0x300, |
| 8 | "jmp" => 0x400, | 8 | "jmp" => 0x400, |
| 9 | "ascii" => 0x500, | ||
| 9 | "++acc" => 0xf01, | 10 | "++acc" => 0xf01, |
| 10 | "--acc" => 0xf02, | 11 | "--acc" => 0xf02, |
| 11 | "++idx" => 0xf04, | 12 | "++idx" => 0xf04, |
| @@ -27,6 +28,7 @@ ARGF.each_line() do | line | | |||
| 27 | op = 0x000 | 28 | op = 0x000 |
| 28 | refs = [] | 29 | refs = [] |
| 29 | line.scan(/\S+/).each() do | word | | 30 | line.scan(/\S+/).each() do | word | |
| 31 | break if word =~ /^#/ | ||
| 30 | if word =~ /^0(\d+)$/ | 32 | if word =~ /^0(\d+)$/ |
| 31 | op |= $1.to_i(8) | 33 | op |= $1.to_i(8) |
| 32 | elsif word =~ /^-0(\d+)$/ | 34 | elsif word =~ /^-0(\d+)$/ |
