flat assembler
Message board for the users of flat assembler.
Index
> Windows > "Can't open existing file". |
Author |
|
revolution 11 Mar 2019, 23:48
You will need to link the output with a linker to make an executable file.
Another option is to use fasm itself to make the executable directly. Code: format pe console ... Code: format pe gui ... |
|||
11 Mar 2019, 23:48 |
|
Ali.Z 11 Mar 2019, 23:51
you need at least 1 winapi call in order to execute the file, as win loader will say its not a valid win32 application.
Code: format PE entry main section '.text' code readable executable main: mov eax, 2 add eax, 3 add eax, 4 ; eax = 9 ret ; on ret you will exit with error code 9 karl: ; karl is never called or executed push ebp mov ebp, esp mov eax, 0 mov esp, ebp pop ebp ret section '.data' data readable writeable duper equ 1 _________________ Asm For Wise Humans |
|||
11 Mar 2019, 23:51 |
|
mcmike 12 Mar 2019, 10:00
Ali.Z wrote: you need at least 1 winapi call in order to execute the file, as win loader will say its not a valid win32 application. Thank you for the hint! I know that karl is never called, I decided to include it still for future reference. I have modified code like this: Code: format PE64 console entry main include 'win64a.inc' section '.code' code readable executable main: call karen mov eax, 2 add eax, 3 add eax, 4 invoke ExitProcess, eax karen: push ebp mov ebp, esp mov eax, 0 mov esp, ebp pop ebp ret section '.idata' import data readable writeable library kernel32,'kernel32.dll' import kernel32,\ ExitProcess, 'ExitProcess' And it doesn't compile, saying push ebp is an illegal instruction. |
|||
12 Mar 2019, 10:00 |
|
revolution 12 Mar 2019, 12:50
For 64-bit code there is no encoding for 32-bit pushes. But since your code is 32-bit then using "format pe console" should solve your problem.
|
|||
12 Mar 2019, 12:50 |
|
Marut 12 Mar 2019, 14:09
I.E. you should use PE instead of PE64, and win32a.inc instead of win64a.inc
Or, you could compile a 64-bit binary and have: Code: format PE64 console entry main include 'win64a.inc' section '.code' code readable executable main: call karen mov eax, 2 add eax, 3 add eax, 4 invoke ExitProcess, rax karen: push rbp mov rbp, rsp mov eax, 0 mov rsp, rbp pop rbp ret section '.idata' import data readable writeable library kernel32,'kernel32.dll' import kernel32,\ ExitProcess, 'ExitProcess' |
|||
12 Mar 2019, 14:09 |
|
mcmike 12 Mar 2019, 18:43
Thank you for the answer! It seems so obvious now when I know what is up. What is better to use on modern windows, 64 or 32 bit? Obviously 32 bit allows for backwards compatibility, but this isn't really my priority in a learning environment and it doesn't seem complicated to change.
|
|||
12 Mar 2019, 18:43 |
|
DimonSoft 12 Mar 2019, 23:19
I’d say 64-bit programming is not as assembly-programmer-friendly as 32-bit is due to the calling conventions used by the OS that seem to be more compiler-oriented than human-oriented. So, if WinAPI is also a subject to learn at the same time, I’d still suggest using 32 bits, at least for a while.
|
|||
12 Mar 2019, 23:19 |
|
Ali.Z 13 Mar 2019, 17:03
mcmike wrote: Thank you for the answer! It seems so obvious now when I know what is up. What is better to use on modern windows, 64 or 32 bit? Obviously 32 bit allows for backwards compatibility, but this isn't really my priority in a learning environment and it doesn't seem complicated to change. learning the environment is important, and its kinda complicated. you should learn the architecture you want to program for i.e. x86 or x86_64, as well as the operating system you are programming in. _________________ Asm For Wise Humans |
|||
13 Mar 2019, 17:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.