Skip to content
← Back to Community
How Do You Run Assembly in Repl.it
Profile icon
AmazingMech2418

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:
image

Voters
Profile icon
a2br
Profile icon
BilalBaheer
Profile icon
Alexandru74
Profile icon
coding1001
Profile icon
programmeruser
Profile icon
fuwn
Profile icon
TheForArkLD
Profile icon
Giothecoder
Profile icon
TheBreadFish
Profile icon
Jakman
Comments
hotnewtop
Profile icon
Jakman

Add a comment

Profile icon
LuckyHackers1

Replit is shit you can't even send cpu assembly to pc to do something thats why you need real hardware

Profile icon
AmazingMech2418

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

Profile icon
CodeLongAndPros

install-pkg nasm
nasm -f bin main.s

Profile icon
AmazingMech2418

@CodeLongAndPros package install error...

Profile icon
CodeLongAndPros

@AmazingMech2418 It worked for me…

Profile icon
AmazingMech2418

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

Profile icon
CodeLongAndPros

@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?
Profile icon
AmazingMech2418

@CodeLongAndPros I think so.

Profile icon
CodeLongAndPros

@AmazingMech2418 And you ran install-pkg nasm?

Profile icon
AmazingMech2418

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

Profile icon
AmazingMech2418
Profile icon
AmazingMech2418

@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...

Profile icon
CodeLongAndPros

@AmazingMech2418 Try cloning this repo:
https://github.com/bitwiseworks/nasm-os2
and compile from source.

Profile icon
AmazingMech2418

@CodeLongAndPros What file do I run to compile it?

Profile icon
CodeLongAndPros

@AmazingMech2418

sh autogen.sh sh configure --prefix=$HOME make make install
Profile icon
AmazingMech2418

@CodeLongAndPros
image

Profile icon
CodeLongAndPros

@AmazingMech2418 install-pkg dh-autoreconf

Profile icon
CodeLongAndPros
Profile icon
AmazingMech2418

@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!

Profile icon
TheForArkLD
as main.s chmod +wrx a.out ./a.out
Profile icon
AmazingMech2418

@TheForArkLD
image

Profile icon
TheForArkLD
Profile icon
AmazingMech2418

@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.

Profile icon
TheForArkLD

@AmazingMech2418 Oh yes probably it’s correct

Profile icon
AmazingMech2418

@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!

Profile icon
TheForArkLD

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

Profile icon
Giothecoder

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

Profile icon
Giothecoder

@Giothecoder seems you’ve got some errors too. https://repl.it/@Giothecoder/Assembly-Pi

Profile icon
AmazingMech2418

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

Profile icon
Giothecoder

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

Profile icon
Giothecoder

@AmazingMech2418 gah. Couldn’t find it.

Profile icon
Giothecoder

Oh wait

Profile icon
Giothecoder

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