flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > fasm1: longmath(65bit+) in assembly time |
Author |
|
macomics 24 Oct 2024, 16:30
ProMiNick wrote:
|
|||
24 Oct 2024, 16:30 |
|
macomics 24 Oct 2024, 17:30
Code: include 'ProMiNick-longmath.asm' macro displaylong value { macro displayhex val \{ local temp rept 8 i:0 \\{ temp = (val shr (28 - 4 * i)) and 15 if temp < 10 display '0' + temp else display 'A' + temp - 10 end if \\} \} display 'a.size=' displayhex a#.'size display 13,10,'a.value=' rept value#.'size i:0 \{ rept 1 j:value\#.'size-i-1 \\{ displayhex value\\#.'\\#j \\} \} display 13,10 } displaylong a Code: $ fasm test_longmath.asm flat assembler version 1.73.32 (16384 kilobytes memory) a.size=00000002 a.value=FFFFFFFF00000000 1 passes, 0 bytes. ADD: But! Code: include 'ProMiNick-longmath.asm' macro displaylong value { macro displayhex val \{ local temp rept 8 i:0 \\{ temp = (val shr (28 - 4 * i)) and 15 if temp < 10 display '0' + temp else display 'A' + temp - 10 end if \\} \} display 'a.size=' displayhex a#.'size display 13,10,'a.value=' rept value#.'size+2 i:0 \{ rept 1 j:value\#.'size-i+1 \\{ displayhex value\\#.'\\#j \\} \} display 13,10 } displaylong a Code: $ fasm test_longmath.asm flat assembler version 1.73.32 (16384 kilobytes memory) a.size=00000002 a.value=0000000000000000FFFFFFFF00000000 1 passes, 0 bytes. ADD: And! Code: include 'ProMiNick-longmath.asm' macro displaylong value { macro displayhex val \{ local temp rept 16 i:0 \\{ temp = (val shr (60 - 4 * i)) and 15 if temp < 10 display '0' + temp else display 'A' + temp - 10 end if \\} \} display 'a.size=' displayhex a#.'size display 13,10,'a.value=' rept value#.'size+2 i:0 \{ rept 1 j:value\#.'size-i+1 \\{ displayhex value\\#.'\\#j \\} \} display 13,10 } displaylong a Code: $ fasm test_longmath.asm flat assembler version 1.73.32 (16384 kilobytes memory) a.size=00000002 a.value=0000000000000000000000000000000000000000FFFFFFFF0000000000000000 1 passes, 0 bytes. |
|||
24 Oct 2024, 17:30 |
|
ProMiNick 24 Oct 2024, 20:20
macomics wrote: It's definitely +i, not +1. Code: macro longmath [symbolic] { irpv any, symbolic#.'size \{ rept 0 \{\} rept 1 \{ symbolic#.'size equ 2 symbolic#.'0 = (symbolic) and $FFFFFFFF symbolic#.'1 = (symbolic shr 32) and $FFFFFFFF \} } macro displaylong [value] { macro displayhex val \{ local temp rept 8 i:0 \\{ temp = (val shr (28 - 4 * i)) and 15 if temp < 10 display '0' + temp else display 'A' + temp - 10 end if \\} \} display `value,'.size=' displayhex value#.'size display 13,10,`value,':',13,10 rept value#.'size i:0 \{ reverse displayhex value\#.'\#i \} display 13,10 } ; a.lo*b.lo ; a.lo*b.hi+a.hi*b.lo ;a.hi*b.hi macro longmul dest,src { ;local tmp longmath dest,src ;tmp#.'size equ 4 rept dest#.'size+src#.'size %:0 \{ tmp#.'\#%=0 \} rept src#.'size i:0 \{ rept dest#.'size j:0 \\{ rept 1 k:j+i \\\{ rept 1 l:k+1 \\\\{ tmp#.'\\\#k = tmp#.'\\\#k + dest#.'\\#j * src#.'\#i tmp#.'\\\\#l = tmp#.'\\\\#l+(tmp#.'\\\#k shr 32) tmp#.'\\\\#k = tmp#.'\\\\#k and $FFFFFFFF \\\\} \\\} \\} \} ;displaylong tmp rept 1 i:dest#.'size+src#.'size\{ dest#.'size equ i\} rept dest#.'size i:0 \{ dest#.'\#i =tmp#.'\#i \} } a=$FFFFFFFFFFFFFFFF b=$FFFFFFFFFFFFFFFF longmul a,b displaylong a assert a.'3 = $FFFFFFFF assert a.'2 = $FFFFFFFE assert a.'1 = $00000000 assert a.'0 = $00000001 Code: a.size=00000004 a: FFFFFFFFFFFFFFFE0000000000000001 unsigned correctly multyplied _________________ I don`t like to refer by "you" to one person. My soul requires acronim "thou" instead. |
|||
24 Oct 2024, 20:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.