if_literal

This commit is contained in:
Simon Forman
2019-11-07 16:15:41 -08:00
parent 0ce64f2ec4
commit 7bab15c64a
2 changed files with 10 additions and 3 deletions
+4 -3
View File
@@ -237,9 +237,10 @@ language.
([]) --> [].
([Term|Terms]) --> (Term), (Terms).
(if_literal(Reg, Label)) --> % commands marked by setting high bit.
[and_imm(0, Reg, 0x8000), % 1 << 15
eq_offset(Label)].
(if_literal(Reg, Label)) -->
[ior_imm(0, Reg, -30), % get just the two tag bits.
sub_imm(0, 0, 2), % subtract 2 to check if result is zero.
ne_offset(Label)].
% if reg = 0 jump to label.
(if_zero(Reg, Label)) --> [sub_imm(Reg, Reg, 0), eq_offset(Label)].
+6
View File
@@ -101,3 +101,9 @@ the offsets will always be negative (or positive). SInce it's easier to
deal with positive offsets and it's just as easy to allocate up as down,
I'm going to do that.
Next, we must check if the term is a literal (not a symbol)
That involves rolling the value to get the top two bits and then checking
whether they are 10 or not.