|
-
October 10th, 2010, 11:07 PM
#1
Run assembly programs inside microsoft windows?
For the longest time I used linux for writing my assembly programs and it worked perfectly.
My current PC has windows xp on it and is used for both gaming and for assembly programming.
After reading around a bit on windows programming, I made a simple example:
Code:
global _WinMain@16
extern _MessageBoxA@16
section .data
parm1 db "Program", 10, 0
parm2 db "Hello World", 10, 0
section .code
_WinMain@16
push 0
push dword parm1
push dword parm2
push 0
call _MessageBoxA@16
add esp, 8
ret 16
It assembles correctly however I have no idea how to link it to an executable.
It only creates an object file once assembled.
Code:
nasm -f win32 program.asm -o program.obj
-
October 11th, 2010, 05:02 PM
#2
Re: Run assembly programs inside microsoft windows?
I haven't done any assembly programming for a very long time but a shot in the dark would be to remove the -o program.obj or maybe rename program.obj to program.exe. Check if current program.obj starts with MZ!
-
October 11th, 2010, 05:33 PM
#3
Re: Run assembly programs inside microsoft windows?
 Originally Posted by S_M_A
I haven't done any assembly programming for a very long time but a shot in the dark would be to remove the -o program.obj or maybe rename program.obj to program.exe. Check if current program.obj starts with MZ!
Even if you remove the -o program.obj, it still creates an object file. :-/
I tried to use ld to make an exe such as:
Code:
ld program.obj -o program.exe
However I get this message:
Code:
undefined reference to MessageBoxA@16
How do I include header files using ld?
-
October 11th, 2010, 05:44 PM
#4
Re: Run assembly programs inside microsoft windows?
You don't include headers when linking, you should link with the appropriate lib/obj. Isn't there any documentation regarding how to build a win32 exe with nasm?
-
October 11th, 2010, 05:47 PM
#5
Re: Run assembly programs inside microsoft windows?
-
October 11th, 2010, 07:05 PM
#6
Re: Run assembly programs inside microsoft windows?
 Originally Posted by S_M_A
[...] or maybe rename program.obj to program.exe.
Uuuh, that's pretty darn evil... 
No, without kidding, older compilers and assemblers used import libraries (file extension .lib) for that purpose. The only assembly module I ever wrote for the Win environment (that was to be finally assembled into a .dll) includes this line for the purpose in question:
Code:
includelib \masm32\lib\user32.lib
This was MASM, however...
HTH
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
October 11th, 2010, 07:06 PM
#7
Re: Run assembly programs inside microsoft windows?
 Originally Posted by S_M_A
So many posts for a single-line solution...
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
October 12th, 2010, 02:30 PM
#8
Re: Run assembly programs inside microsoft windows?
-
October 12th, 2010, 04:31 PM
#9
Re: Run assembly programs inside microsoft windows?
 Originally Posted by S_M_A
Yeah, should have googled before doing the first post... Or in a perfect world, the OP would have googled before posting... 
No, sorry, I didn't mean your posts in this thread here. Instead I meant the archived thread you have linked to...
And I'm not even sure whether my suggestion will help the OP, as I know very little about nasm.
Regarding the rename. It might have been so that the -o option renamed a perfectly good exe output to obj. Just like -o does for gcc (if I remember correct). That's why I asked the op to first look for Mark Zbikowski's initials.
I couldn't imagine any reasonable software might do something like that. Maybe your suggestion actually is the clue that the OP needed.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|