Running a 32bit Binary within WSL can be complicated, because at the moment WSL only runs ELF-64 binaries.
Installation of WSL is described here (docs.microsoft.com)
sudo apt update
sudo apt upgrade
apt install build-essential gcc-multilib
# WSL currently only works on x64 systems, and only runs ELF-64 binaries.
# (https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13377507-please-add-32-bit-elf-support-to-the-kernel)
# so the following must be done:
# (Source: https://github.com/microsoft/wsl/issues/2468#issuecomment-374904520)
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
sudo service binfmt-support start
dpkg --add-architecture i386
apt update
To run an IA-32 Assembler Programm you have to create a file containing the Programm with the file extension *.s
Tip: within WSL you can find under /mnt/c/
your local drive so you can create and edit the Assembler file within your favorite Editor within Windows.
Then maybe you need to start the following sudo service binfmt-support start
After that you can compile your code with gcc –m32 –o example example.s
Now you should be able to run your code with ./example
Tested on Ubuntu 16.04 but should also work with later Versions of Ubuntu. Should also work with Debian.