From: C. M. <pu...@38...> - 2018-12-15 20:06:55
|
On at 2018-12-14 01:38 -0800, H. Peter Anvin wrote: > On 12/4/18 4:02 AM, C. Masloch wrote: >> >> Oh yeah, you're right. Yes, it'd definitely be useful to support both >> the operator and question mark in identifiers. >> > > OK, the most logical way to deal with this seems to be to treat ? as a > *keyword*, rather than a *character*. In other words, since ? is > legitimate in identifiers, it is also a legitimate keyword. Just like > any other keyword, it has to be separated from other keywords by > whitespace or other non-identifier characters. Thanks, I tested building from git 33b5d21fbdc9 and it seems to handle everything the way it should, ie still allowing me to use the question mark in define names. >> (Side question: Would it be possible to "evaluate" expressions with >> strings as result? Eg << db _FAT16 ? "FAT16" : "FAT12" >>. Currently I >> use << db "FAT1",'2'+4*!!_FAT16 >> >> https://bitbucket.org/ecm/ldosboot/src/b469e243526d4fbdfe79d6ef4ef677ff2372eb19/boot.asm#lines-490 >> , which only uses a string that fits as a numeric constant in a byte.) > > I'm afraid not, although > > db "FAT1", _FAT16 ? '6' : '2' > > ... does work. > > This is because in NASM, strings used in expressions are always > converted to numbers. This isn't something we can realistically change > without who knows what breakage. Yeah, figures. > Now, since NASM does internal 64-bit arithmetic strings converted to > numbers can be up to 8 characters long, but since there is no 5-byte > object you can't trivially use it in the way you'd expect. > > Now, if you had an 8-byte field you could indeed do: > > dq _FAT16 ? "FAT16" : "FAT12" > > ... and you'd get a 5-character string with 3 bytes of zero padding. A side question: Your mails never seem to show up in https://sourceforge.net/p/nasm/mailman/nasm-devel/ -- what's up with that? Regards, ecm |