summaryrefslogtreecommitdiff
path: root/asm.rb
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-04-04 14:16:27 -0700
committerJulian Blake Kongslie2021-04-04 14:16:27 -0700
commit6fb37d5f47629817a5092da40217bde5ca0ed4fa (patch)
treea4f176f62cce9ca66806445ab9a0ca4e7543def7 /asm.rb
parentRemove unneeded .exe suffixes in bat scripts. (diff)
downloadnoncpu-6fb37d5f47629817a5092da40217bde5ca0ed4fa.tar.xz
Very fancy improved Fibonacci machine, with HDL convert-to-ASCII functionality
Diffstat (limited to '')
-rwxr-xr-xasm.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/asm.rb b/asm.rb
index 80bbd67..b883510 100755
--- a/asm.rb
+++ b/asm.rb
@@ -2,10 +2,11 @@
2 2
3OPCODES = { 3OPCODES = {
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+)$/