flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > out of memory error when i try compile this code |
Author |
|
Tomasz Grysztar 18 Jan 2019, 18:40
In fasm 1 architecture the entire preprocessed source is kept in memory (you can see it when you generate .FAS file) and REPT is preprocessor's directive, so all copies of text generated by REPT are accumulated in memory, which can quickly run out - especially in this case, where "mov" and in turn "xor" are also macros, so the text generated by a single iteration of REPT is quite long. If you reduce the number of repetitions, generate .FAS file and use PREPSRC tool to extract preprocessed source, you're going to see exactly what happens there.
On the other hand, if you replace REPT with REPEAT, which is assembler's directive and does not generate copies of the text, the problem should not occur. |
|||
18 Jan 2019, 18:40 |
|
CandyMan 18 Jan 2019, 18:50
I have enough memory (1GB). REPT is just an example, in my program I do not use rept and the problem also occurs. The error is somewhere in the macro lea.
_________________ smaller is better |
|||
18 Jan 2019, 18:50 |
|
revolution 18 Jan 2019, 18:53
You can use the memory option "-m" to control how much memory to allocate at startup.
The Linux build doesn't do memory size detection and it defaults to a small memory footprint. The Windows build tries to allocate as much RAM as it can so often the -m switch isn't required unless it interferes with other applications trying to use memory. |
|||
18 Jan 2019, 18:53 |
|
Tomasz Grysztar 18 Jan 2019, 18:56
When I generate .FAS file out of your source, it is nearly 1 GB (1 053 730 997 bytes exactly). So if you have just 1 GB of memory, this text of preprocessed source is enough to run out of it.
|
|||
18 Jan 2019, 18:56 |
|
CandyMan 18 Jan 2019, 19:08
after removing the "load" line from the lea macro, the problem disappears
_________________ smaller is better |
|||
18 Jan 2019, 19:08 |
|
Tomasz Grysztar 18 Jan 2019, 19:35
The generated .FAS file is only 863 MB then, so it fits in your 1 GB.
Note that every iteration of your REPT translates to one "xor" macro and two "mov" macros, and each of these "mov" translates to one "xor" and two previous "mov", and each of them evaluates "lea" 9 times. Therefore every iteration is 2*2*9 "lea" macro calls, so every line in "lea" ends up being repeated 64*1024*36 times. Obviously removing even a single line from "lea" macro is going to affect memory requirements by dozens if not hundreds of MBs. You could just as well decrease the memory usage by reducing that 9 multiplier, that is removing one of "lea" in the "mov" macro definition. Just comment out a few "lea" (like 3 of them) and you should notice a difference. |
|||
18 Jan 2019, 19:35 |
|
CandyMan 18 Jan 2019, 19:46
I understand everything. I did not expect that it would take so much memory.
I apologize for unnecessary confusion. |
|||
18 Jan 2019, 19:46 |
|
l4m2 23 Jan 2019, 15:52
So the temp code too large 咯?
|
|||
23 Jan 2019, 15:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.