flat assembler
Message board for the users of flat assembler.

flat assembler > Compiler Internals > compile directive (or assemble, or anything).

Goto page 1, 2  Next

comile directive
yes
61%
 61%  [ 8 ]
no
38%
 38%  [ 5 ]
not the compile keyword, but yes
0%
 0%  [ 0 ]
Total Votes : 13

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
fasm miss a directive to tell:

compile this file please.

this directive is the key of huge projects building, without breaking the ssso principle.

fasm would become like a sort of shell.

for example, build a set of executables and make an image to put on the disk.
Code:
compile "boot.asm" ; result in boot.bin file, will seek kernel.bin in the root
compile "startup.asm" ; result in startup.html file
compile "kernel.asm" ; result in the kernel executable file
compile "browser.asm" ; result in the stand alone browser

BOOT:
file "boot.bin";assume it fits in 512 bytes
BOOTDIR=512;the bootdir starts at DS:512
bootdir:;the boot drive root directory, contain offsets to files
dd @f-$-4;size of dir
dd boot
dd startupPage
dd browser
dd kernel
dd script
@@:
boot:
dd BOOT
db boot",0
kernel:
dd KERNEL
db "kernel",0
startPage:
dd STARTPAGE
db "startup",0
script:
dd SCRIPT
db "script",0
KERNEL:
file "kernel.bin";assume the image is mounted in a linear adress space
BROWSER:
file "browser.bin";the browser
STARTPAGE:
file "start.html";the startup page
SCRIPT:
db "kernel browser start.html",0;assume that boot will read script to know that it should open kernel with brower start.html in parameter, inducing the launch of the browser with the startup page
    

the above example is just an idea of what compile directive can help to do.

_________________
Smile fool
Post 21 Oct 2013, 17:41
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1171
Location: Unknown
Stupid post removed.


Last edited by HaHaAnonymous on 28 Feb 2015, 19:40; edited 2 times in total
Post 21 Oct 2013, 17:42
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
it is not an example, it is a request about the fasm compiler internals. the associated example is just to imagine the possibilities.
Post 21 Oct 2013, 17:55
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
Isn't it mainly that stuff what a linker does ?
Could be realized with batch files or with eclipse or with an own application using FASM.DLL as compiler engine. Wink
Post 21 Oct 2013, 20:56
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: 15975
Location: Qo'noS
fasm is not a batch file interpreter, or a "make" facility. Just keep it simple and single purpose, we have other tools to automate multiple tasks (batch files and make programs).
Post 22 Oct 2013, 00:34
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
it can also let compile a dll needed by an executable, without using boring platform specific batch or make files.
Post 22 Oct 2013, 10:10
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
for example:
using the dll example from fasmw package
Code:
compile "errormsg.asm";compile the dll

format PE GUI 4.0
entry start

include 'win32a.inc'

section '.text' code readable executable

  start:
        invoke  ShowLastError,HWND_DESKTOP
        invoke  ExitProcess,0

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          errormsg,'ERRORMSG.DLL'

  import kernel,\
         ExitProcess,'ExitProcess'

  import errormsg,\
         ShowLastError,'ShowLastError'
                                                      
    

and the dll file will be compiled just before the program using it, and run with just one hit on the F9 key

_________________
Smile fool
Post 22 Oct 2013, 16:45
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 620
At first glance, this suits my lazy side nicely Very Happy but the examples are not reflective of all huge projects. It is possible to have a large include tree that has requirements on a particular file that is used in many places; with this simple behavior it would be very inefficient to rebuild the same file. As soon as you add other keywords to get around this and other problems, it becomes more complex and ultimately requires prior knowledge of the surrounding build stages.

There are also still the same issues related to type of build (win/unix), since there's no way to indicate the target platform without an external build action (and if there were you'd need to perform external stages for C/... building).

Ultimately this still ends up needing the likes of CMake/Python/Perl/... or shell/batch/make/... scripts, so I think it makes sense to use them rather than confuse source and build.
Post 22 Oct 2013, 17:52
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
ok, then, i will make it for me only, using the ShellExecute("fasm.exe","file.asm file.exe") function of course.

i saw the directives are in tables.inc and used somewhere else to call the related function. i think no more than 20 extra lines are needed in various places of the code. Smile
Post 21 Nov 2013, 15:42
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
It doesn't only brings the possibility to improve our laziness, it also let us imagine many cool and usefull usage of fasm as a pure and universal development tool, depending on what macros are defined, and it will let you generate many files.

another feature would be to generate multiple files from only one source file.

compile "file.asm" would be very cool, but a sort of compile container would be far more interresting.

compile "file.bin" {
blablabla
}

this second featurewould be very hard to implement.
Post 28 Jan 2014, 10:27
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15975
Location: Qo'noS
You could use fasm.dll to do the compilation and just have wrapper code to extract out the "compile" directives. Although care must be taken with the dll since it doesn't support multiple threads so only one section can be compiled at a time.
Post 28 Jan 2014, 10:36
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
hem, in fact, only a sort of compile block could be interresting cause it can cover all usecases

Code:
compile "file.bin" {;create a binary file from another source code
include "file.asm"
}

compile "file1.bin" {;create a binary file from code
mov eax,ebx
}

myfile = "file2.bin"

compile myfile {;create an empty binary file
}

    
Post 29 Jan 2014, 10:22
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15975
Location: Qo'noS
edfed wrote:
hem, in fact, only a sort of compile block could be interresting cause it can cover all usecases

Code:
compile "file.bin" {;create a binary file from another source code
include "file.asm"
}

compile "file1.bin" {;create a binary file from code
mov eax,ebx
}

myfile = "file2.bin"

compile myfile {;create an empty binary file
}

    
So what you really want is a batch file type of thing. I wonder if any OSes support such a thing? Wink
Post 29 Jan 2014, 13:41
View user's profile Send private message Visit poster's website Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
I would like the compile keyword, but it would be nice to make the compile keyword tell FASM to incbin it.
Which means:
The compile keyword will compile the program, like LOL.ASM to LOL.BIN
and add this during compilation,
Code:
file 'LOL.BIN'     

This would help us have two ORGs in one program without specifically compiling each part.
Else than that as others said it would become a Makefile mess, I hate GNU,C and Make for that reason which makes me get faith in MS VB and C#.
Post 29 Jan 2014, 14:31
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
sid123 wrote:
This would help us have two ORGs in one program without specifically compiling each part.
Why not have multiple modules in source, each with its own ORG / adressing space setup?
Post 29 Jan 2014, 14:46
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
Tomasz Grysztar wrote:
Why not have multiple modules in source, each with its own ORG / adressing space setup?


I don't know either what he meant. I use ORG sometimes extensively and added PHASE and DEPHASE directives in FASM as used in some older assemblers for compatibility. These commands can be cascaded and I use an internal address stack for that. Wink

Quote:
org 9000h

Set the address to assemble to 0x9000.

phase address

Continue to produce code and data for loading at the current address but assemble instructions and define labels as if they originated at the given address. Useful when producing code that will be copied to a different location before being executed (e.g., an overlay).

dephase

End phase mode assembly.


http://members.shaw.ca/gp2000/zmac.html
http://www.xl2s.tk
Post 30 Jan 2014, 00:06
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4160
Location: 2018
yep, it looks a lot like a sort of batch or make file.

but at least, this will be a makefile with a far more power than any other batch/makefile ever designed before, and can lead fasm to become an universal tool (it is still an universal assembler)

i also have a project for fasm/os.

using fasm as a shell in my future os (when i will have it working, just after having it in progress, just after having it out of the project box... Laughing)
Post 30 Jan 2014, 09:13
View user's profile Send private message Visit poster's website Reply with quote
badc0de02



Joined: 25 Nov 2013
Posts: 216
Location: %x
edfed,
edfed wrote:

Code:
file "kernel.bin";assume the image is mounted in a linear adress space
BROWSER:
file "browser.bin";the browser    



why you not make:

Code:
include "kernel.asm"
BROWSER:
include "browser.asm"    
Post 01 Apr 2014, 15:19
View user's profile Send private message Reply with quote
badc0de02



Joined: 25 Nov 2013
Posts: 216
Location: %x
edfed wrote:

This would help us have two ORGs in one program without specifically compiling each part.

why not you use
Code:
virtual at 0 ;offset
; code ...
end virtual
    
Post 01 Apr 2014, 16:10
View user's profile Send private message Reply with quote
badc0de02



Joined: 25 Nov 2013
Posts: 216
Location: %x
Quote:

we wouldn't need Windows and Gates

without specific gates our processor will not work.
Post 01 Apr 2014, 16:18
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2018, Tomasz Grysztar.

Powered by rwasa.