All macros β€” alphabetical indexΒΆ

Every macro in the standard library, sorted by fully-qualified name and arity. 295 entries total.

Macro

File

Time

Space

Summary

bit._.cmp_next_eq/4

bit/cond_jumps

2@+4

3@+6

jump to:

bit._.print_str_one_char/2

bit/output

bit.add/3

bit/math

n(8@+14)

n(8@+14)

dst[:n] += src[:n]

bit.add1/3

bit/math

8@+14

8@+14

Unsafe for dst==carry (but there is no reason in calling it that way)

bit.address_and_variable_xor/4

bit/logics

n@

n@

address(bit_address) ^= src

bit.and/2

bit/logics

2@+2

2@+2

dst &= src

bit.and/3

bit/logics

n(2@+2)

n(2@+2)

dst[:n] &= src[:n]

bit.ascii2bin/3

bit/casting

17@+24

17@+24

if ascii is β€˜0’/’1’, set bit to 0/1 (end error=0). else, set error=1.

bit.ascii2dec/3

bit/casting

25@+56

25@+56

if ascii is β€˜0’-β€˜9’, set dec to that decimal digit value (end error=0). else, set error=1.

bit.ascii2hex/3

bit/casting

53@+86

53@+86

if ascii is β€˜0’-β€˜9’/’a’-β€˜f’/’A’-β€˜F’, set hex to that hexadecimal digit value (end error=0). else, set error=1.

bit.bin2ascii/2

bit/casting

9@-7

9@-7

ascii := the ascii representation of the value of bin.

bit.bit/0

bit/memory

bit.bit/1

bit/memory

Size Complexity: 1

bit.cmp/5

bit/cond_jumps

2@+4

3@+6

jump to:

bit.cmp/6

bit/cond_jumps

n(3@+6)

TIme Complexity: n(2@+4)

bit.dec/2

bit/math

2n + 5@+12

n(2@+6)

x[:n]--

bit.dec2ascii/2

bit/casting

12@-10

12@-10

ascii := the ascii representation of the value of dec.

bit.div/5

bit/div

n^2(10@+20)

n^2(11@+22)

if b==0: goto end (do nothing)

bit.div.div_step/5

bit/div

n(10@+20)

n(11@+22)

R[0] ^= N

bit.div10/3

bit/div

n(5@+11)

n(5@+11)

dst[:n], src[:n] = src[:n] / 10, src[:n] % 10.

bit.div10.cmp_sub_10/3

bit/div

4@+12

4@+12

if (val > 10) {

bit.div_loop/5

bit/div

n^2(18@+18)

n(25@+22)

if b==0: goto end (do nothing)

bit.double_exact_xor/3

bit/logics

@

@

note: pad 2 is needed, but pad 8 is used for wflips-padding optimization and for smaller wflips.

bit.exact_not/1

bit/logics

1

1

dst(bit_address) ^= 1

bit.exact_xor/2

bit/logics

@-1

@-1

note: pad 2 is needed, but pad 8 is used for wflips-padding optimization and for smaller wflips.

bit.exact_xor_from_ptr/2

bit/pointers

8w@

8w@

like:  bit.exact_xor dst, *ptr

bit.hex2ascii/2

bit/casting

15@+7

21@+30

ascii := the ascii representation of the value of hex (digits & capital-letters).

bit.idiv/5

bit/div

n^2(10@+20)

n^2(11@+22)

if b==0: goto end (do nothing)

bit.idiv_loop/5

bit/div

n^2(18@+18)

n(37@+58)

if b==0: goto end (do nothing)

bit.if/3

bit/cond_jumps

@+2

@+2

if x == 0 jump to l0, else jump to l1

bit.if/4

bit/cond_jumps

n(@+2)

n(@+2)

if x[:n] == 0 jump to l0, else jump to l1

bit.if0/2

bit/cond_jumps

@+2

@+2

if x == 0 jump to l0

bit.if0/3

bit/cond_jumps

n(@+2)

n(@+2)

if x[:n] == 0 jump to l0

bit.if1/2

bit/cond_jumps

@+2

@+2

if x == 1 jump to l1

bit.if1/3

bit/cond_jumps

n(@+2)

n(@+2)

if the x[:n] != 0 jump to l1

bit.inc/2

bit/math

5@+12 in average

n(2@+6)

x[:n]++

bit.inc.inc1_with_carry0_jump/3

bit/math

2@+6

2@+6

Unsafe for dst==carry (but there is no reason in calling it that way)

bit.inc1/2

bit/math

2@+6

2@+6

Unsafe for dst==carry (but there is no reason in calling it that way)

bit.input/1

bit/input

16@-16

16@-16

input one byte into dst[:8] (lsb first)

bit.input/2

bit/input

n(16@-16)

n(16@-16)

input n bytes into dst[:8n] (lsb first)

bit.input_bit/1

bit/input

2@-2

2@-2

input one bit into the bit-variable, β€˜dst’.

bit.mov/2

bit/memory

2@-1

2@-1

note: works if dst==src.

bit.mov/3

bit/memory

n(2@-2)

n(2@-2)

note: doesn’t work if dst and src overlap. works if dst==src.

bit.mul/3

bit/mul

n*b(8@+14)    if b==n/2:  n^2(4@+7)

n^2(8@+14)

dst[:n] *= src[:n]

bit.mul.mul_add_if/4

bit/mul

n(8@+14)

n(8@+14)

if flag:

bit.mul10/2

bit/mul

n(14@+10)

n(14@+10)

x[:n] *= 10

bit.mul_loop/3

bit/mul

n^2(6@+2) + n*b(8@+14)    if b==n/2:  n^2(10@+9)

n(21@+11)

dst[:n] *= src[:n]

bit.neg/2

bit/math

n + 5@+12

n(2@+6)

x[:n]--

bit.not/1

bit/logics

1

1

dst ^= 1

bit.not/2

bit/logics

Complexity: n

bit.one/1

bit/memory

@

@

bit = 1

bit.one/2

bit/memory

n@

n@

x[:n] = (1<<n) - 1   // all 1's

bit.or/2

bit/logics

2@+2

2@+2

`dst

bit.or/3

bit/logics

n(2@+2)

n(2@+2)

`dst[:n]

bit.output/1

bit/output

@+2

@+2

outputs the bit β€˜x’.

bit.pointers.advance_by_one_and_flip__ptr_wflip/2

bit/pointers

Advances *to_flip by 1 (which takes n flips, from bit0 to bit1, bit2,…).

bit.pointers.ptr_init/0

bit/pointers

2w+2

Initializes the global opcodes and pointer-copies required for the pointers macros.

bit.pointers.set_flip_pointer/1

bit/pointers

2w@

2w@

Sets both to_flip and to_flip_var to point to the given pointer.

bit.pointers.set_jump_pointer/1

bit/pointers

2n@

2n@

Sets both to_jump and to_jump_var to point to the given pointer.

bit.print/1

bit/output

8@+16

8@+16

outputs a byte from x[:8] (a bit vector. from lsb to msb).

bit.print/2

bit/output

n(8@+16)

n(8@+16)

outputs n bytes from x[:8n] (a bit vector. from lsb to msb).

bit.print_as_digit/1

bit/output

@+9

@+9

prints the ascii character β€˜0’/’1’, based on x’s value.

bit.print_as_digit/2

bit/output

@+9

@+9

prints x[:n] as n ascii-characters (β€˜0’s and β€˜1’s, lsb first).

bit.print_dec_int/2

bit/output

n^2(2@+4)

n(16@+23)

prints x[:n] as a signed decimal number (without leading zeros).

bit.print_dec_uint/2

bit/output

n^2(2@+4)

n(14@+16)

prints x[:n] as an unsigned decimal number (without leading zeros).

bit.print_dec_uint.div10_step/8

bit/output

n(7@+12)

11@-3

if zero_flag:      // if src is already 0:

bit.print_dec_uint.print_char/2

bit/output

5@+12

5@+12

if char_flag: print the ascii representation of the decimal digit ascii4[:4].

bit.print_hex_int/3

bit/output

n(7@+13)

n(7@+13)

print x[:n] as a signed hexadecimal number, without leading zeros (digits & capital-letters).

bit.print_hex_uint/3

bit/output

n(7@+11)

n(7@+11)

print x[:n] as an unsigned hexadecimal number, without leading zeros (digits & capital-letters).

bit.print_hex_uint.print_digit/2

bit/output

bit.print_str/2

bit/output

min(n, len+1)*(16@+32)

min(n, len+1)*(16@+32)

prints the string at x[:8n], or until the reaches the first β€˜\0’ (the earlier).

bit.ptr_dec/1

bit/pointers

2w + 5@+12

w(2@+6)

ptr[:n] -= 2w

bit.ptr_flip/1

bit/pointers

2w@ + @

2w@ + @

like:  *ptr;

bit.ptr_flip_dbit/1

bit/pointers

2w@ + 2@

2w@ + 2@

The stl.comp_flip_if executes in ~##w, which should be much less than @/2 operations.

bit.ptr_inc/1

bit/pointers

5@+12

w(2@+6)

bit.ptr_jump/1

bit/pointers

2w@ + 2

2w@ + 2

like:  ;*ptr

bit.ptr_wflip/2

bit/pointers

3w@  (actually a bit smaller, 3w@+3w)

3w@  (actually a bit smaller, 3w@+3w)

like:  wflip *ptr, value

bit.ptr_wflip_2nd_word/2

bit/pointers

3w@

3w@

like:  wflip (*ptr)+w, value

bit.rol/2

bit/shifts

n(2@-1)

n(2@-1)

rotate x[:n] left by 1-bit

bit.ror/2

bit/shifts

n(2@-1)

n(2@-1)

rotate x[:n] right by 1-bit

bit.shl/2

bit/shifts

n(2@-1)

n(2@-1)

x[:n] <<= 1

bit.shl/3

bit/shifts

n(2@-1)

n(2@-1)

x[:n] <<= times

bit.shr/2

bit/shifts

n(2@-1)

n(2@-1)

x[:n] >>= 1

bit.shr/3

bit/shifts

n(2@-1)

n(2@-1)

x[:n] >>= times

bit.shra/3

bit/shifts

n(2@-1)

n(2@-1)

x[:n] >>= times (arithmetic shift right)

bit.str/1

bit/casting

create a bit-vector, initialized with the value of β€˜str’, and with the number of bytes needed to store β€˜str’, plus 1.

bit.sub/3

bit/math

n(8@+16)

n(8@+16)

dst[:n] -= src[:n]

bit.swap/2

bit/memory

2@+5

3@+8

a, b = b, a

bit.swap/3

bit/memory

n(2@+5)

n(3@+8)

a[:n], b[:n] = b[:n], a[:n]

bit.unsafe_mov/2

bit/memory

2@-2

2@-2

note: doesn’t work if dst==src.

bit.vec/1

bit/memory

bit.vec/2

bit/memory

Size Complexity: n

bit.xor/2

bit/logics

@-1

@-1

dst ^= src

bit.xor/3

bit/logics

n(@-1)

n(@-1)

dst[:n] ^= src[:n]

bit.xor_from_ptr/2

bit/pointers

8w@

8w@

like: bit.xor dst, *ptr

bit.xor_to_ptr/2

bit/pointers

2w@ + 2@+2

2w@ + 2@+2

like:  bit.xor *ptr, bit

bit.xor_zero/2

bit/logics

@

@

dst ^= src

bit.xor_zero/3

bit/logics

n@

n@

dst[:n] ^= src[:n]

bit.zero/1

bit/memory

@-1

@-1

bit = 0

bit.zero/2

bit/memory

n(@-1)

n(@-1)

x[:n] = 0

hex.add/2

hex/math

4@+12

4@+52

dst += src

hex.add/3

hex/math

n(4@+12)

n(4@+52)

dst[:n] += src[:n]

hex.add.add_constant_with_leading_zeros/4

hex/math

hex.add.add_hex_shifted_constant/4

hex/math

hex.add.add_hex_shifted_constant/5

hex/math

n_const(4@+12)   + 5@+2

n_const(2.5@+39) + (dst_n - hex_shift)(1.5@+13) + 4@+29

dst[:dst_n] += const << (4*hex_shift)

hex.add.clear_carry/0

hex/math

2@

2@+12

carry = 0

hex.add.clear_carry/2

hex/math

2@+1

2@+16

carry = 0. jump to c0 if it was 0, and to c1 otherwise.

hex.add.init/0

hex/math

8 (when jumping to dst, until finished)

1570

This is where the add β€œtruth” tables are.

hex.add.not_carry/0

hex/math

1

1

carry = !carry

hex.add.set_carry/0

hex/math

2@+1

2@+13

carry = 1

hex.add_constant/3

hex/math

n_const(4@+12)   + 5@+2

n_const(2.5@+39) + (dst_n - hex_shift)(1.5@+13) + 4@+29

dst[:n] += const

hex.add_count_bits/3

hex/math_basic

2.27@-1                // (2@-10 + 2 + 4 + 3 + 0.25*[16@/15])

0.5@+109 + n(1.5@+13)  // (2@-10 + 16(1+4+1+2) + 4 + (n-1)(1.5@+13))

(n=2 when operating on 16-255 bit-numbers)

hex.add_mul/2

hex/mul

5@+26

4@+52

.mul.add_carry_dst : res   +=   x * .mul.dst + .mul.add_carry_dst

hex.add_mul/4

hex/mul

n(5@+26)

n(4@+52)

res[n] += a[n] * b[1]

hex.add_shifted/5

hex/math

src_n(4@+12)   + 5@+1        // It's on average, see the note in hex.inc.

src_n(2.5@+39) + (dst_n - hex_shift)(1.5@+13) + 4@+28

dst[:dst_n] += src[:src_n] << (4*hex_shift)

hex.address_and_variable_double_xor/6

hex/logics

n(@+12)

n(@+60)

address1(bit_address) ^= src

hex.address_and_variable_xor/4

hex/logics

n(@+4)

n(@+28)

address(bit_address) ^= src

hex.and/2

hex/logics

4@+10

4@+52

dst &= src

hex.and/3

hex/logics

n(4@+10)

n(4@+52)

dst[:n] &= src[:n]

hex.and.init/0

hex/logics

6 (when jumping to dst, until finished)

595

This is where the and β€œtruth” tables are.

hex.cmp/5

hex/cond_jumps

3@+8

3@+30

compares a to b.

hex.cmp/6

hex/cond_jumps

m(3@+8)        // m=(n-i), where i is the most-significant index such that a[i] != b[i] (if a==b, then m==n).

n(3@+30)

compares a[:n] to b[:n].

hex.cmp.cmp_eq_next/4

hex/cond_jumps

compares a to b; if equal just continue.

hex.cmp.init/0

hex/cond_jumps

6 (when jumping to dst, until finished)

514

This is where the compare β€œtruth” tables are.

hex.count_bits/3

hex/math_basic

n(2.27@-1)

n(3.5@+135)    // on 16-255 bit-numbers. (a bit bigger on bigger numbers).

dst[:small_n] = x[:n].#on-bits

hex.dec/2

hex/math_basic

1.067@     // It's on average. To be exact: 16/15 * @.

n(1.5@+13)

hex[:n]--

hex.dec.step/2

hex/math_basic

hex.dec1/3

hex/math_basic

@

1.5@+13

hex-- (if underflows - jump to borrow1; else jump to borrow0)

hex.div/7

hex/div

n^2(2@+8) + n*nb(34@+92)   so if nb==n:  n^2(36@+100)

n(4@+81)  + nb(16@+243)    so if nb==n:  n(20@+324)

if b==0: goto div0

hex.double_exact_xor/9

hex/logics

@+4

@+28

{t3,t2,t1,t0} ^= src

hex.double_xor/3

hex/logics

@+4

@+28

dst1 ^= src

hex.exact_xor/5

hex/logics

@

@+12

{d3,d2,d1,d0} ^= src

hex.hex/0

hex/memory

hex.hex/1

hex/memory

Size Complexity: 1

hex.idiv/8

hex/div

n^2(2@+8) + n*nb(34@+92)   so if nb==n:  n^2(36@+100)

n(8.5@+132)  + nb(21.5@+309)    so if nb==n:  n(30@+441)

if b==0: goto div0

hex.if/3

hex/cond_jumps

@-1

@+15

if hex==0 goto l0, else goto l1.

hex.if/4

hex/cond_jumps

n(@-1)

n(@+15)

if hex[:n]==0 goto l0, else goto l1.

hex.if0/2

hex/cond_jumps

if hex==0 goto l0, else continue.

hex.if0/3

hex/cond_jumps

if hex[:n]==0 goto l0, else continue.

hex.if1/2

hex/cond_jumps

if hex!=0 goto l1, else continue.

hex.if1/3

hex/cond_jumps

if hex[:n]!=0 goto l1, else continue.

hex.if_flags/4

hex/cond_jumps

@-1

@+15

if flags&(1<<hex) is true:

hex.inc/2

hex/math_basic

1.067@     // It's on average. To be exact: 16/15 * @.

n(1.5@+13)

hex[:n]++

hex.inc.step/2

hex/math_basic

hex.inc1/3

hex/math_basic

@

1.5@+13

hex++ (if overflows - jump to carry1; else jump to carry0)

hex.init/0

hex/tables_init

6500   (6464+@)

It is 50/100KB (for w=32/64 bits)

hex.input/1

hex/input

4@+14

4@+36

byte[:2] = input(8bits) // lsb first

hex.input/2

hex/input

n(4@+14)

n(4@+36)

bytes[:2n] = input(8n-bits) // lsb first

hex.input_as_hex/2

hex/input

7@+11

8.5@+92

hex = hex_from_ascii(input(1byte))

hex.input_as_hex/3

hex/input

n(7@+11)

n(8.5@+92)

hex[:n] = hex_from_ascii(input(n-bytes))

hex.input_hex/1

hex/input

2@+7

2@+18

hex := input(4bits) // lsb first

hex.mov/2

hex/memory

2@+1

2@+25

dst = src

hex.mov/3

hex/memory

n(2@)

n(2@+24)

Unsafe if dst and src overlap! but safe if they are the exact same address.

hex.mul/4

hex/mul

n^2(3@+7) + n*b(5@+26)

n(21@+479)

for n==b/2: n^2(5.5@+20)

hex.mul.clear_carry/0

hex/mul

3@+1

3@+1

hex.mul.init/0

hex/mul

@+24 (when jumping to dst, until finished)

1620+@

This is where the add_mul β€œtruth” tables are.

hex.neg/2

hex/math_basic

~@+4n

n(1.5@+17)

x[:n] = -x[:n]

hex.not/1

hex/logics

4

4

hex = !hex  (15-hex)

hex.not/2

hex/logics

4n

4n

x[:n] = !x[:n]

hex.or/2

hex/logics

4@+10

4@+52

`dst

hex.or/3

hex/logics

n(4@+10)

n(4@+52)

`dst[:n]

hex.or.init/0

hex/logics

6 (when jumping to dst, until finished)

595

This is where the or β€œtruth” tables are.

hex.output/1

hex/output

@

@+26

output 4 bits from hex (lsb first)

hex.pointers.advance_by_one_and_flip__ptr_wflip/2

hex/pointers/xor_to_pointer

Advances *to_flip by 1 (which takes n flips, from bit0 to bit1, bit2,…).

hex.pointers.ptr_init/0

hex/pointers/basic_pointers

w/2+261

NOTE: must be placed just after the startup, so that the read_ptr_byte_table will be in address 256.

hex.pointers.read_byte_from_inners_ptrs/0

hex/pointers/xor_from_pointer

5@+13

5@+24

use after: hex.pointers.set_flip_and_jump_pointers ptr

hex.pointers.set_flip_and_jump_pointers/1

hex/pointers/basic_pointers

w(0.75@+5)

w(0.75@+29)

Sets both to_flip and to_flip_var, and to_jump and to_jump_var to point to the given pointer.

hex.pointers.set_flip_pointer/1

hex/pointers/basic_pointers

w(0.5@+2)

w(0.5@+14)

Sets both to_flip and to_flip_var to point to the given pointer.

hex.pointers.set_jump_pointer/1

hex/pointers/basic_pointers

w(0.5@+2)

w(0.5@+14)

Sets both to_jump and to_jump_var to point to the given pointer.

hex.pointers.stack_init/1

hex/pointers/basic_pointers

n+w/4 + 330

Initializes a stack of size n (maximal capacity of n hexes / return-addresses).

hex.pointers.xor_byte_to_flip_ptr/1

hex/pointers/xor_to_pointer

10@+24

10@+152

xors (the byte hex[2:]) to the byte pointed by the memory-word hex.pointers.to_flip.

hex.pointers.xor_byte_to_ptr_and_inc/2

hex/pointers/xor_to_pointer

w(0.5@+2)  + 19@+38

w(0.9@+17) + 15@+207

like:  hex.xor *ptr, hex[:2]

hex.pointers.xor_hex_to_flip_ptr/1

hex/pointers/xor_to_pointer

5@+12

5@+76

xors (the parameter hex) to the hex pointed by the memory-word hex.pointers.to_flip.

hex.pointers.xor_hex_to_flip_ptr/2

hex/pointers/xor_to_pointer

5@+12

5@+76

xors (the parameter hex, shifted left by bit_shift) to the hex/byte pointed by the memory-word hex.pointers.to_flip.

hex.pointers.xor_hex_to_ptr_and_inc/2

hex/pointers/xor_to_pointer

w(0.5@+2)  + 14@+26

w(0.9@+17) + 10@+131

like:  hex.xor *ptr, hex

hex.pop/2

hex/pointers/stack

n(w(0.38@+ 3) + 9@+18)

n(w(0.56@+16) + 7@+70)

Like:  sp -= M

hex.pop_byte/1

hex/pointers/stack

w(0.75@+ 5) + 18@+ 36

w(1.13@+32) + 14@+139

Like:  byte[:2] = stack[sp--]

hex.pop_hex/1

hex/pointers/stack

w(0.75@+ 5) + 16@+ 36

w(1.13@+32) + 12@+115

Like:  hex = stack[sp--]

hex.pop_ret_address/1

hex/pointers/stack

w(  1.5@+ 5) + 9@+23

w(1.875@+20) + 5@+67

Like:  stack[sp--] = 0

hex.print/1

hex/output

2@

2@+52

output 8 bits from x[:2] (lsb first)

hex.print/2

hex/output

n(2@)

n(2@+52)

output n bytes from x[:2n] (lsb first)

hex.print_as_digit/2

hex/output

@+4

@+36

prints the ascii of the hexadecimal representation of hex.

hex.print_as_digit/3

hex/output

n(@+4)

n(@+36)

prints the ascii of the hexadecimal representation of x[:n].

hex.print_int/4

hex/output

n(2@+10)

n(4.5@+71)

print the signed x[:n], without leading zeros.

hex.print_uint/4

hex/output

n(2@+6)

n(3@+54)

print the unsigned x[:n], without leading zeros.

hex.print_uint.print_digit/3

hex/output

2@+6

3@+54

print the ascii of the hexadecimal representation of hex (skip leading zeros, based on printed_something)

hex.ptr_add/2

hex/pointers/pointer_arithmetics

13@+26

w(0.375@ + 3.25) + 7.5@+94

ptr[:w/4] += value * 2w (advance ptr by value)

hex.ptr_dec/1

hex/pointers/pointer_arithmetics

9@+23

w(0.375@ + 3.25)  + 5@+67  (for log(w) in 16,32,64,128)

ptr[:w/4] -= 2w

hex.ptr_flip/1

hex/pointers/xor_to_pointer

w(0.5@+2)  + @

w(0.5@+14) + @

like:  *ptr;

hex.ptr_flip_dbit/1

hex/pointers/xor_to_pointer

w(0.5@+2)  + @+6

w(0.5@+14) + @+6

The stl.comp_flip_if executes in ~##w, which should be much less than @/2 operations.

hex.ptr_inc/1

hex/pointers/pointer_arithmetics

9@+14

w(0.375@ + 3.25)  + 5@+55  (for log(w) in 16,32,64,128)

ptr[:w/4] += 2w

hex.ptr_jump/1

hex/pointers/basic_pointers

w(0.5@+2)

w(0.5@+14)

like:  ;*ptr

hex.ptr_sub/2

hex/pointers/pointer_arithmetics

13@+35

w(0.375@ + 3.25)  + 7.5@+106

ptr[:w/4] -= value * 2w (retreat ptr by value)

hex.ptr_wflip/2

hex/pointers/xor_to_pointer

w(1.5@+5)

w(1.5@+17)

like:  wflip *ptr, value

hex.ptr_wflip_2nd_word/2

hex/pointers/xor_to_pointer

w(1.5@+5)

w(1.5@+17)

like:  wflip (*ptr)+w, value

hex.push/2

hex/pointers/stack

n(w(0.38@+ 3) + 13@+ 25)

n(w(0.56@+16) + 11@+128)

Like:  stack[sp+1:][:M] = hex[:n];  sp += n.

hex.push_byte/1

hex/pointers/stack

w(0.75@+ 5) + 26@+ 51

w(1.13@+32) + 22@+255

Like:  stack[++sp] = byte[:2]

hex.push_hex/1

hex/pointers/stack

w(0.75@+ 5) + 20@+ 39

w(1.13@+32) + 16@+167

Like:  stack[++sp] = hex

hex.push_ret_address/1

hex/pointers/stack

w(2.25@+10) +  9@+ 51

w(2.62@+49) + 20@+231

Like:  stack[++sp] = return_address

hex.quadrupled_exact_xor/17

hex/logics

@+12

@+60

{q3,q2,q1,q0} ^= src

hex.read_byte/2

hex/pointers/read_pointers

w(0.75@+ 5) + 9@+13

w(0.75@+29) + 9@+72

like:  dst[:2] = *ptr

hex.read_byte/3

hex/pointers/read_pointers

n(w(0.75@+ 5) + 18@+27)

n(w(1.13@+32) + 14@+127)

like:  dst[:2n] = *ptr[:n]

hex.read_byte_and_inc/2

hex/pointers/read_pointers

w(0.75@+ 5) + 18@+27

w(1.13@+32) + 14@+127

like:  dst[:2] = *ptr

hex.read_hex/2

hex/pointers/read_pointers

w(0.75@+ 5) + 7@+13

w(0.75@+29) + 7@+48

like:  dst = *ptr

hex.read_hex/3

hex/pointers/read_pointers

n(w(0.75@+ 5) + 16@+27)

n(w(1.13@+32) + 12@+103)

like:  dst[:n] = *ptr[:n]

hex.read_hex_and_inc/2

hex/pointers/read_pointers

w(0.75@+ 5) + 16@+27

w(1.13@+32) + 12@+103

like:  dst = *ptr

hex.set/2

hex/memory

@+4

@+16

hex = val (constant)

hex.set/3

hex/memory

n(@+4)

n(@+16)

hex[:n] = val (constant)

hex.shifts.shl_bit_once/2

hex/shifts

@+1

@+28

{next(1bit),dst(1hex)} = dst << 1

hex.shifts.shr_bit_once/2

hex/shifts

@+1

@+28

{next(1bit),dst(1hex)} = dst >> 1

hex.shl_bit/2

hex/shifts

n(@+1)

n(@+28)

dst[:n] <<= 1

hex.shl_hex/2

hex/shifts

n(@+4)

n(@+28)

dst[:n] <<= 4

hex.shl_hex/3

hex/shifts

n(@+4)

n(@+28)

dst[:n] <<= 4*times

hex.shr_bit/2

hex/shifts

n(@+1)

n(@+28)

dst[:n] >>= 1

hex.shr_hex/2

hex/shifts

n(@+4)

n(@+28)

dst[:n] >>= 4

hex.shr_hex/3

hex/shifts

n(@+4)

n(@+28)

dst[:n] >>= 4*times

hex.sign/4

hex/cond_jumps

@-1

@+15

if number[:n] < 0 jump to neg, else jump to zpos (Zero POSitive).

hex.sign_extend/3

hex/math_basic

(full_n - signed_n)(@+4)

(full_n - signed_n)(@+16)

sign-extends hex[:signed_n] into hex[:full_n]

hex.sp_add/1

hex/pointers/stack

13@+26

w(0.375@ + 3.25) + 7.5@+94

Like:  sp += value

hex.sp_dec/0

hex/pointers/stack

9@+23

w(0.375@ + 3.25)  + 5@+67

Like:  sp--

hex.sp_inc/0

hex/pointers/stack

9@+14

w(0.375@ + 3.25)  + 5@+55

Like:  sp++

hex.sp_sub/1

hex/pointers/stack

13@+35

w(0.375@ + 3.25)  + 7.5@+106

Like:  sp -= value

hex.sub/2

hex/math

4@+12

4@+52

dst -= src

hex.sub/3

hex/math

n(4@+12)

n(4@+52)

dst[:n] -= src[:n]

hex.sub.clear_carry/0

hex/math

2@+5

2@+20

carry = 0

hex.sub.clear_carry/2

hex/math

2@+5

2@+20

carry = 0. jump to c0 if it was 0, and to c1 otherwise.

hex.sub.init/0

hex/math

8 (when jumping to dst, until finished)

1570

This is where the sub β€œtruth” tables are. must be called once if you want to use hex.sub (hex.init calls it).

hex.sub.not_carry/0

hex/math

1

1

carry = !carry

hex.sub.set_carry/0

hex/math

2@+6

2@+21

carry = 1

hex.sub.sub_constant_with_leading_zeros/4

hex/math

hex.sub.sub_hex_shifted_constant/4

hex/math

hex.sub.sub_hex_shifted_constant/5

hex/math

n_const(4@+12)   + 5@+2

n_const(2.5@+39) + (dst_n - hex_shift)(1.5@+13) + 4@+29

dst[:dst_n] -= const << (4*hex_shift)

hex.sub_constant/3

hex/math

n_const(4@+12)   + 5@+11

n_const(2.5@+39) + (dst_n - hex_shift)(1.5@+13) + 4@+41

dst[:dst_n] -= const

hex.sub_shifted/5

hex/math

src_n(4@+12)   + 5@+10        // It's on average, see the note in hex.inc.

src_n(2.5@+39) + (dst_n - hex_shift)(1.5@+13) + 4@+40

dst[:dst_n] -= src[:src_n] << (4*hex_shift)

hex.swap/2

hex/memory

3@+1

3@+37

hex1, hex2 = hex2, hex1

hex.swap/3

hex/memory

n(3@)

n(3@+36)

Unsafe if dst and src overlap! but safe if they are the exact same address.

hex.tables.clean_table_entry__table/1

hex/tables_init

4

256

A table. When jumping to entry d - it xors d into dst, and jumps to hex.tables.ret

hex.tables.clean_table_entry__table/3

hex/tables_init

log(n) / 2     (an overage over all entries, of jumping to an entry in this table)

n

@Assumes: n must be a power of 2, and it must be (1<<n)-padded.

hex.tables.init_all/0

hex/tables_init

This is the inner-macro of hex.init, and it’s identical to it. see hex.init documentation.

hex.tables.init_shared/0

hex/tables_init

hex.tables.jump_to_table_entry/3

hex/tables_init

4@+4

4@+52

The macro assumes that jumper_to_table is a fj-op that jumps to a 256-padded table.

hex.vec/1

hex/memory

hex.vec/2

hex/memory

Size Complexity: n

hex.write_byte/2

hex/pointers/write_pointers

w(0.75@+5)  + 17@+37

w(0.75@+29) + 17@+200

like:  *ptr = src[:2]

hex.write_byte/3

hex/pointers/write_pointers

n(w(0.75@+5)  + 26@+51)

n(w(1.13@+32) + 22@+255)

like:  *ptr[:n] = src[:2n]

hex.write_byte_and_inc/2

hex/pointers/write_pointers

w(0.75@+5)  + 26@+51

w(1.13@+32) + 22@+255

like:  *ptr = src[:2]

hex.write_hex/2

hex/pointers/write_pointers

w(0.75@+5)  + 11@+25

w(0.75@+29) + 11@+112

like:  *ptr = src

hex.write_hex/3

hex/pointers/write_pointers

n(w(0.75@+5)  + 20@+39)

n(w(1.13@+32) + 16@+167)

like:  *ptr[:n] = src[:n]

hex.write_hex_and_inc/2

hex/pointers/write_pointers

w(0.75@+5)  + 20@+39

w(1.13@+32) + 16@+167

like:  *ptr = src

hex.xor/2

hex/logics

@

@+12

dst ^= src

hex.xor/3

hex/logics

n@

n(@+12)

dst[:n] ^= src[:n]

hex.xor_by/2

hex/memory

4 (avg. 2: #on-bits)

4 (avg. 2: #on-bits)

hex ^= val (constant)

hex.xor_by/3

hex/memory

4n (avg. 2n: #on-bits)

4n (avg. 2n: #on-bits)

hex[:n] ^= val (constant)

hex.xor_byte_from_ptr/2

hex/pointers/xor_from_pointer

w(0.75@+ 5) + 7@+13

w(0.75@+29) + 7@+48

like:  dst[:2] ^= *ptr

hex.xor_byte_to_ptr/2

hex/pointers/xor_to_pointer

w(0.5@+2)  + 10@+24

w(0.5@+14) + 10@+152

like:  hex.xor *ptr, hex[:2]

hex.xor_byte_to_ptr/3

hex/pointers/xor_to_pointer

n(w(0.5@+2)  + 19@+38)

n(w(0.9@+17) + 15@+207)

like:  hex.xor *ptr[:n], hex[:2n]

hex.xor_hex_from_ptr/2

hex/pointers/xor_from_pointer

w(0.75@+ 5) + 6@+13

w(0.75@+29) + 6@+36

like:  dst ^= *ptr

hex.xor_hex_to_ptr/2

hex/pointers/xor_to_pointer

w(0.5@+2)  + 5@+12

w(0.5@+14) + 5@+76

like:  hex.xor *ptr, hex

hex.xor_hex_to_ptr/3

hex/pointers/xor_to_pointer

n(w(0.5@+2)  + 14@+26)

n(w(0.9@+17) + 10@+131)

like:  hex.xor *ptr[:n], hex[:n]

hex.xor_zero/2

hex/logics

@+4

@+28

dst ^= src

hex.xor_zero/3

hex/logics

n(@+4)

n(@+28)

dst[:n] ^= src[:n]

hex.zero/1

hex/memory

@

@+12

hex = 0

hex.zero/2

hex/memory

n@

n(@+12)

x[:n] = 0

hex.zero_ptr/1

hex/pointers/write_pointers

w(0.75@+5)  + 15@+37

w(0.75@+29) + 15@+176

like:  *ptr = 0

stl.bit2hex/2

casting

2@-1

2@+11

hex = bit

stl.bit2hex/3

casting

n(1.25@-1)

n(1.25@+2)

hex[:(n+3)/4] = bit[:n]

stl.call/1

ptrlib

~2.5w@  (exact: w(2.25@+10)   + 24@+51)

<3w@    (exact: w(2.625@+49) + 20@+231)

Saves the return address to the stack and jumps to the given β€œaddress”.

stl.call/2

ptrlib

<3w@  (exact: w(2.25@+10)  + 37@+57)

<3w@  (exact: w(2.625@+49) + 43@+251)

Saves the return address to the stack and jumps to the given β€œaddress”.

stl.comp_flip_if/2

runlib

if expr != 0 (compilation time), flip the given bit.

stl.comp_if/3

runlib

if expression is 0 (compilation time), jump to l0. else jump to l1

stl.comp_if0/2

runlib

if expression is 0 (compilation time), jump to l0. else continue

stl.comp_if1/2

runlib

if expression is not 0 (compilation time), jump to l1. else continue

stl.fcall/2

ptrlib

@-1

@-1

Jumps to label, and saves the return address in the given β€œret_reg” variable.

stl.fj/2

runlib

1

1

macro for 1 flip-jump op

stl.fret/1

ptrlib

1

1

Return into the address written in the β€œret_reg” variable.

stl.get_sp/1

ptrlib

n(2@)

n(2@+24)

(Unsafe if dst overlaps with hex.pointers.sp).

stl.hex2bit/2

casting

5@-4

5@+8

bit[:4] = hex

stl.hex2bit/3

casting

n(5@-4)

n(5@+8)

bit[:4n] = hex[:n]

stl.loop/0

runlib

finish (loop to self)

stl.output/1

runlib

8 * string_length

8 * string_length

str is a constant. The macro outputs the bytes of it (from lsB to msB) until it becomes all zeros.

stl.output_bit/1

runlib

1

1

bit is a constant. 0 will output o, anything else will output 1.

stl.output_char/1

runlib

8

8

ascii is a constant. The macro outputs the byte (ascii & 0xff)

stl.ptr_init/0

ptrlib

2.5w+263

2.5w+263

NOTE: must be placed just after the startup, so that the read_ptr_byte_table will be in address 256.

stl.return/0

ptrlib

w(2@+7)      + 9@+23

w(2.375@+34) + 5@+67

Returns to the calling function (gets the return-address from the top of the stack).

stl.skip/0

runlib

skip the next flip-jump op

stl.stack_init/1

ptrlib

n+w/4

Initializes a stack of size n (maximal capacity of n hexes / return-addresses).

stl.startup/0

runlib

2

2

startup Macro - Should be the first piece of code in your program.

stl.startup/1

runlib

2

2

startup Macro - Should be the first piece of code in your program.

stl.startup_and_init_all/0

runlib

~7000  (7026 for w=64, 6894 for w=16)

~7000  (7026 for w=64, 6894 for w=16)

startup Macro - Should be the first piece of code in your program.

stl.startup_and_init_all/1

runlib

6725 + 2.75w+@ + n

6725 + 2.75w+@ + n

startup Macro - Should be the first piece of code in your program.

stl.startup_and_init_all/2

runlib

6725 + 2.75w+@ + n

6725 + 2.75w+@ + n

startup Macro - Should be the first piece of code in your program.

stl.startup_and_init_pointers/0

runlib

2.5w+265

2.5w+265

startup Macro - Should be the first piece of code in your program.

stl.startup_and_init_pointers/1

runlib

2.5w+265

2.5w+265

startup Macro - Should be the first piece of code in your program.

stl.wflip_macro/2

runlib

@

@

macro for 1 wflip op

stl.wflip_macro/3

runlib

@

@

macro for 1 wflip op (with jump)