diff options
author | pommicket <pommicket@gmail.com> | 2022-01-11 18:03:09 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-01-11 18:03:09 -0500 |
commit | 343129a61099f74ab746905a693d7b18ced6b269 (patch) | |
tree | 8f2a2dbc21d69c03982c313f2743be36ca121dce | |
parent | c42cf36deef86530dc179851ec921373add2f01c (diff) |
full multiply
-rw-r--r-- | 05/main.b | 5 | ||||
-rw-r--r-- | 05/tokenize.b | 10 | ||||
-rw-r--r-- | 05/util.b | 29 |
3 files changed, 39 insertions, 5 deletions
@@ -88,7 +88,6 @@ function main local tokens fill_in_powers_of_10() - print_powers_of_10() dat_banned_objmacros = 255 dat_banned_fmacros = 255 @@ -142,6 +141,10 @@ function main string a.out byte 0 +; NOTE: this language doesn't have proper support for floating-point numbers, +; but we need to do some float stuff. floats are stored as a 58-bit significand +; and an exponent. the significand ranges from 0 (inclusive) to 0x400000000000000 (exclusive) + function normalize_float argument p_significand argument p_exponent diff --git a/05/tokenize.b b/05/tokenize.b index 3715fc1..1c197a7 100644 --- a/05/tokenize.b +++ b/05/tokenize.b @@ -120,6 +120,8 @@ function tokenize local n local p local data + local significand + local exponent in = pptokens :tokenize_loop @@ -236,9 +238,6 @@ function tokenize out += 2 ; no info data = c goto token_output - :tokenize_float - ; @TODO - byte 0xcc :tokenize_string_literal n = rodata_end_offset - RODATA_OFFSET n += RODATA_ADDR ; address of string @@ -261,6 +260,11 @@ function tokenize out += 2 ; no info data = n goto token_output + :tokenize_float + significand = 0 + exponent = 0 + ; @TODO + byte 0xcc :tokenize_loop_end return 0 @@ -1,4 +1,31 @@ - +; multiply two 64-bit signed numbers to a 128-bit number +function full_multiply_signed + argument a + argument b + argument p_lower + argument p_upper + local lower + local upper + + lower = a * b + ; mov rax, rdx + byte 0x48 + byte 0x89 + byte 0xd0 + ; mov [rbp-48] (upper), rax + byte 0x48 + byte 0x89 + byte 0x85 + byte 0xd0 + byte 0xff + byte 0xff + byte 0xff + + *8p_lower = lower + *8p_upper = upper + return + + function file_error argument name fputs(2, .str_file_error) |