flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > size context of the [i]times[/i] argument value |
Author |
|
revolution 26 May 2014, 23:37
Currently fasm uses 65 bit numbers internally.
0xffffffffffffffff is distinct from -1. |
|||
26 May 2014, 23:37 |
|
l_inc 26 May 2014, 23:50
revolution
I know that, but internal number implementation has nothing to do with precision contexts. And currently the precision context of nearly all control directives is 64 bit, where 0xffffffffffffffff is the same as -1. Note the difference: Code: y = -1 ;unlimited precision context x =qword -1 ;64 bit precision context (same as 0xffffffffffffffff) _________________ Faith is a superposition of knowledge and fallacy |
|||
26 May 2014, 23:50 |
|
Tomasz Grysztar 27 May 2014, 08:40
l_inc wrote: As it is documented, the operators not, xor and shr work differently depending on the precision context. It does not seem however to be documented what context is valid for all the assembly directives, that take a numeric expression as an argument. Old versions of fasm used the 32-bit context for count expressions, but some time after I implemented the support for x86-64 architecture I decided that it is better to use 64-bit context uniformly for all such arguments. l_inc wrote: To justify the topic title here's a question related specifically to the times directive. It is documented to repeat an instruction passed to it as a second argument. In a context of assembly languages an instruction is normally understood as a CPU instruction. However here the term seems to be used in some wider sense, because even the first usage example demonstrates repeating of a data definition directive, which is (strictly speaking) not an instruction (mnemonic). The rule is that only one instruction is allowed per line - so everything that follows the initial labels has to be one and only one directive/instruction. The exception from this rule is the TIMES directive, which allows an additional instruction as its operand (not label though!), and this exception can also be nested. This scheme also applies to the preprocessing - the preprocessor directive can also follow a label (or a number of labels), like any other instruction: Code: a: macro x { db 7 } b:c: x PS The classic structure of an assembly line, which I used in fasm's design, is: [label:] instruction [operand] [;comment] fasm allows multiple label fields per one line, but the rest is more or less standard. |
|||
27 May 2014, 08:40 |
|
revolution 27 May 2014, 08:55
Tomasz Grysztar wrote: ... every line of assembly source consists of any number of labels (words ending with ":") and then ... BTW; Did you miss the current bug report "Bug compiling 1.0e-317 floating-point number"? http://board.flatassembler.net/topic.php?t=16769 |
|||
27 May 2014, 08:55 |
|
Tomasz Grysztar 27 May 2014, 08:56
revolution wrote: BTW; Did you miss the current bug report "Bug compiling 1.0e-317 floating-point number"? |
|||
27 May 2014, 08:56 |
|
l_inc 27 May 2014, 11:49
Tomasz Grysztar
Quote: You are right, and this has not been documented But the question was, why this is not documented. Just unintentionally or do you want to have a possibility to change that in the future (and endanger programs written before)? I'd like to know, if I can rely on that behaviour. Quote: and then the instruction - understood as any kind of directive recognized by assembler I would accept this as is in the context of the times directive, if there were no exceptions resulting in "unexpected instruction" (in contrast to "illegal instruction" in case of numeric constant or label definition): Code: times 1 repeat 3 display 'Hello',13,10 times 1 end repeat Or may be a more useful example: Code: x = 60 times 5 if x mod % = 0 display 'x is divisible by an LCM of {2..5}',13,10 times 5 end if It may seem that times only accepts "instructions", that are not involved in multiline constructs, but there's again a counterexample: Code: times 1 virtual at $ dd 5 times 1 end virtual So what "instructions" do actually belong to this mysterious subset of instructions, that can become an argument of times ? _________________ Faith is a superposition of knowledge and fallacy |
|||
27 May 2014, 11:49 |
|
Tomasz Grysztar 27 May 2014, 16:19
l_inc wrote: I would accept this as is in the context of the times directive, if there were no exceptions resulting in "unexpected instruction" (in contrast to "illegal instruction" in case of numeric constant or label definition): Code: repeat 1 if 1 end repeat ; unexpected instruction end if Code: while 1 repeat 1 end while ; unexpected instruction end repeat This rule of proper nesting applies only to the directives that control the flow of the assembly - the repeats and conditional blocks. Section 2.2.3 of manual declares this to be the case for IF, REPEAT and WHILE (it's in the last paragraph) - I forgot to mention TIMES there, but it is just a different syntactical variant of REPEAT (one that makes further nesting impossible by its very nature). I should add additional line explaining it there. Other block instructions, like VIRTUAL or DATA, do not need to follow such rules: Code: repeat 3 virtual at % end repeat times 2 end virtual end virtual |
|||
27 May 2014, 16:19 |
|
Tomasz Grysztar 27 May 2014, 16:27
l_inc wrote: Tomasz Grysztar |
|||
27 May 2014, 16:27 |
|
l_inc 27 May 2014, 22:27
Tomasz Grysztar
Quote: This could be theoretically a valid construction, but current implementation disallows it. Oh, that would be a huge mistake to allow such constructions. IMHO. Aside from the natural ambiguity (is it a repetition of if 1 or is it a conditional end repeat?), no bizarre rules of evaluating this directive mixture would ever make it seep into a product of a tidy coder (I know: not an argument). However same is also true for my previous examples with times . I just wanted to know the limits of the formal applicability of times. Thank you for the clarification. Quote: I was not sure what the right choice for this context should be Me neither, but if we try to nitpick here (yes, even more ), then this phrase: Quote: if the value specified by numerical expression has to fit in a unit of specified size, and the arguments for operation fit into that size, the operation will be performed with precision limited to that size suggests to deduce an "otherwise not" meaning that the statement is an "if and only if". This way I had a wrong expectation when trying to show off by converting this piece of code: Code: if iSize < 10 display ' ' end if ;dispDec iSize into this one: Code: times -((iSize/10)-1)shr 64 display ' ' ;dispDec iSize For the currently applied 64 bit precision a correct way could be: Code: times ((iSize/10)-1)shr 63 display ' ' ;dispDec iSize The difference is very little, but it's still important, that the behaviour is defined in either way. _________________ Faith is a superposition of knowledge and fallacy |
|||
27 May 2014, 22:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.