flat assembler
Message board for the users of flat assembler.
Index
> Programming Language Design > fasm(g) tolerate of underscore in numbers ? |
Author |
|
Tomasz Grysztar 19 Sep 2016, 10:00
In fasm traditionally ' character was used for this purpose:
Code: db 0000'1111b But supporting _ as an alternative should not cause any problems, so I may as well add it. In the meantime, just for fun I'm going to demonstrate how to preprocess source text to convert such numbers with a macro: Code: macro convert_token out,token& local t,a t db `token load a:byte from t if a >= '0' & a <='9' repeat $-t load a:byte from t+%-1 if a = "_" store "'":byte at t+%-1 end if end repeat end if end macro macro ? line& local buffer,command virtual at 0 define out define buffer line while 1 match car cdr, buffer convert_token out,car match car_= cdr_, buffer match =car,car_ db ' ' end match end match define buffer cdr else match car, buffer convert_token out,car break else break end match end while load command:$ from 0 end virtual eval command end macro db 0000_1111b Last edited by Tomasz Grysztar on 19 Sep 2016, 10:36; edited 2 times in total |
|||
19 Sep 2016, 10:00 |
|
revolution 19 Sep 2016, 10:04
fasm uses the single quote character (') for number separation.
fasmarm uses the more common underscore character (_) for number separation. |
|||
19 Sep 2016, 10:04 |
|
Tomasz Grysztar 19 Sep 2016, 10:58
revolution wrote: fasm uses the single quote character (') for number separation. Already added to fasmg. |
|||
19 Sep 2016, 10:58 |
|
revolution 19 Sep 2016, 11:01
Tomasz Grysztar wrote: Well, I might add [_] into fasm, too. |
|||
19 Sep 2016, 11:01 |
|
jmg 19 Sep 2016, 19:57
Tomasz Grysztar wrote:
Great Tested this, and it also fixed an issue of not allowing > 8bit binary strings. Now, only if the number overflows the field, does an error result = Good. flat assembler g version 0.98.1474353977 Code: dd (100000_0010b shl 22) dd (1111_1010_0101_0111_0110_0101_0100_0011b) ; dd (1_1111_1010_0101_0111_0110_0101_0100_0011b) ; flags, as is > 32b dq (1110_1111_1010_0101_0111_0110_0101_0100_0011_0010_0001b) |
|||
19 Sep 2016, 19:57 |
|
Tomasz Grysztar 21 Sep 2016, 17:21
To sum things up:l fasmg now supports three ways of separating groups of digits: with single quote, with underscore, or with hash - because "#" operator works with numbers as well as with symbol identifiers (and, unlike fasm 1, fasmg allows it anywhere, not only in lines generated by macros).
jmg wrote: Tested this, and it also fixed an issue of not allowing > 8bit binary strings. |
|||
21 Sep 2016, 17:21 |
|
DOS386 23 Sep 2016, 19:31
I've been using $FFFF'FFFF for years with FASM
|
|||
23 Sep 2016, 19:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.