diff options
author | pommicket <pommicket@gmail.com> | 2022-01-13 16:12:28 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-01-13 16:12:28 -0500 |
commit | 13363eac1af870ea256b35843078fa890cea6f24 (patch) | |
tree | f00a11cca9630bbb4664c66f08af2fc1477e5dde /05/util.b | |
parent | e43f32b93217dc712d113d43feb8d1e7b8177422 (diff) |
simple expressions
Diffstat (limited to '05/util.b')
-rw-r--r-- | 05/util.b | 43 |
1 files changed, 35 insertions, 8 deletions
@@ -44,6 +44,14 @@ function left_shift :left_shift_negative n = 0 - n return x > n + +function max_signed + argument a + argument b + if a > b goto maxs_return_a + return b + :maxs_return_a + return a function file_error argument name @@ -327,26 +335,45 @@ function fputn_signed fputn(fd, n) return -function fputx +:hex_digits + string 0123456789abcdef + +function fputx64 argument fd argument n local m local x m = 60 - :fputx_loop + :fputx64_loop x = n > m x &= 0xf x += .hex_digits fputc(fd, *1x) m -= 4 - if m >= 0 goto fputx_loop + if m >= 0 goto fputx64_loop return -:hex_digits - string 0123456789abcdef - -function putx +function putx64 + argument n + fputx64(1, n) + return + +function fputx32 + argument fd + argument n + local m + local x + m = 28 + :fputx32_loop + x = n > m + x &= 0xf + x += .hex_digits + fputc(fd, *1x) + m -= 4 + if m >= 0 goto fputx32_loop + return +function putx32 argument n - fputx(1, n) + fputx32(1, n) return function putn |