diff --git a/.gitignore b/.gitignore index de40e4f..1f7b35e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ bloom wo-lernen lua-foo binsearch +test-inline-assembly +test-inline-assembly.s diff --git a/Makefile b/Makefile index fada90b..046d249 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ CFLAGS=-std=c99 -Wall -g -O2 INDENTOPTS=-kr --no-tabs --braces-on-func-def-line --indent-level2 -TARGETS=approximate-pi linked-list mandelbrot threads circular-buffer structs ncurses-pong bit-fuckery bit-fuckery2 checkcheck multibrot bloom wo-lernen lua-foo binsearch -EXTRAS=mandelbrot.bmp multibrot.png +TARGETS=approximate-pi linked-list mandelbrot threads circular-buffer structs ncurses-pong bit-fuckery bit-fuckery2 checkcheck multibrot bloom wo-lernen lua-foo binsearch test-inline-assembly +EXTRAS=mandelbrot.bmp multibrot.png test-inline-assembly.s .PHONY: all all: $(TARGETS) $(EXTRAS) @@ -34,3 +34,9 @@ multibrot.png: multibrot lua-foo: lua-foo.c $(CC) $(CFLAGS) -o $@ $< -llua -lm + +test-inline-assembly: test-inline-assembly.c + $(CC) -Wall -o $@ $< + +test-inline-assembly.s: test-inline-assembly.c + $(CC) -Wall -S -o $@ $< diff --git a/test-inline-assembly.c b/test-inline-assembly.c new file mode 100644 index 0000000..fe5a978 --- /dev/null +++ b/test-inline-assembly.c @@ -0,0 +1,13 @@ +#include + +int main() { + int i = 0xffff; + + asm("movl $23, %0" + : "=r" (i) /* output */ + /* : no input */ + /* : no clobbered */ + ); + + printf("i = %d\n", i); +}