Author Topic: How to run a program?  (Read 6950 times)

Offline Hazique35

  • Jr. Member
  • *
  • Posts: 4
How to run a program?
« 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

Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: How to run a program?
« Reply #1 on: April 07, 2013, 08:10:45 PM »
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.

Offline Hazique35

  • Jr. Member
  • *
  • Posts: 4
Re: How to run a program?
« Reply #2 on: April 08, 2013, 01:12:04 PM »
Code: [Select]
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?

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: How to run a program?
« Reply #3 on: April 08, 2013, 03:41:20 PM »
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!



Offline Hazique35

  • Jr. Member
  • *
  • Posts: 4
Re: How to run a program?
« Reply #4 on: April 08, 2013, 04:10:45 PM »
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?