flat assembler
Message board for the users of flat assembler.
Index
> Main > Multiple programs in single .asm file |
Author |
|
smiddy 26 Jul 2014, 01:06
Look at "include" and "file" depending on what you are trying to do.
|
|||
26 Jul 2014, 01:06 |
|
l_inc 26 Jul 2014, 01:10
3ric
May I ask you, why you need that? Is there just some esthetical value in having a single file only? Or is there also some practical utility over batch compilation using a shell script? _________________ Faith is a superposition of knowledge and fallacy |
|||
26 Jul 2014, 01:10 |
|
revolution 26 Jul 2014, 07:16
Maybe to match the multi-program-asm file we can also have multiple exe's in a single file. Then we could put the entire OS into a single file.
And then we could go one step further and put both the source codes and the binary exe's all into one single super file that has everything. But I think there is one big problem to solve. What filename to give to this uber-meta-has-everything file? And what extension should it have? |
|||
26 Jul 2014, 07:16 |
|
3ric 26 Jul 2014, 08:04
i have 100+ *.asm file with only few lines of code(10-20), So i thought is it possilbe rather than having all these files i can include all the code in single file thats it. I want to achieve something like this
all in single file: USE32; XOR EAX,EAX ..... ..... RET define filename for this code output:1.bin USE32; XOR EAX,EAX ..... ..... RET define filename for this code output:2.bin USE32; XOR EAX,EAX ..... ..... RET define filename for this code output:3.bin |
|||
26 Jul 2014, 08:04 |
|
revolution 26 Jul 2014, 08:10
You can do it with a batch file:
Code: echo use32 > 1.asm echo ret >> 1.asm fasm 1.asm 1.bin echo use32 > 2.asm echo ret >> 2.asm fasm 2.asm 2.bin |
|||
26 Jul 2014, 08:10 |
|
3ric 26 Jul 2014, 08:46
thanks for your kind reply, But i already know it through batch file.
|
|||
26 Jul 2014, 08:46 |
|
revolution 26 Jul 2014, 08:51
3ric wrote: thanks for your kind reply, But i already know it through batch file. |
|||
26 Jul 2014, 08:51 |
|
3ric 26 Jul 2014, 09:16
I suppose so, But i was kind of thinking it though FASM. btw thanks for looking into it.
|
|||
26 Jul 2014, 09:16 |
|
evk1 26 Jul 2014, 11:17
You can compile a single tar archive and extract all files from it.
Code: ;tar.inc macro ___@integer val,syms,trailingzeroes=0,addr{ match ,addr\{ db (syms)-(trailingzeroes) dup('0'),trailingzeroes dup(0) ___@tar_inc@intend=$-(trailingzeroes)\} match any,addr\{___@tar_inc@intend=(addr)-(trailingzeroes)\} ___@tar_inc@int=val assert ___@tar_inc@int>=0 & ___@tar_inc@int<1 shl (3*((syms)-1)) while ___@tar_inc@int store byte (___@tar_inc@int and 7)+'0' at ___@tar_inc@intend-% ___@tar_inc@int=___@tar_inc@int shr 3 end while} macro ___@fillchecksum{ ___@tar_inc@checksum=0 repeat 512 load ___@tar_inc@int byte from $-% ___@tar_inc@checksum=___@tar_inc@checksum+___@tar_inc@int end repeat store qword '00000000' at $-364 store byte 0 at $-357 ___@integer ___@tar_inc@checksum,8,1,$-356} macro filedata name*,mode=___@tar_inc@fmask,uid=___@tar_inc@uid,gid=___@tar_inc@gid,mtime=%t{ endfiledata local filesize ___@tar_inc@namesize=$ match prefix,___@tar_inc@curdir\{rept 1\\{db prefix\\#name\\}\} ___@tar_inc@namesize=$-___@tar_inc@namesize rb 100-___@tar_inc@namesize ___@integer mode,8,1 ___@integer uid,8,1 ___@integer gid,8,1 ___@integer filesize,12 ___@integer mtime,12 db 8 dup(' ') ;___@integer chksum,8,1 db '0' rb 100 rb 255 ___@tar_inc@filesize equ filesize ___@fillchecksum org 0} macro endfiledata{ match any,___@tar_inc@filesize\{ ___@tar_inc@filesize: restore ___@tar_inc@filesize\} rb (512-($ and 511))and 511} macro directorydata name*,mode=___@tar_inc@dmask,uid=___@tar_inc@uid,gid=___@tar_inc@gid,mtime=%t{ endfiledata ___@tar_inc@namesize=$ match prefix,___@tar_inc@curdir\{rept 1\\{___@tar_inc@curdir equ prefix\\#name\\#'/'\\}\} db ___@tar_inc@curdir ___@tar_inc@namesize=$-___@tar_inc@namesize rb 100-___@tar_inc@namesize ___@integer mode,8,1 ___@integer uid,8,1 ___@integer gid,8,1 db '000000000000' ;___@integer filesize,12 ___@integer mtime,12 db 8 dup(' ') ;___@integer chksum,8 db '0' rb 100 rb 255 ___@tar_inc@filesize equ 0 ___@fillchecksum restore ___@tar_inc@filesize rept 1 deep:___@tar_inc@curdeep+1\{ ___@tar_inc@uid@\#deep=uid ___@tar_inc@uid equ ___@tar_inc@uid@\#deep ___@tar_inc@gid@\#deep=gid ___@tar_inc@gid equ ___@tar_inc@gid@\#deep ___@tar_inc@dmask@\#deep=mode ___@tar_inc@dmask equ ___@tar_inc@dmask@\#deep ___@tar_inc@fmask@\#deep=(mode)and not 7111o ___@tar_inc@fmask equ ___@tar_inc@fmask@\#deep ___@tar_inc@curdeep equ deep\}} macro enddirectorydata{ endfiledata restore ___@tar_inc@curdir,___@tar_inc@uid,___@tar_inc@gid,___@tar_inc@dmask,___@tar_inc@fmask,___@tar_inc@curdeep} macro filemask mode{___@tar_inc@fmask=mode} macro directory name*,mode=___@tar_inc@dmask,uid=___@tar_inc@uid,gid=___@tar_inc@gid,mtime=%t{directorydata name,mode,uid,gid,mtime} macro enddirectory{enddirectorydata} macro symlink name*,file*,mode=___@tar_inc@fmask,uid=___@tar_inc@uid,gid=___@tar_inc@gid,mtime=%t{ endfiledata ___@tar_inc@namesize=$ match prefix,___@tar_inc@curdir\{rept 1\\{db prefix\\#name\\}\} ___@tar_inc@namesize=$-___@tar_inc@namesize rb 100-___@tar_inc@namesize ___@integer mode,8,1 ___@integer uid,8,1 ___@integer gid,8,1 db '000000000000' ;___@integer filesize,12 ___@integer mtime,12 db 8 dup(' ') ;___@integer chksum,8 db '2' ___@tar_inc@namesize=$ db file ___@tar_inc@namesize=$-___@tar_inc@namesize rb 100-___@tar_inc@namesize rb 255 ___@tar_inc@filesize equ 0 ___@fillchecksum restore ___@tar_inc@filesize} macro hardlink name*,file*,mode=___@tar_inc@fmask,uid=___@tar_inc@uid,gid=___@tar_inc@gid,mtime=%t{ endfiledata ___@tar_inc@namesize=$ match prefix,___@tar_inc@curdir\{rept 1\\{db prefix\\#name\\}\} ___@tar_inc@namesize=$-___@tar_inc@namesize rb 100-___@tar_inc@namesize ___@integer mode,8,1 ___@integer uid,8,1 ___@integer gid,8,1 db '000000000000' ;___@integer filesize,12 ___@integer mtime,12 db 8 dup(' ') ;___@integer chksum,8 db '1' ___@tar_inc@namesize=$ db file ___@tar_inc@namesize=$-___@tar_inc@namesize rb 100-___@tar_inc@namesize rb 255 ___@tar_inc@filesize equ 0 ___@fillchecksum restore ___@tar_inc@filesize macro endtar{ enddirectorydata db 512*2 dup(0) restore ___@tar_inc@filesize} ___@tar_inc@filesize equ ___@tar_inc@curdir equ '' ___@tar_inc@curdeep equ 0 ___@tar_inc@dmask@0=755o ___@tar_inc@fmask@0=644o ___@tar_inc@uid@0 equ 0 ___@tar_inc@gid@0 equ 0 ___@tar_inc@dmask equ ___@tar_inc@dmask@0 ___@tar_inc@fmask equ ___@tar_inc@fmask@0 ___@tar_inc@uid equ ___@tar_inc@uid@0 ___@tar_inc@gid equ ___@tar_inc@gid@0 Code: ;tarexample.asm format binary as 'tar' include 'tar.inc' directory 'dir1' filedata 'file1.bin' db 0,1,2,3,4,5,6 filedata 'file2.bin' db 'qwerty' filedata 'file3.bin' db 0,1,2,3 dw 0,1,2,3 dd 0,1,2,3 enddirectory endtar _________________ Sorry for my English |
|||
26 Jul 2014, 11:17 |
|
l_inc 26 Jul 2014, 13:39
3ric
Quote: So i thought is it possilbe rather than having all these files i can include all the code in single file thats it Then the following solution should be most appropriate for you. Fix the fasm path at the end as necessary. Save it as a bat- or cmd-file and run. One exe, one dll and one bmp file will be compiled. Code: ;@echo off ;goto make if FILE_SELECTION = '1' ;===================== EXECUTABLE FILE ===================== display 'Executable compiled',13,10 format PE GUI 4.0 entry start include 'win32a.inc' section '.text' code readable executable start: invoke ExitProcess,0 section '.idata' data readable data import library kernel32,'kernel32.dll' include 'api\kernel32.inc' end data else if FILE_SELECTION = '2' ;========================= DLL FILE ======================== display 'Dll compiled',13,10 format PE GUI 4.0 DLL entry DllEntry include 'win32a.inc' section '.text' code readable executable proc DllEntry hinstDLL,fdwReason,lpvReserved mov eax,TRUE ret endp section '.idata' data readable data import library kernel32,'kernel32.dll' include 'api\kernel32.inc' end data section '.reloc' fixups data discardable else if FILE_SELECTION = '3' ;======================= BITMAP FILE ======================= display 'Bitmap compiled',13,10 format binary as 'bmp' BITMAP_WIDTH=640 BITMAP_HEIGHT=480 BITMAP_DEPTH=3 db 'BM' dd $36+BITMAP_WIDTH*BITMAP_HEIGHT*BITMAP_DEPTH dw 0 dw 0 dd $36 dd $28 dd BITMAP_WIDTH dd -BITMAP_HEIGHT dw 1 dw BITMAP_DEPTH*8 dd 0 dd 0 dd 0 dd 0 dd 0 dd 0 rept 1 { local offset,t1,t2,t3,tx1,tx2 repeat BITMAP_HEIGHT offset = %-1 repeat BITMAP_WIDTH t1 = (offset*$100)/BITMAP_HEIGHT t2 = ((%-1)*$100)/BITMAP_WIDTH t3 = (t1-$80)*(t1-$80+1)*(t2-$80)*(t2-$80+1)/$100000 t3 = $100/(t3*2+1) - 1 tx1 = (((t1/$80-1) shr 63)*2+1)*(t1-$80) tx2 = (((t2/$80-1) shr 63)*2+1)*(t2-$80) db (%-1+offset*1) and $FF,(%-1+offset*2) and $FF,(%-1+offset*3) and $FF end repeat end repeat } end if virtual file 'sel.txt':0,1 load FILE_SELECTION byte from $$ end virtual ;:make ;set Include=C:\fasmw\include ;for /L %%i in (1,1,3) do ( ;echo %%i>sel.txt ;C:\fasmw\fasm.exe asm.bat ; ) ;pause Using the ren command you can choose file names. _________________ Faith is a superposition of knowledge and fallacy |
|||
26 Jul 2014, 13:39 |
|
3ric 26 Jul 2014, 16:40
@l_inc Thanks buddy, your solution is by far the most suitable one, and thanks everyone for putting your effort and priceless time into it. If anyone has more better solution you are welcome...
|
|||
26 Jul 2014, 16:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.