To start with assembly programming I've collected here some "basic" examples.  Basic doesn't mean that they are simple but I've tried to get the most general operations together is this category like read from keyboard, a file, write to stdout, collect command line arguments and get the environment parameters.  Absolute beginners should start with hello.asm which is, as in other programming languages, the initial introduction.  Sources can be downloaded at Github.  To build the examples each source code has the build instructions in the comment on top of the source.  To build it all at once you can use the Makefile, which is also included at Github, below.


BIN=arguments cpuid cwd dealcards dirinfo hello inputdemo keyfilter palindrome printenv readfile rotatebits uuid waitforkeypress waitforenterkeypress winsize

NASM=/usr/bin/nasm
NASMOPTS=-felf64 -Fdwarf
LDOPS=-melf_x86_64 -g

.PHONY: all clean

all: $(BIN)

clean:
	rm -rf $(BIN)

%: %.asm
	$(NASM) $(NASMOPTS) -o $@.o $<
	$(LD) $(LDOPS) -o $@ $@.o
	rm -f $@.o