I have assembly code in a text file and I don't know how to run it. I wish you can help me with detailed explanation. Thank you
-
2Which architecture, operating system, and assembler has that file been written for?– fuzApr 15, 2019 at 19:44
-
3Unlike "high-level" operating languages, assembler code will only work on a certain CPU type: Assembler code written for x86 (typical PCs) won't work on an ARM CPU (Raspberry Pi). And x86 PCs even have different operating modes requiring specific code. Different operating systems require different code. And finally different programming tools ("assemblers") require a different syntax. If you don't post the code file so we can see it, there is absolutely no chance that we can help you.– Martin RosenauApr 16, 2019 at 6:18
1 Answer
Warning: never run code you don't know. In the case of assembly it can crash your system, or worse.
Assuming your assembly code is x86, And assuming it doesn't look like only rows of "01101010" or "de876f1a6bc37" And assuming that you are on Windows,
- Set up your development environment: https://ccm.net/faq/1559-compiling-an-assembly-program-with-nasm#compiling-an-assembly-program-with-nasm-for-windows
- Copy the assembly code
- Open notepad
- Paste the code
- Save on your desktop as "assembly.asm"
- Hold shift, right click on your desktop, select "Open command window here" from the dropdown
- Enter the following two commands:
- nasm -f win32 assembly.asm -o test.o
- ld test.o -o assembly.exe
Again, be careful with assembly. You also might not get output, so you won't know the output of your program.
-
1You're also assuming that it's NASM syntax for 32-bit x86 for Windows. If it was written for Linux (e.g. with
int 0x80
system calls), it will assemble + link but crash on Windows. And there are many other assembler syntaxes for x86, including MASM being common on Windows. You're making a lot more assumptions than just "x86". Apr 17, 2019 at 1:55 -
1can you please answer this question assuming we're on linux and using x86 ?– Gray HatAug 24, 2020 at 9:37
-
@GrayHat stackoverflow.com/questions/3314919/… mind the difference in syntax, if it's NASM or something else– AnnoyinCAug 25, 2020 at 11:23
-
3Assembly itself will not crash your computer at all. This goes for any other language. Jan 15, 2022 at 19:55