about summary refs log tree commit diff stats
path: root/314divide.subx
blob: c0b855264201840ee81686b5f4bd00a42e797fab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
== code

integer-divide:  # a: int, b: int -> quotient/eax: int, remainder/edx: int
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # eax = a
    8b/-> *(ebp+8) 0/r32/eax
    # edx = all 0s or all 1s
    99/sign-extend-eax-into-edx
    # quotient, remainder = divide eax by b
    f7 7/subop/divide-eax-edx-by *(ebp+0xc)
$integer-divide:end:
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return
span> LIBS = -lm ### CFLAGS = -std=c99 CFLAGS += -g CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -pedantic CFLAGS += -Werror CFLAGS += -Wmissing-declarations CFLAGS += -DUNITY_SUPPORT_64 ASANFLAGS = -fsanitize=address ASANFLAGS += -fno-common ASANFLAGS += -fno-omit-frame-pointer .PHONY: test test: tests.out @./tests.out .PHONY: memcheck memcheck: test/*.c src/*.c src/*.h @echo Compiling $@ @$(CC) $(ASANFLAGS) $(CFLAGS) src/*.c test/vendor/unity.c test/*.c -o memcheck.out $(LIBS) @./memcheck.out @echo "Memory check passed" .PHONY: clean clean: rm -rf *.o *.out *.out.dSYM tests.out: test/*.c src/*.c src/*.h @echo Compiling $@ @$(CC) $(CFLAGS) src/*.c test/vendor/unity.c test/*.c -o tests.out $(LIBS)