6

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

2
  • 2
    Which architecture, operating system, and assembler has that file been written for?
    – fuz
    Apr 15, 2019 at 19:44
  • 3
    Unlike "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. Apr 16, 2019 at 6:18

1 Answer 1

7

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,

  1. Set up your development environment: https://ccm.net/faq/1559-compiling-an-assembly-program-with-nasm#compiling-an-assembly-program-with-nasm-for-windows
  2. Copy the assembly code
  3. Open notepad
  4. Paste the code
  5. Save on your desktop as "assembly.asm"
  6. Hold shift, right click on your desktop, select "Open command window here" from the dropdown
  7. Enter the following two commands:
  8. nasm -f win32 assembly.asm -o test.o
  9. 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.

4
  • 1
    You'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
  • 1
    can you please answer this question assuming we're on linux and using x86 ?
    – Gray Hat
    Aug 24, 2020 at 9:37
  • @GrayHat stackoverflow.com/questions/3314919/… mind the difference in syntax, if it's NASM or something else
    – AnnoyinC
    Aug 25, 2020 at 11:23
  • 3
    Assembly itself will not crash your computer at all. This goes for any other language. Jan 15, 2022 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.