flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasm1 compilation process (memory point of view)

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 825
Location: Russian Federation, Sochi
ProMiNick 05 Dec 2025, 13:58
Code:
        VirtualAlloc [compiler_memory] shl 10 ; shl 10 - kilobytes multiplier
        for initialization of blocks that grow up on all states usualy used edi.
        allocated memory divided in proportion 3:1    
Code:
                                          3              :                     1
        [allocated_memory]={[memory_start...memory_end]  :  [additional_memory...additional_memory_end]} 
                             A
                             |
                             [code_start]    
Code:
[tagged_blocks]=0    
Code:
         call    preprocessor {

        [allocated_memory]={[include_paths...,0,memory_start][memory_start...memory_end]  :  [additional_memory...additional_memory_end]} ;memory_start moved right by size of include_paths
                                                                                              A                                       A
                                                                                              |                                       |
                                                                                              [free_additional_memory]                |
                                                                                                                                      |
                                                                                                                                      [labels_list]    
file sources opened and placed in a way that their file end points to memory_end, each file stream grows down memory_end pointer. While its tokenization is placed from memory_start growing up that memory_start pointer
Code:
        [allocated_memory]={[include_paths...,0,memory_start][tokenized source...>][memory_start...memory_end][<...file sources mapped to memory]  :  [additional_memory...additional_memory_end]}    
preprocessing_finished with
Code:
[source_start]=edi }    

I guess additional_memory even on preprocessor state used for calculations of expressions. than parser state...
to be continued...
(please not judge me strong for bad shemes - they are as are|as I see)
[edited]:proportion of allocated_memory 3:1 not 4:1

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 05 Dec 2025, 21:36; edited 1 time in total
Post 05 Dec 2025, 13:58
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8489
Location: Kraków, Poland
Tomasz Grysztar 05 Dec 2025, 14:53
You may find some information in my old unfinished guide, although only the preprocessor stage got covered in detail.
Post 05 Dec 2025, 14:53
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8489
Location: Kraków, Poland
Tomasz Grysztar 05 Dec 2025, 15:02
For the areas of fasm's internals that were not covered by these few chapters, there may still be something to dig out in the oldest threads on these forums, like this description of parsed source tokens.
Post 05 Dec 2025, 15:02
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1746
Location: Toronto, Canada
AsmGuru62 05 Dec 2025, 15:28
Is there any limits for the amount of code files included into FASM main file?
Please consider this main source specified on command line:
Code:
format  PE GUI 4.0
entry   start
stack   4000h, 4000h

    include 'Win32W.Inc'
    include 'Macros.Inc'
    include 'Macro\If.Inc'

; ---------------------------------------------------------------------------
section '.data' data readable writeable

    include 'Globals.Inc'

; ---------------------------------------------------------------------------
section '.code' code readable executable

    include 'Module_001.Asm'
    include 'Module_002.Asm'
    ...
    include 'Module_999.Asm'

; ---------------------------------------------------------------------------
; PROGRAM ENTRY POINT
; ---------------------------------------------------------------------------
align 32
start:
    ...
    

Lets assume I have included some (a thousand) files.
Are they limited in memory being consumed?
Process has 2Gb for user code and data.
Or, the memory specified on command line IS memory taken by FASM for included files and for data taken by Assembler itself?
Is there anything like a disk cache where included files may be stored?
Or, maybe each file is included and processed and then released?
Post 05 Dec 2025, 15:28
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20787
Location: In your JS exploiting you and your system
revolution 05 Dec 2025, 15:58
All included files must fit into memory.

The memory limit is set by the -m argument and is limited to not more than 4GB. For some OSes the limit is lower, e.g. for Windows it can't be more than 2GB in normal boot mode.
Post 05 Dec 2025, 15:58
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1746
Location: Toronto, Canada
AsmGuru62 05 Dec 2025, 18:37
Thanks, I was just curious.
The largest EXE file I ever made was around 128Kb.
Included files count was around 80 of them, no more than few Mb in total room.
Post 05 Dec 2025, 18:37
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.