Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 194 Vote(s) - 3.65 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a Makefile for a program for assembly Language?

#1
I've come across this task to build a Makefile for a program in assembly language I made (nothing fancy, like a hello world). The program is in Linux 32 bits and I'm using NASM assembler. So far I can only find Makefiles for programs for C, I'm aware that there's not much difference from one to another but I'm not familiar with this thing. What I have is this:

Program: main.o
gcc -o Program main.o
main.o: main.asm
nasm -f elf -g -F stabs main.asm

I can't tell whether this is correct or, if it does, how it works. I can't try the code because this computer doesn't have Linux. I really would like to know what's going on in the code.
Reply

#2
First of all, read [an introduction to Makefile][1].

Your Makefile is read by the `make` program on invocation. It executes either the given rule (e.g. `make clean`) or executes the default one (usually `all`).

Each rule has a name, optional dependencies, and shell code to execute.

If you use objects file you usally start your Makefile like that:

all: main.o
gcc -o PROGRAM_NAME main.o

The dependency here is `main.o`, so it must be resolved before the execution of the code. Make searches first for a file named `main.o` and use it. If it doesn't exist, it search for a rule permitting to make the file.

You have the following:

main.o: main.asm
nasm -f elf -g -F stabs main.asm

Here the rule to make `main.o` depends on `main.asm`, which is your source file so I think it already exists. The code under the rule is then executed and has to make the file matching the rule name.
If your `nasm` invocation is correct, then the file is created and the code of the `all` (or `Program` as you named it) is executed.

So your Makefile *should* work, you just have to test it to be sure :) It is barely the same as invoking:

nasm -f elf -g -F stabs main.asm && gcc -o Program main.o

As a side note, you can still test this on windows as long as you have all the tools installed. The [cygwin][2] project provides an environment where you can install `make`, `gcc` and `nasm`.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through