Ask coding questions

← Back to all posts
How Do You Run Assembly in Repl.it
h
AmazingMech2418 (693)

I'm trying to learn Assembly, but don't know how to run it in Repl.it. I tried as and gcc already, trying examples for x86 and x64 Assembly (I normally learn new programming languages by reading code examples) and it returned an error saying "Exec format error". Does anyone know how to fix this?

Here is a screenshot of one of the error messages:

Commentshotnewtop
AmazingMech2418 (693)

I have no idea what I did really, but I got it to work now... Now, to learn Assembly!

CodeLongAndPros (963)

install-pkg nasm
nasm -f bin main.s

AmazingMech2418 (693)

@CodeLongAndPros For me, it says I don't have permission to download a file or something like that.

CodeLongAndPros (963)

@AmazingMech2418 Is this the error:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
AmazingMech2418 (693)

@CodeLongAndPros Actually, it is
now. It isn't even getting to the error now, it is just stopping.

AmazingMech2418 (693)

@CodeLongAndPros I'm pretty sure that was a past error message, but now it just is stopping. I don't really know why though... The first time it happened was when I was trying to install ubuntu-mate-desktop on a bash repl...

AmazingMech2418 (693)

@CodeLongAndPros What file do I run to compile it?

CodeLongAndPros (963)

@AmazingMech2418

sh autogen.sh
sh configure --prefix=$HOME
make
make install
AmazingMech2418 (693)

@CodeLongAndPros I couldn't get NASM to work, but I got GAS to work. I honestly don't even know what I did, but it works!

TheForArkLD (660)
as main.s
chmod +wrx a.out
./a.out
AmazingMech2418 (693)

@TheForArkLD It is something with either the assembler or the platform for Assembly. I tried x86 and x64 and neither would work. I was told by someone else that Repl.it used x86, but the AMD64 architecture makes me think it would be x64 instead.

TheForArkLD (660)

@AmazingMech2418 Oh yes probably it’s correct

AmazingMech2418 (693)

@TheForArkLD It was x86. Apparently, I had to use gcc instead of as. I honestly have no idea what I did differently, but it works now!

TheForArkLD (660)

@AmazingMech2418 cool!(you thinking what is next language?)

Giothecoder (127)

It’s because you didn’t link your code yet. Basically before you can run the code you have to link it. The assembler only gives you an object file, not a actual executable. You have to use lid first

Edit: use ld

AmazingMech2418 (693)

@Giothecoder If there are errors, do you know where to find an example Assembly program that will work?

Giothecoder (127)

@AmazingMech2418 it’s just one error and I think I know a link to the answer give me one sec....

Giothecoder (127)

the as command, mwilki7’s Soft CPU, download nasm or yasm, gcc -s, stuff like that.