flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vid 04 Sep 2004, 07:27
2. because symbols that have their value assigned more than once cannot be forward refernced.
|
|||
![]() |
|
Tukang Paip 04 Sep 2004, 07:32
Quote:
can you explains more about this? |
|||
![]() |
|
Tomasz Grysztar 04 Sep 2004, 08:26
1. Load cannot know such dependencies - it just loads the bytes from code. This is an advanced directive and you should be careful when using it this way. All other assembler directives are designed to keep the whole code resolved correctly, but the "load"/"store" directive are an exception - this is a pair of advanced directives, to allow some advanced hacks to be done at assembly time. I wouldn't recommend them for beginner though.
|
|||
![]() |
|
vid 04 Sep 2004, 11:33
2. if you define constant only once in code (like label, which is too just a numeric constant), then it has same value anywhere in code, even before it is defined. but you are allowed to create variables that doesn't have same value everywhere in code, so you can do things like "a = a + 1". then, value of last time when such "variable" was redefined is used, so
Code: a = 1 ;here a is 1 a = a*5 ;here a is 5 a = a+5 ;here a is 10 But you can't read such constant before some it's value is set first time: Code: ;what should be value here??? a = 1 a = a*5 a = a+5 |
|||
![]() |
|
Tukang Paip 05 Sep 2004, 03:17
i'm confused here..
1. since foo is not yet known in dd foo, it cannot be assembled yet. So load directive should produce error since there was no code/data assembled at offset 0. 2. since fasm is multi-pass, why it just cannot resolve foo to the last value assigned? Code: dd foo ;foo = 1 here foo = 0 foo = 1 i don't really know the internal working of fasm's parser and assembler. |
|||
![]() |
|
Dragontamer 05 Sep 2004, 04:03
The syntax of the code is considered "the LAST time the value was assigned"
Thus, the thing doesn't "loop" so to speak. If someone saw this: foo = 0 dd foo Then you would think that foo is 0, right? But if they had your method: foo = 0 dd foo ; two hundred lines of code foo = 1 Then the above, foo is 1, not zero. |
|||
![]() |
|
Tomasz Grysztar 05 Sep 2004, 07:48
1.
Tukang Paip wrote: since foo is not yet known in dd foo, it cannot be assembled yet. So load directive should produce error since there was no code/data assembled at offset 0. When "foo" is not known, the data is assembled with value 0 - the assembler has to put generate some code there in each pass, otherwise it would never be able to resolve the offsets. 2. Using the last value assigned is the thing fasm would do naturally, but I had put the error check code there to avoid the amibuguity when the constant gets redefined. Dragontamer: you sample doesn't show this exactly, it should have the order as in Tukang's sample - in your the "foo" is anyway 0 at point of "dd foo" definition. |
|||
![]() |
|
Dragontamer 05 Sep 2004, 15:59
I get it. K then.
|
|||
![]() |
|
Tukang Paip 12 Sep 2004, 03:36
now i get it clear.. thanks privalov.. here's another thing (i don't want to create a new thread)
there's a problem with output filename for source file without extension, the last character is missing, e.g, for flat binary program : source filename : "foo" output filename : "fo.bin" this happens when we don't explicitly specify output file name. My solution is to fix formats.inc : original Code: find_extension: dec eax cmp eax,[free_additional_memory] jb extension_found cmp byte [eax],'\' je extension_found cmp byte [eax],'/' je extension_found cmp byte [eax],'.' jne find_extension mov edi,eax extension_found: fix : Code: find_extension: dec eax cmp eax,[free_additional_memory] jb no_file_extension cmp byte [eax],'\' je no_file_extension cmp byte [eax],'/' je no_file_extension cmp byte [eax],'.' jne find_extension mov edi,eax jmp extension_found no_file_extension: inc edi extension_found: |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.