sjasmplus icon indicating copy to clipboard operation
sjasmplus copied to clipboard

it would be great to have an ability to separate binary constants with some separator

Open he1f opened this issue 2 weeks ago • 4 comments

In general binary constants looks quite ugly for example 0b11111110, I would suggest to add some separator which would simplify reading long line of 1 or 0. Underscore is good choice from my point of view, i.e. previous exmple may looks like 0b1111_1110 or even 0b111_111_110 if you prefer octal number system.

he1f avatar Dec 08 '25 21:12 he1f

you mean 0b111'111'11?

https://z00m128.github.io/sjasmplus/documentation.html#s_numeric

Optional single quotes(') may be inserted between the digits as a separator (example: ld a,%11'01'11'00 ). They are ignored by the assembler.

The longer this C++ syntax is in place, the longer I'm thinking about adding support also for _, because I still don't get why C++ chose the apostrophe... 🤷‍♂️

ped7g avatar Dec 08 '25 22:12 ped7g

well, apostrophe is better than nothing ;) actually I'm fine with it but underscore would be even better :)

he1f avatar Dec 09 '25 07:12 he1f

I've also been thinking in the past that this would make groups of bits more readable. The apostrophe is indeed a strange choice, as it is narrow and thus doesn't add the desired visual space.

Note to myself if I will implement underscore: Make sure it doesn't clash with temporary labels _b and _f, to not mistake ld hl,101_b as binary digit or something like that.

From a quick look I think the correctly written label vs numerical constant is never ambiguous and syntax rules out one or the other (as the group delimiter must be enclosed by two digits, can't lead or trail number), but make sure this is true and that the parser is correct.

ped7g avatar Dec 09 '25 16:12 ped7g