full multiply
This commit is contained in:
parent
c42cf36dee
commit
343129a610
3 changed files with 39 additions and 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
|
||||
|
|
|
@ -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
|
||||
|
|
29
05/util.b
29
05/util.b
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue