diff options
| author | Julian Blake Kongslie | 2021-04-04 14:16:27 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2021-04-04 14:16:27 -0700 |
| commit | 6fb37d5f47629817a5092da40217bde5ca0ed4fa (patch) | |
| tree | a4f176f62cce9ca66806445ab9a0ca4e7543def7 /asm.rb | |
| parent | Remove unneeded .exe suffixes in bat scripts. (diff) | |
| download | noncpu-6fb37d5f47629817a5092da40217bde5ca0ed4fa.tar.xz | |
Very fancy improved Fibonacci machine, with HDL convert-to-ASCII functionality
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+)$/ |
