You are not logged in.

#1 2021-03-27 09:11:21

Nuskett
Member
Registered: 2021-03-27
Posts: 2

Assembly language IDE

Hi guys, this is my very first thread, account created today, so i'm not sure i should post this here. If not let me know i will surely move on the more appropriate topic. Also, i'm very new to linux in general. Arch is my first distro ever and i have been using it for almost 2 months now. But i have a "serious" problem. I need to find an IDE for assembly language. The problem is that i don't even know (or better, i'm not sure) what kind of assembly is. It should be the x86 one (pentium) but just to be sure i'll leave an example code near the end. Still, i've been searching for an IDE for quite a while now. I used gcc from command line and visual code with variuos extensions, none worked for me. I need something i can write assembly code (with C language as well, as you may see from the example in the end) and that maybe has some intellisense or some extra functions, which are not necessary but welcome. Any suggestions please? P.S. Forgive my very bad english but it's not my motherlanguage : | .

Example (that has worked only on visual studio so far)

int main () {

int res;

__asm{

MOV EAX,5
MOV EBX,4
ADD EAX,EBX
MOV res,EAX

}

printf("Res is %d",res);
}

Offline

#2 2021-03-27 14:45:15

mpan
Member
Registered: 2012-08-01
Posts: 1,639
Website

Re: Assembly language IDE

The code above is not valid C code. If it works, it’s because of some non-standard Visual Studio extensions. And by “not valid” I mean “hard invalid” — it can’t even be skipped by replacing the __asm with a macro that swallows its contents, like that of gcc’s. Therefore it can only be used in Visual Studio.

The syntax for inline assembly in C is:

asm("… your code …");

Or, in gcc with its extended-asm notation:

__asm__("… your code …" : outputs : inputs : clobbers);

The code from the post above would be, in gcc notation:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int res;
    
    __asm__ (
        "mov    $5, %%eax       \n"
        "mov    $4, %%ebx       \n"
        "add    %%ebx, %%eax    \n"
        "mov    %%eax, %[res]   \n"
        :   [res] "=r" (res)
        :   
        :   "eax", "ebx"
    );
    
    printf("res is %d\n", res);
    
    return EXIT_SUCCESS;
}

This is suboptimal, as it clobbers specific registers and does unnecessary memory writes, but this is what the original code did.

In the pure C notation it is too hard to write reliably, because it requires determining the location of the res variable, which depends on many factos — down to what compiler chooses during the given compilation run.

As for the IDE, I do not know any and I am wondering if there even is any. In particular C-with-asm one. What would you expect from it, considering that there is close to nothing an IDE could do in that situation? Suggesting names of two or three variables you use in the block and type faster than the IDE can find them? Adding the last ‘x’ in the register name?

Last edited by mpan (2021-03-27 14:48:08)

Offline

#3 2021-03-27 14:51:36

Nuskett
Member
Registered: 2021-03-27
Posts: 2

Re: Assembly language IDE

Ok man. Look i honestly don't undestand everything you wrote, but i got the core. I thank you for your answer, but i would let you know that i'm asking this out of pure ignorance, since i'm learning assembly for school and they use visual studio. I was hoping there was something equivalent on linux, but since there's not, i will stick to the dualboot i was alredy using. Thanks for the answer.

Offline

#4 2021-03-27 15:43:00

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,352

Re: Assembly language IDE

Nuskett wrote:

I was hoping there was something equivalent on linux, but since there's not, i will stick to the dualboot i was alredy using.

A few years ago Microsoft opened up VS and made it cross platform. Nowadays it runs on many non-MS systems, including archlinux .

See https://wiki.archlinux.org/index.php/Visual_Studio_Code

Last edited by Lone_Wolf (2021-03-27 15:43:20)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2021-03-27 15:48:01

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: Assembly language IDE

clang seems to have implemented most of the MSVC style inline assembly, so you could probably use that to compile https://stackoverflow.com/a/57186896

I do not know if any editors support syntax highlighting or autocomplete, though. Maybe VSCode?


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#6 2021-03-27 18:30:45

mpan
Member
Registered: 2012-08-01
Posts: 1,639
Website

Re: Assembly language IDE

Nuskett wrote:

Ok man. Look i honestly don't undestand everything you wrote, but i got the core.

With comments:

    __asm__ (
        // AT&T syntax for assembly. Double %% is needed, because `__asm__`
        // itself uses % and it has to be escaped. The meaning of these lines
        // is identical to your code above.
        "mov    $5, %%eax       \n"
        "mov    $4, %%ebx       \n"
        "add    %%ebx, %%eax    \n"
        "mov    %%eax, %[res]   \n"
        // Output operands. In this case we use `res` variable (indicated
        // by round brackets) as the output register ("=r"). Operands
        // could be referenced by their indices, but %0, %1, … isn’t very
        // readable, so the operand is named `res`(the square brackets).
        :   [res] "=r" (res)
        // Input operants; unused here
        :   
        // Clobbers; Since here we use EAX and EBX registers, compiler
        // must be somehow told that those registers are used.
        :   "eax", "ebx"
    );
Nuskett wrote:

I thank you for your answer, but i would let you know that i'm asking this out of pure ignorance, since i'm learning assembly for school and they use visual studio.

Perhaps the school has an RDP server you could connect to and use the VS directly through FreeRDP / Remmina?

Offline

#7 2021-03-27 22:44:44

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,420
Website

Re: Assembly language IDE

Lone_Wolf wrote:
Nuskett wrote:

I was hoping there was something equivalent on linux, but since there's not, i will stick to the dualboot i was alredy using.

A few years ago Microsoft opened up VS and made it cross platform. Nowadays it runs on many non-MS systems, including archlinux .

See https://wiki.archlinux.org/index.php/Visual_Studio_Code

Visual Studio is an entirely seperate product that includes a C++ (amongst others) IDE and compiler. Visual Studio Code is a generic editor.


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#8 2021-03-27 23:04:15

darkskyabove
Member
Registered: 2014-07-15
Posts: 14

Re: Assembly language IDE


To emulate flesh machines, I am learning...

Offline

Board footer

Powered by FluxBB