Skip to content

Commit e30ca86

Browse files
committed
Added RPOP spec
1 parent 5d0520d commit e30ca86

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

spec/machine_spec.cr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ describe StackVM::Machine do
119119
sp.should eq 27
120120
end
121121

122+
it "runs RPOP" do
123+
machine = Machine.new 32
124+
machine.flash Assembler::Utils.convert_opcodes EXE{
125+
LOADI, QWORD, 25_i64,
126+
RPOP, R0,
127+
HALT
128+
}
129+
130+
machine.start
131+
132+
r0 = machine.regs[R0]
133+
r0.should eq 25
134+
end
135+
122136
end
123137

124138
end

src/stackvm.cr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module StackVM
1111

1212
# Compile the above program to bytes
1313
binary = Assembler::Utils.convert_opcodes EXE{
14-
LOADI, 11_u32, "hello world",
14+
LOADI, QWORD, 25_i64,
15+
RPOP, R0,
1516
HALT
1617
}
1718

0 commit comments

Comments
 (0)