Compile/run assembler in Linux?

后端 未结 8 1793
清歌不尽
清歌不尽 2020-12-22 18:05

I\'m fairly new to Linux (Ubuntu 10.04) and a total novice to assembler. I was following some tutorials and I couldn\'t find anything specific to Linux. So, my question is,

8条回答
  •  不思量自难忘°
    2020-12-22 18:30

    If you are using NASM, the command-line is just

    nasm -felf32 -g -Fdwarf file.asm -o file.o
    

    where 'file.asm' is your assembly file (code) and 'file.o' is an object file you can link with gcc -m32 or ld -melf_i386. (Assembling with nasm -felf64 will make a 64-bit object file, but the hello world example below uses 32-bit system calls, and won't work in a PIE executable.)

    Here is some more info:

    http://www.nasm.us/doc/nasmdoc2.html#section-2.1

    You can install NASM in Ubuntu with the following command:

    apt-get install nasm
    

    Here is a basic Hello World in Linux assembly to whet your appetite:

    http://web.archive.org/web/20120822144129/http://www.cin.ufpe.br/~if817/arquivos/asmtut/index.html

    I hope this is what you were asking...

提交回复
热议问题