flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Roman 16 Apr 2023, 14:38
Fasmw 1.73
Code: macro fltDat {} fltDat "5.55" ;convert text to dd 5.55 flt1 equ '4.5430' fltDat flt1 ;convert text to dd 4.5430 |
|||
![]() |
|
revolution 16 Apr 2023, 15:37
Third step not needed.
Fourth step (now the new third step): Code: include 'temp.fasm' |
|||
![]() |
|
revolution 16 Apr 2023, 15:39
macomics wrote: Forth ![]() Sometimes I wonder if Roman is writing a fully-fledged HLL compiler with fasm macros. ![]() |
|||
![]() |
|
Roman 16 Apr 2023, 15:58
Quote:
This variant I do and using now. But I want do simple convert in fasm macro. Sometime its handful. |
|||
![]() |
|
macomics 16 Apr 2023, 16:07
revolution wrote: Third step not needed. |
|||
![]() |
|
Roman 16 Apr 2023, 16:30
Idea little trick.
macro fltDat search text in Tabflts. Code: Virtual at 0 Tabflts:: Txt db "5.55" dd 5.55 db "4.5430" dd 4.5430 end virtual ;or this Virtual at 0 Tabflts:: Txt db "5.55" db "4.5430" end virtual Virtual at 0 Flts:: dd 5.55 dd 4.5430 end virtual |
|||
![]() |
|
Tomasz Grysztar 16 Apr 2023, 17:13
Well, if you are that desperate, you could try something like this:
Code: macro fltDat str* { local buffer, next define buffer f rept 8 i:1 \{ rept 1 c: str shr ((8-i)*8) and 0FFh - 48 \\{ match f, buffer \\\{ define next 0 match -=48, c \\\\{ define next 1 \\\\} match -=2, c \\\\{ define buffer .\\\#f define next 1 \\\\} match =0, next \\\\{ define buffer c\\\#f \\\\} \\\} \\} \} dd buffer } fltDat "5.55" flt1 equ '4.5430' fltDat flt1 |
|||
![]() |
|
Roman 16 Apr 2023, 17:23
Thanks.
Cool macro. |
|||
![]() |
|
macomics 16 Apr 2023, 17:29
Tomasz Grysztar wrote: Well, if you are that desperate, you could try something like this: Code: macro fltDat str* { local buffer, next define buffer f rept 8 i:1 \{ rept 1 c: str shr ((8-i)*8) and 0FFh - 48 \\{ match f, buffer \\\{ define next 0 match -=48, c \\\\{ define next 1 \\\\} match -=2, c \\\\{ define buffer .\\\#f define next 1 \\\\} match =0, next \\\\{ define buffer c\\\#f \\\\} \\\} \\} \} dd buffer } fltDat "5.50000500000" flt1 equ '4.54300000000000001' fltDat flt1 Code: fasm -m 1024 ./temp.asm ./temp.fasm flat assembler version 1.73.30 (1024 kilobytes memory) ./temp.asm [16]: fltDat "5.50000500000" ./temp.asm [5] fltDat [4]: rept 1 c: str shr ((8-i)*8) and 0FFh - 48 \\{ ./temp.asm [5] rept [1]: rept 1 c: str shr ((8-i)*8) and 0FFh - 48 \\{ error: value out of range. |
|||
![]() |
|
Tomasz Grysztar 16 Apr 2023, 17:34
The limitations of fasm's engine are obvious, but this doesn't matter anyway, because this macro is useless for any practical purpose. It can only handle literals that available at preprocessing time.
|
|||
![]() |
|
revolution 16 Apr 2023, 17:37
Next we need a triple precision module to handle strings up to 24 characters.
![]() Code: fltDat "3.141592635389793238e-245" ; 25 characters! It won't fit into triple precision. ![]() |
|||
![]() |
|
Roman 16 Apr 2023, 17:58
For me normal 3.1415926 accuracy 7 digits
"-1.0" wrong value macro fltDat Last edited by Roman on 16 Apr 2023, 18:06; edited 2 times in total |
|||
![]() |
|
revolution 16 Apr 2023, 18:05
Roman wrote: For me normal 3.1415926 accuracy 7 digits |
|||
![]() |
|
Roman 16 Apr 2023, 18:07
Ok 3.141592 for me
|
|||
![]() |
|
Tomasz Grysztar 16 Apr 2023, 18:15
Roman wrote: "-1.0" wrong value macro fltDat Code: match -=3, c \\\\{ define buffer -f define next 1 \\\\} |
|||
![]() |
|
revolution 16 Apr 2023, 18:17
Code: 1e6 ![]() And Code: 1E6 Code: 1.2f Code: 1.61F |
|||
![]() |
|
Tomasz Grysztar 16 Apr 2023, 18:21
I'm waiting for something else.
|
|||
![]() |
|
revolution 16 Apr 2023, 18:23
We need arithmetic also.
Code: 3.2*1.8-2.1/7.8**-0.1+sqrt(7.02) |
|||
![]() |
|
Tomasz Grysztar 16 Apr 2023, 18:24
The macro does exactly what was asked for. But I'm pretty sure that's mostly useless.
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.