flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 05 Jan 2017, 18:18
Yes, fasm's preprocessor is limited to 32-bit signed numbers. Keep in mind that fasm's preprocessor is a separate language on top of the assembler.
|
|||
![]() |
|
l_inc 06 Jan 2017, 01:11
Well, that is not the whole truth. I didn't do a thorough investigation, but it seems the preprocessor can work with wider integers as long as these are intermediate values. As we are talking about comparison here, the following code correctly finds the maximum value of $ffff'ffff'ffff and $1'0000'0000'0000 (equmax from here):
Code: x equ $ffff'ffff'ffff y equ $1'0000'0000'0000 m equmax x,y match v,m { display `v,13,10 } That works as long as the computed difference fits into the 32-bit signed range. If not (like if one of the above values was 1 instead), a more generalized version would be needed: Code: struc equmax v1*,v2* { restore . . equ v1 rept 1 diff_hi : (v1)shr 30 - (v2)shr 30 \{ match =0,diff_hi \\{ rept 1 diff_lo : (v1)and $3fffffff - (v2)and $3fffffff \\\{ match - any,diff_lo \\\\{ rept 0 \\\\\{ \\} match, \\{ match - any,diff_hi \\\{ match, \\\\{\\\\} restore . . equ v2 \\\} \\} \} } The above macro allows to compare 60-bit values. Any other calculations could be extended this way. _________________ Faith is a superposition of knowledge and fallacy |
|||
![]() |
|
l4m2 06 Jan 2017, 02:25
l_inc wrote: Tested. Code: x equ $ffff'ffff'ffff rept 1 t:x shr 40 {} |
|||
![]() |
|
l4m2 06 Jan 2017, 03:07
So converting from number to int can't use a simple rept but
Code: match, { local f, s, g rept 80 \{ local t, u macro f x \\{ rept 1 t |
|||
![]() |
|
Tomasz Grysztar 06 Jan 2017, 08:44
REPT uses the same expression evaluator as the assembler module, so during the expression evaluation the same rules and limits apply (note that the results of expressions are mostly well defined for any value sizes, only the limitations of implementation cause errors - compare with fasmg implementation of the same evaluator). However where the preprocessor itself operates on numbers, it is limited to 32-bit values, since it was designed this way (the addition of REPT with its use of the assembler's calculator was a late one).
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.