Skip to content

Instantly share code, notes, and snippets.

@ThePyProgrammer
Created August 23, 2022 09:36
Show Gist options
  • Save ThePyProgrammer/f4d9ca9105b7f997724221f6879148d6 to your computer and use it in GitHub Desktop.
Save ThePyProgrammer/f4d9ca9105b7f997724221f6879148d6 to your computer and use it in GitHub Desktop.
Run x86 ASM Assembly from WSL2
file=$1
patharr=(${file//./ })
finalexe=${patharr[0]}
nasmfile="${finalexe}.o"
nasm -f elf64 $file
ld -s -o $finalexe $nasmfile
@ThePyProgrammer
Copy link
Author

ThePyProgrammer commented Aug 23, 2022

I guess the best way to code this is as follows:

In your ~/.bashrc:

function asm() {
  file=$1
  patharr=(${file//./ })
  finalexe=${patharr[0]}
  nasmfile="${finalexe}.o"
  echo "${patharr}"
  echo "${finalexe} ${nasmfile}"
  nasm -f elf64 $file
  ld -s -o $finalexe $nasmfile
}

export -f asm

Then in WSL2:

$ asm filename.asm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment