Author Topic: Assembler languages for Linux  (Read 23786 times)

shankle

  • Member
  • ****
  • Posts: 868
Assembler languages for Linux
« on: February 14, 2016, 01:46:33 AM »
Only interested in 64-bit assemblers.
I have found 4 assemblers that will work for Linux. Trouble is I don't
want to pick the wrong one. I already went from MASM32 to Goasm64.
Now due to Windows 10, I have to start all over again. Thank you Microsoft!

The Linux assemblers are: NASM, YASM, FASM and TASM.
From what I have read FASM seems to be the way to go.
Opinions Please....

mabdelouahab

  • Member
  • ****
  • Posts: 510
Re: Assembler languages for Linux
« Reply #1 on: February 14, 2016, 01:56:34 AM »
I prefer HJWAsm

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Assembler languages for Linux
« Reply #2 on: February 14, 2016, 02:21:32 AM »
There's also SOLAR ASSEMBLER written by Bogdan Ontanu

When I moved to Linux I used JWASM  for the first time .
Pros of using JWASM :
         it's 100% MASM compatible and you can focus on learning new platform  - not new syntax
         If you want to program in 32 bit  - you may use Open Watcom standard library ( JWLINK can link it  ) . It's well documented! 
Cons:
         it has limited support for Linux  - no FASTCALL  for example  but you may write your own macro or use sombody else's one to call functions from C lib etc . I have written such a macro - FCALLTEST - it can handle up to 12 parameters but doesn't have floating point arguments support.
         JWLINK in 64 bit mode is very unstable and limited in functionality

Magnum

  • Member
  • *****
  • Posts: 2367
Re: Assembler languages for Linux
« Reply #3 on: February 14, 2016, 04:40:02 AM »
I tried Solar Asm under Linux.

When I run

Quote
sol_asm2.exe test.asm test.obj -elf32

I get

Quote
# ./test.sh
./test.sh: line 5: sol_asm2.exe: command not found
# sol_asm2.exe
bash: sol_asm2.exe: command not found
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Assembler languages for Linux
« Reply #4 on: February 14, 2016, 04:54:49 AM »
Most likely execute permission was not set
Open terminal in directory with sol_asm and execute
Code: [Select]
llIt will show permissions
To set exec permission:
Code: [Select]
sudo chmod +x sol_asm2.exeTo make sure that your binary is valid ELF executable:
Code: [Select]
file sol_asm2.exe
[EDIT] Oops, my bad , you should use this notation (assumed that terminal is opened in directory where sol_asm lives ):
Quote
./sol_asm2.exe ...
« Last Edit: February 14, 2016, 06:08:32 AM by GoneFishing »

Magnum

  • Member
  • *****
  • Posts: 2367
Re: Assembler languages for Linux
« Reply #5 on: February 14, 2016, 05:43:54 AM »
Looks like it is not a Linux exe.

Quote
sol_asm2.exe: PE32 executable (console) Intel 80386, for MS Windows
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Assembler languages for Linux
« Reply #6 on: February 14, 2016, 06:06:28 AM »
Yes, sol_asm is distributed in object form
You must link it to your C lib
Read this ( if you have the latest version) : sol_asm_2012_10_30_v36_12/bin/obj_unix_elf/read_me.txt

Vortex

  • Member
  • *****
  • Posts: 2697
Re: Assembler languages for Linux
« Reply #7 on: February 14, 2016, 06:46:56 AM »
Hi shankle,

Did you find some good Linux x86-64 assembly tutorials? I guess the options are limited.

shankle

  • Member
  • ****
  • Posts: 868
Re: Assembler languages for Linux
« Reply #8 on: February 14, 2016, 08:52:34 AM »
HI Vortex,
Yes a gentleman on the Linux mint forum gave me 3 references about NASM.
The 1st one seems to be very detailed and just what I need.
I'll probably take several weeks trying to digest them.

Until I do more reading and research, I do not at this time know if I can write,
compile and run an assembler program using NASM in Linux.

   

sbk

  • Regular Member
  • *
  • Posts: 5
Re: Assembler languages for Linux
« Reply #9 on: February 14, 2016, 10:38:09 AM »
Hey shankle,

Yes a gentleman on the Linux mint forum gave me 3 references about NASM.
The 1st one seems to be very detailed and just what I need.
I'll probably take several weeks trying to digest them.

Would you mind sharing those references. I'm always interested in NASM related material and I think others following your footsteps toward the Linux world might be interested as well.

Until I do more reading and research, I do not at this time know if I can write,
compile and run an assembler program using NASM in Linux.

It's really not that different from coding on Windows. The biggest difference between the two are the amount of options. With Windows you have the Win API which provides you with uniform access to various features of the operating system. On Linux, the libraries can be different from system to system. For example, simple GUI applications might be dependent on Qt, or GTK, or X/Motif, or whatever.. not all systems are going to have your chosen target by default. This means that, aside from simple system call's and use of the standard C library, your code is usually going to require at least some people to install various libraries to get your program to work. This is oddly acceptable in the Linux world and because of the large number of options for configurations and frameworks, one of the first things the Windows programmer has to learn when switching to Linux is... there is no one correct way to do anything on Linux. I myself kinda miss that about Win32 systems, being able to look up the Windows API reference and know the one correct method to implement a given feature. But it's also liberating, in a way, to be able to choose to develop your software around libraries which share your style of coding.

Anyway, I have faith that you'll do just fine as a Linux programmer. Just avoid telling people what editor you use.. for some reason that starts HUGE arguments within the Linux community.  :lol:

Best Regards,
~ Bryant

shankle

  • Member
  • ****
  • Posts: 868
Re: Assembler languages for Linux
« Reply #10 on: February 14, 2016, 11:50:14 AM »
HI SBK,
The references that you requested can be found on Linuxmint.com/forum.
Then go to the Newbie folder and look under my post called "assembler
languages that work in linux". The references are given by the gentleman
called Reorx. Hope this helps.
If not tell me and I will try to find another way of getting the info to you.

sbk

  • Regular Member
  • *
  • Posts: 5
Re: Assembler languages for Linux
« Reply #11 on: February 14, 2016, 12:25:11 PM »
Only interested in 64-bit assemblers.

This is the reason I wanted to see the references. The examples you were given were specific to 32-bit mode Linux systems. These will build and work under your 64-bit Linux using compatibility mode, but you're question (at least here) was much more specific.

I would say bookmark the Linux Assembly page, that one has been a great resource for years. The third link he gave you is on that page, so he really gave you 2 links. The first one is okay, but you're interested in 64-bit systems and there isn't really enough to that tutorial to warrant spending a lot of time on it.

Check out the following:

Gunther

  • Member
  • *****
  • Posts: 4086
  • Forgive your enemies, but never forget their names
Re: Assembler languages for Linux
« Reply #12 on: February 14, 2016, 09:50:36 PM »
Hi shankle,

my favorite assembler under Linux and BSD is YASM. You'll find some of my Linux sources inside the forum.

The Linux assemblers are: NASM, YASM, FASM and TASM.
From what I have read FASM seems to be the way to go.
Opinions Please....

I think TASM won't work under Linux.

Gunther
Get your facts first, and then you can distort them.

anta40

  • Member
  • ***
  • Posts: 315
Re: Assembler languages for Linux
« Reply #13 on: February 15, 2016, 12:24:46 PM »
If you prefer MASM-style assembler, definitely pick JWASM/HJWASM.
But if you don't mind trying different assemblers, NASM/FASM are fine.
Both are still under active development.

BTW, there's an interesting visual IDE and UI library for FASM, which runs on Windows as well on Linux.

 ;)

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Assembler languages for Linux
« Reply #14 on: February 15, 2016, 08:15:33 PM »
...
BTW, there's an interesting visual IDE and UI library for FASM, which runs on Windows as well on Linux.
...
Didn't tried it yet but have heard of it earlier . Their site looks very original . I really like it .

BTW One should  not forget Linux native GAS assembler .

EDIT: I noticed a couple of issues with SOL_ASM's -elf64 output object format:
assemble /obj_libc/test.asm with -elf64 switch and link :
Quote
/usr/bin/ld: fatal error: test.obj: unsupported ELF machine number 3
I had to edit ELF header to link it successfully
Code: [Select]
elfedit  --output-mach x86-64  test.objNow test app is built but crashes with  Segmentation fault
The reason - no FASTCALL for Linux .
It's very sad news
The thread on  SOL_ASM development froze a year ago that's why I wan't to post there   
« Last Edit: February 16, 2016, 04:14:32 AM by GoneFishing »