hex.cmp (arity 5)ΒΆ
Three-way compare on hex nibbles: jumps to lt if a<b, eq if a==b, gt if a>b. a, b are hexes; lt, eq, gt are addresses.
SignatureΒΆ
def cmp a, b, lt, eq, gt @ ret, _eq, _gt, jumper_to_return_table, __lt, __eq, __gt < .cmp.dst, .tables.ret { ... }
Defined in hex/cond_jumps.fj β lines 81β109 (view on GitHub).
ComplexityΒΆ
Time:
3@+8Space:
3@+30
See the complexity glossary for what @, w, dw, dbit, n mean.
Requires initΒΆ
The following must be initialised before this macro is invoked:
hex.cmp.init (or hex.init)
SourceΒΆ
Click to view the macro body
def cmp a, b, lt, eq, gt \
@ ret, _eq, _gt, jumper_to_return_table, __lt, __eq, __gt \
< .cmp.dst, .tables.ret {
//part1
.xor .cmp.dst , a
.xor .cmp.dst+4, b
wflip .tables.ret+w, ret, .cmp.dst
pad 4
//part2
ret:
wflip .tables.ret+w, ret, jumper_to_return_table //part3
.tables.ret+dbit ;_eq
.tables.ret+dbit+1;_gt
_eq: jumper_to_return_table+dbit ;ret //(part2.5)
_gt: jumper_to_return_table+dbit+1;ret
jumper_to_return_table:
//part4
;__lt
pad 4
//part5
__lt: ;lt
__eq: jumper_to_return_table+dbit ;eq
__gt: jumper_to_return_table+dbit+1;gt
}
Depends onΒΆ
Used byΒΆ
Example usesΒΆ
hex.cmpinhex/cond_jumps.fjhex.cmp.cmp_eq_nextinhex/cond_jumps.fj