flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasm as DLL

Goto page Previous  1, 2, 3, 4, 5, 6  Next
Author
Thread Post new topic Reply to topic
masm



Joined: 10 Oct 2014
Posts: 6
masm 12 Aug 2019, 17:30
please helps how i can compile FASMX64.ASM ? when i complile with last version 1.73.16 it is give me erros.


Description:
Filesize: 81.32 KB
Viewed: 18833 Time(s)

fasm.jpg


Post 12 Aug 2019, 17:30
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 12 Aug 2019, 19:41
I'm not sure what might have caused this problem in your case, but I have updated the fasmDLL.zip with re-assembled 1.73.16 version. Please check if the new one works for you.
Post 12 Aug 2019, 19:41
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 12 Aug 2019, 21:13
My first guess was that you’re trying to compile PREPROCE.INC only (start from this file) which doesn’t contain the symbol. Looked through the file and checked that. Choose FASMX64.ASM tab before compiling or better assign it to compiler from context menu.
Post 12 Aug 2019, 21:13
View user's profile Send private message Visit poster's website Reply with quote
Abruzzi



Joined: 30 Sep 2019
Posts: 17
Abruzzi 09 Jan 2020, 16:02
I used FASM DLL to assembly a simple instruction like xor eax, eax and I wonder why the output_length for this particular instruction is 3 and output binary data is something like 0x6631C0.

I tried to add one more instruction to see how the output is changing and for these two lines
Code:
xor eax, eax
xor eax, eax    

the output_length is 6 and output binary data is 0x6631C06631C0. What is this extra byte (0x66) used for?
Post 09 Jan 2020, 16:02
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 805
Location: Russian Federation, Sochi
ProMiNick 09 Jan 2020, 16:48
try this sequence
Code:
use16
xor eax, eax    

thou will see output is the same as thours
than try
Code:
use32
xor eax, eax    


use16 mode is by default in fasm
thou could play with these samples too
Code:
use16
xor ax, ax    
Code:
use32
xor ax, ax    


Abruzzi, than I congratulate thou - thou explore bicicle.
Post 09 Jan 2020, 16:48
View user's profile Send private message Send e-mail Reply with quote
Abruzzi



Joined: 30 Sep 2019
Posts: 17
Abruzzi 09 Jan 2020, 17:16
Many thanks ProMiNick. Indeed using use32 directive the output is 2 bytes length and the resulted opcode is 0x31C0 as I expect.

I tried your examples also.
Code:
use16
xor ax, ax     

generates 0x31C0 as 32 bit mode if I use eax register and
Code:
use32
xor ax, ax     

generates 0x6631C0 as 16 bit mode if I use eax register

I have to dig out to understand why it's encoded in that way. Right now it's just witchcraft. Shocked
Post 09 Jan 2020, 17:16
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 805
Location: Russian Federation, Sochi
ProMiNick 09 Jan 2020, 17:33
Post 09 Jan 2020, 17:33
View user's profile Send private message Send e-mail Reply with quote
Abruzzi



Joined: 30 Sep 2019
Posts: 17
Abruzzi 09 Jan 2020, 18:10
It makes sense now why 66h prefix appear before instruction opcode when I am using 32 bit mode and 16 bit operands and vice versa as I could see. Thank you again ProMiNick.
Post 09 Jan 2020, 18:10
View user's profile Send private message Reply with quote
soloworker



Joined: 09 Dec 2020
Posts: 9
soloworker 09 Dec 2020, 01:24
How can we use this assembler to get the relocatable offsets?

Code:
mov eax,401000h ;Offset
push eax    


It would be great if it supports the read of these types like for example

"Offsets" it writes back the indexes to the offsets. Same for .data section.

Any idea how to achieve that?
Post 09 Dec 2020, 01:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 09 Dec 2020, 05:08
If you use PE format and include a relocs table then you will get a fully relocatable exe.
Post 09 Dec 2020, 05:08
View user's profile Send private message Visit poster's website Reply with quote
soloworker



Joined: 09 Dec 2020
Posts: 9
soloworker 25 Dec 2020, 02:31
Thx revolution. I have noticed that unrefrenced code is not compiled. Why is this case?
Post 25 Dec 2020, 02:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 25 Dec 2020, 03:15
If you use the normal fasm proc/endp macros then it has lines like this:
Code:
if used function ; in proc macro
;...
end if ; in endp macro    
Post 25 Dec 2020, 03:15
View user's profile Send private message Visit poster's website Reply with quote
soloworker



Joined: 09 Dec 2020
Posts: 9
soloworker 25 Dec 2020, 03:46
revolution wrote:
If you use the normal fasm proc/endp macros then it has lines like this:
Code:
if used function ; in proc macro
;...
end if ; in endp macro    


You mean the define@proc macro?

Quote:
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name


Ok i found it. Thanks for your help.
Post 25 Dec 2020, 03:46
View user's profile Send private message Reply with quote
soloworker



Joined: 09 Dec 2020
Posts: 9
soloworker 01 Jan 2021, 08:34
I have a question
Does fasm allocate memory for the same data used in source?
Like for example:
Code:
section '.data' data readable writeable
something  db 83886080 dup(?) '80MB     


When assembling, the fasm.exe memory usage goes over 90 MB. Why is this?
Post 01 Jan 2021, 08:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 01 Jan 2021, 08:37
fasm allocates all data and code in RAM. That includes all uninitialised values.
Post 01 Jan 2021, 08:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 01 Jan 2021, 11:48
soloworker wrote:
I have a question
Does fasm allocate memory for the same data used in source?
Like for example:
Code:
section '.data' data readable writeable
something  db 83886080 dup(?) '80MB     


When assembling, the fasm.exe memory usage goes over 90 MB. Why is this?
The way fasm handles uninitialized data definitions is very similar to initialized ones, it only cuts them out afterwards when possible.

This was improved in case of fasmg's engine - if you assemble the same thing with fasmg, that uninitialized definition is not going to cause any additional memory usage unless you force it to become initialized by putting something initialized after it in the same section.
Post 01 Jan 2021, 11:48
View user's profile Send private message Visit poster's website Reply with quote
soloworker



Joined: 09 Dec 2020
Posts: 9
soloworker 07 Mar 2021, 05:04
Tomasz Grysztar wrote:
soloworker wrote:
I have a question
Does fasm allocate memory for the same data used in source?
Like for example:
Code:
section '.data' data readable writeable
something  db 83886080 dup(?) '80MB     


When assembling, the fasm.exe memory usage goes over 90 MB. Why is this?
The way fasm handles uninitialized data definitions is very similar to initialized ones, it only cuts them out afterwards when possible.

This was improved in case of fasmg's engine - if you assemble the same thing with fasmg, that uninitialized definition is not going to cause any additional memory usage unless you force it to become initialized by putting something initialized after it in the same section.


Thanks for the tip.
I still don't understand why it uses huge memory (like 400mb) when compiling some relatively small exe under 2mb of size with only this code as data. But the size of the code of (.asm) file is 7mb. So big code with few data will also have this problem.

Code:
section '.data' data readable writeable
sss db 'AXaaaaaaaaaaaaAXaaaaaaaaaaaaAXaaaaaaaaaaaaAXaaaaaaaaaaaa',0
sss2 db 'atatatatatatatatatatatatatatatatatatatatat',0
sss3 db 'tatatatatatatatatatatatatatatatatata',0
sss4 db '53535535355353553535535355353553535535355353553535535355353553535535355353553535535355353553535',0    
Post 07 Mar 2021, 05:04
View user's profile Send private message Reply with quote
soloworker



Joined: 09 Dec 2020
Posts: 9
soloworker 09 Mar 2021, 23:42
I found why it uses huge memory.
The macro that is responsible for this is
Code:
allow_nesting    
in WIN32AX.inc file.

If i remove it, fasm.exe uses way less memory. What does it do?
Post 09 Mar 2021, 23:42
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4075
Location: vpcmpistri
bitRAKE 10 Mar 2021, 03:16
iirc, allow_nesting enables using invoke as parameter to another invoke.
Code:
invoke CommandLineToArgvW, <invoke GetCommandlineW>,ADDR nargs    
etc.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 10 Mar 2021, 03:16
View user's profile Send private message Visit poster's website Reply with quote
Ben321



Joined: 07 Dec 2017
Posts: 70
Ben321 06 Dec 2023, 11:44
Tomasz Grysztar wrote:
The subject says all. Wink

I've made fasm into a simple DLL which allows to assemble just inside the memory. The package contains short documentation, demonstration program (which also uses flat editor in DLL form) and the SOURCE directory, which needs to be merged with SOURCE directory of standard fasm's distributions.


I found a bug in the FASM DLL. Not sure if this also impacts the normal EXE version, but I found it certainly impacts the DLL version.

To tell it that a number is hexadecimal, you can either prepend "0x" or append "h" to the number. I found this doesn't work though if the first digit of the number is a hexadecimal letter. For example, 0xF00000 works, but F00000h generates an error. It's fine if the letter is elsewhere in the hex number. This means a temporary work around hers is to prepend a zero before the first letter, like 0F00000h will work. But it's not ideal. I hope this is a bug that you can fix.
Post 06 Dec 2023, 11:44
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6  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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.