NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: Hazique35 on April 07, 2013, 08:01:59 PM
-
Hello, I have been having some trouble with running a program, I am confused on what to use: win32, elf, bin... How do I know which one to use? Does it sometimes have something to do with the code?
thanks
-
The code is not near as significant as the target. For example, ELF64 is not going to work on windows or a 32 bit version of Linux for that matter. What is the program you're trying to assemble and what is the target? Then we will be able to answer more succinctly.
-
section .data
message db "Hello World!$"
section .text
global _start
_start:
mov eax, 4
mov ebx, 1
mov ecx, message
int 0x80
mov eax, 1
int 0x80
There are probably a whole bunch of mistakes in this... I am using windows xp 32 bit. If it helps, I am using this as a virtual machine. Would this conflict with the code?
-
That looks like 32-bit Linux code.
I'm ASSuming you are running a Linux distro in a virtual machine on your Win32 computer?
If so, then to assemble the code for Linux: nasm -f elf32 -o hello.o hello.asm
You then need to link the object file: ld -o hello hello.o
Finally, run it: $ ./hello
Note that, in your case, your new hello executable will not run outside your virtual machine.
It is a linux program that will only work within a Linux environment.
Hope that helps!
-
Actually, Im running this virtual environment on windows 7, but I couldnt get it to work on windows 7, but now I figured it out. I now know how to run a program, but I am having trouble finding any material for nasm under a windows operating system. If there isnt any, should I just get linux operating system on my virtual machine?