From 11e89c8c97769f984a305f096622045d16b08f6d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 15 Jan 2022 16:07:11 +0900 Subject: [PATCH] [gamecode] Add tests for lea --- libs/gamecode/test/Makemodule.am | 6 +++++ libs/gamecode/test/test-lea.c | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 libs/gamecode/test/test-lea.c diff --git a/libs/gamecode/test/Makemodule.am b/libs/gamecode/test/Makemodule.am index cdc0824a6..364ebfea6 100644 --- a/libs/gamecode/test/Makemodule.am +++ b/libs/gamecode/test/Makemodule.am @@ -11,6 +11,7 @@ libs_gamecode_tests = \ libs/gamecode/test/test-double \ libs/gamecode/test/test-float \ libs/gamecode/test/test-int \ + libs/gamecode/test/test-lea \ libs/gamecode/test/test-load \ libs/gamecode/test/test-long \ libs/gamecode/test/test-mem \ @@ -91,6 +92,11 @@ libs_gamecode_test_test_int_SOURCES= \ libs_gamecode_test_test_int_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_int_DEPENDENCIES= $(test_gamecode_libs) +libs_gamecode_test_test_lea_SOURCES= \ + libs/gamecode/test/test-lea.c +libs_gamecode_test_test_lea_LDADD= $(test_gamecode_libs) +libs_gamecode_test_test_lea_DEPENDENCIES= $(test_gamecode_libs) + libs_gamecode_test_test_load_SOURCES= \ libs/gamecode/test/test-load.c libs_gamecode_test_test_load_LDADD= $(test_gamecode_libs) diff --git a/libs/gamecode/test/test-lea.c b/libs/gamecode/test/test-lea.c new file mode 100644 index 000000000..36de277ff --- /dev/null +++ b/libs/gamecode/test/test-lea.c @@ -0,0 +1,41 @@ +#include "head.c" + +static pr_int_t lea_globals_init[] = { + // pointers + 24, 26, 28, 29, + 32, -4, -2, 0, + 1, 4, 0xdeadbeef, 0xfeedf00d, + + 0, 0, 0, 0, 0, +}; + +static pr_int_t lea_globals_expect[] = { + // pointers + 24, 26, 28, 29, + 32, -4, -2, 0, + 1, 4, 0xdeadbeef, 0xfeedf00d, + + 7, 29, 34, 26, 88, +}; + +static dstatement_t lea_statements[] = { + {OP(0, 0, 0, OP_LEA_A), 7, 9, 12}, + {OP(0, 0, 0, OP_LEA_B), 3, 8, 13}, + {OP(0, 0, 0, OP_LEA_C), 2, 6, 14}, + {OP(0, 0, 0, OP_LEA_D), 2, 6, 15}, + {OP(0, 0, 0, OP_LEA_E), 4, 2, 16}, +}; + +test_t tests[] = { + { + .desc = "lea", + .num_globals = num_globals (lea_globals_init, lea_globals_expect), + .num_statements = num_statements (lea_statements), + .statements = lea_statements, + .init_globals = lea_globals_init, + .expect_globals = lea_globals_expect, + .edict_area = 28, + }, +}; + +#include "main.c"