A Docker container configured for writing NASM x86 Assembly & C.
The container has NASM, GCC, GDB, Make, Vim, et cetera installed.
- macOS, Linux, or Windows 10
- Docker
Make sure you've got Docker running, then run
docker compose build
To load the Debian container's Bash shell run
docker compose run nasm-gcc
...and you'll see a command prompt like this
llp@fa82417446cc:/usr/src#
The nasm-gcc/src
dir is mounted from your host as a volume in the Docker
container, so file changes made on the host or in the container will show up
in both places. This makes it possible to edit files in your host's editor,
then compile, link, and run them in the Docker container.
To compile and create an executable program from nasm-gcc/src/helloworld.asm
,
for example, run docker-compose run nasm-gcc
to enter the container shell,
then run
nasm -felf64 helloworld.asm -o helloworld.o
ld -o helloworld.out helloworld.o # link helloworld.out with helloworld.o
chmod u+x helloworld.out # give helloworld.out execute permission
./helloworld.out # run helloworld.out
or just make run
...and you'll see "hello world!" printed to stdout.
To disassemble an executable, run
ndisasm -b 64 helloworld.out > _helloworld.asm