asmrb 0.0.2.3 → 0.0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asmrb.rb +41 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65959eb6a15a1ae6dfc55cf8d3b66e6d1a1135fc
|
4
|
+
data.tar.gz: c6cba8bc4473c3673d3f3d07fb6e9cf3e3a6470d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20a11f724628741c96756ae0ff8239bec0a4d5102a7ba9cc28d4016cee113bb09c6ff169bbeee707a3f3d81ae16980b5a287179d70655f1e2c1ee46288375ab
|
7
|
+
data.tar.gz: 5eb31088ebe69adf432e4293276932a24fa98d5239bc89f2ea1e13392f74e1cc354cf6cc813e2210f94a5c7bddfe69796404813fa40f70414d355e6e47ccb696
|
data/lib/asmrb.rb
CHANGED
@@ -83,20 +83,20 @@ class Asm
|
|
83
83
|
@stack.push e
|
84
84
|
},
|
85
85
|
|
86
|
-
"add" => lambda { | a
|
87
|
-
@stack.push(
|
86
|
+
"add" => lambda { | a |
|
87
|
+
@stack.push(@stack.pop + refvar(a))
|
88
88
|
},
|
89
89
|
|
90
|
-
"sub" => lambda { | a
|
91
|
-
@stack.push(
|
90
|
+
"sub" => lambda { | a |
|
91
|
+
@stack.push(@stack.pop - refvar(a))
|
92
92
|
},
|
93
93
|
|
94
|
-
"mul" => lambda { | a
|
95
|
-
@stack.push(
|
94
|
+
"mul" => lambda { | a |
|
95
|
+
@stack.push(@stack.pop * refvar(a))
|
96
96
|
},
|
97
97
|
|
98
|
-
"div" => lambda { | a
|
99
|
-
@stack.push(
|
98
|
+
"div" => lambda { | a |
|
99
|
+
@stack.push(@stack.pop / refvar(a))
|
100
100
|
},
|
101
101
|
|
102
102
|
"incr" => lambda { |dest, incval = 1|
|
@@ -167,7 +167,7 @@ class Asm
|
|
167
167
|
|
168
168
|
"dbg" => lambda {
|
169
169
|
puts "#{@stack} > #{@program[@pc][0]}".light_green
|
170
|
-
binding.pry if @is_debug
|
170
|
+
#binding.pry if @is_debug
|
171
171
|
},
|
172
172
|
|
173
173
|
"func" => lambda {|name|
|
@@ -182,7 +182,7 @@ class Asm
|
|
182
182
|
# after invoking the outside function.
|
183
183
|
# @@pc is belong to class, sync with all objects
|
184
184
|
# made with this class.
|
185
|
-
# while @pc is stick to instance that created
|
185
|
+
# while @pc is stick to instance that created
|
186
186
|
# by this class.
|
187
187
|
# which is why invoking other Asm, cause @@pc
|
188
188
|
# to increase, while @pc don't.
|
@@ -217,8 +217,6 @@ class Asm
|
|
217
217
|
"exit" => lambda {
|
218
218
|
exit
|
219
219
|
}
|
220
|
-
|
221
|
-
#and so on
|
222
220
|
}
|
223
221
|
|
224
222
|
def create_label(lbl)
|
@@ -362,4 +360,34 @@ class Asm
|
|
362
360
|
end
|
363
361
|
end
|
364
362
|
|
365
|
-
|
363
|
+
def self.fac2(n)
|
364
|
+
if(n > 1)
|
365
|
+
n * fac2(n - 1)
|
366
|
+
else
|
367
|
+
1
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
end
|
372
|
+
|
373
|
+
|
374
|
+
Asm.new do
|
375
|
+
defn :factorial
|
376
|
+
arg acc, n
|
377
|
+
cmp n, 1
|
378
|
+
jge :recursion
|
379
|
+
jmp :exit
|
380
|
+
|
381
|
+
label :recursion
|
382
|
+
push acc
|
383
|
+
mul n
|
384
|
+
push n
|
385
|
+
sub 1
|
386
|
+
jmp :factorial
|
387
|
+
label :exit
|
388
|
+
push acc
|
389
|
+
end
|
390
|
+
|
391
|
+
$factorial.is_debug = true
|
392
|
+
|
393
|
+
puts $factorial.invoke 1,3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asmrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2.
|
4
|
+
version: 0.0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Trung
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: create assembly-like DSL in ruby, use LLVM to speed up.
|
14
14
|
email: deulamco@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|