Assembly Language Programming

I’m looking for recommendations for an Assembler programming editor/ide etc. for pc assembly language. Is there an assembler packaged with openSuSe 11.3? I’m trying to set up a programming environment similar to MASM32 under Windows. I’ve tried NASM but it only provides a command line interface. If that’s my only option so be it. Just wondering what the community thinks and/or uses.
Thanks,
bj

Is your goal to learn assembly language irrespective of CPU? If so there are IDEs and simulators for various microcontrollers.

As for x86* assembly language, only a handful of people need to do this sort of thing, people writing libraries, machine emulators, media processing, tight number crunching code. For the vast majority of people there’s no reward in it.

I’m an IBM Mainframe systems programmer writing in assembler. My love of the language and curiosity of ‘how things work’ leads me to explore PC assembler. Following getting footed in assembler, I plan on moving to C/C++. Are you suggesting I skip the assembler?

Yes, C is the system language for Unix/Linux. The system call API is specified for C and you’ll actually have a harder time trying to map that back to assembler.

I seem to remember that there’s a way of using gcc with assembler code. However, the assembler language supported is a bit different from that of MASM. It’s been a few years, so I have forgotten the details.

Try a google search for “intel assembler gcc” (without the quotes) and see what turns up.

You can insert inline assembly code into gcc. The syntax will be that of gas. And of course if you know the linkage conventions, you can write code for gas and compile to object files.

You can try ‘as’.

For tools - I use vim for a lot a stuff, but I also don’t write assembly :slight_smile:

Btw, one can use gcc and it’s inline assembly even with “intel syntax”, something like:


/* 32bi compile as follow:
 * gcc -o intelsyntax -nostdlib -masm=intel intelsyntax.c
 */

/* This is needed only for macros which provide system call numbers. */
#include <sys/syscall.h>

void _start()
{
    int exit_sc = __NR_exit;
    int write_sc = __NR_write;
    char *msg = "Hello, World!
";

    /* Make write system call. */
    asm("mov eax,-0x8[ebp];"    /* write system call number */
            "mov ebx,1;"                 /* file descriptor number */
             "mov ecx,-0x4[ebp];"   /* buffer we are going to write */
             "mov edx,0xe;"            /* buffer lenght */
             "int 0x80;"
           );

    /* Time to make exit system call. */
    asm("mov eax,-0xc[ebp];"
            "xor ebx,ebx;"
            "int 0x80"
            );
}

but…it’s kinda tedious :slight_smile:

For assembly itself…apart from some very-very low level stuff(when compiler intrinsics are not enough), bit of assembly could be great help when things go wrong and there’s no debug info. For me that’s mostly the ABI and how particular registers are used(I’m game developer so this mean mostly how C++ object and function calls are handled).

BLJeffery wrote:

> I’m an IBM Mainframe systems programmer writing in assembler. My love
> of the language and curiosity of ‘how things work’ leads me to explore
> PC assembler. Following getting footed in assembler, I plan on moving
> to C/C++. Are you suggesting I skip the assembler?

Skip any serious assembler stuff. Knowing the instruction set is handy now
and again. Start on C. It’s possible to examine the intermediate assembler
if you pass the compiler the proper switches.

If you want to do C++ you probably have to unlearn a lot - otoh it comes in
very handy if you want to explore Qt and KDE for example, they are both
written in C++ mostly.


R.F. Pels, Boogerd 1, 1791 GW Den Burg, The Netherlands
ruurd@tiscali.nl +31612914545 http://home.tiscali.nl/ruurd

On 12/19/2010 05:36 PM, BLJeffery wrote:
>
> I’m looking for recommendations for an Assembler programming editor/ide
> etc. for pc assembly language. Is there an assembler packaged with
> openSuSe 11.3? I’m trying to set up a programming environment similar
> to MASM32 under Windows. I’ve tried NASM but it only provides a command
> line interface. If that’s my only option so be it. Just wondering what
> the community thinks and/or uses.
> Thanks,
> bj
>
>
There is “as” which is part of Gnu Binutils which can be installed using
Yast. I do not know of any ide for assembly but vim would be a good
editor. I had seen a book published by Wrox which had a lot of info on
assembly for linux but I do not remember the name. I ended up buying
“Linux Programming” 3rd Edition from the same publisher instead which
does not have any assembly in it. I never did get very far into the
book due to time constraints and it still sits on the shelf looking
unloved. :slight_smile:

I almost forgot about another good text that is available for free
called “Programming from the Ground Up” written by Jonathan Bartlett.
It is available from:

http://savannah.nongnu.org/projects/pgubook/

Eric

What you want is ‘highlevelassembler’ which allows you to write in gcc acceptable assembly code. You can easily integrate your assembly language programs seemlessly with c/c++, can build libraries callable from c/c++ if you excuse that c/c++ tends to be in-efficient on many system functions. You want real power I would suggest since you are already an accomplished assembler programmer it gives you an easy step into doing Linux programming and can decide if/when you want to choose to move to the more limited c/c++ coding. This is just MOHO.

Things you might consider are:

  1. c/c++ supports 19 of the current 31 protective memory model modes but gcc supports all 31.
  2. c/c++ does not support call short direct or indirect which means tight code (for i/o functions) will take the more memory hungry double word unless you force c/c++ to do inline assembly.
  3. c/c++ uses standard c - library calls to c/c++ libraries but can be forced to also access standard system calls which by design are used by assembly,
    pascal, fortran, rpg2, cobol, xForms, and xBasic.
  4. By design, assembly can talk with functions written in all the above languages except that you must specify cdecl calls to c-functions so that order precedence is preserved.

By the way, there are someone on the forum, who love this language and use assembler just for fun?

I would do assembly language, but for microcontrollers, not for PCs. Too little return for too much work, unless the return you want is to understand machine architecture. Alas, I don’t have to time to fiddle with electronics these days.

I used to pride myself on understanding the perversions of the various memory models of the 286, but Intel’s gone sensible and flat model is the go nowadays. :wink:

While I use assembly on an as needed basis these days, the simplicity of being able to code and to control operations is fun! as even simple c/c++ code that fails to perform as expected ranks as easy but not fun.

@ken_yap Yes they have gone more flat model :frowning: and the schools have also gone to a lame model of skipping timed device control. It’s sad really that where entry to the elite engineers group used to mean you could correctly understand and write timed control, now you just need to assume the control timing is good and just construct your program to call onboard control functions. A lot gets lost in the translation IMHO.