From 155577093a35012b93cae9b7be2c85970f5aee0e Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Tue, 6 Dec 2016 15:31:07 -0500 Subject: [PATCH] Add test for PC-style labels. These are labels which are given a numeric value. For example, the following code would generate PC labels 0 to 4: for (int i = 0; i < 5; i++) { |=>i: } --- dynasm/Examples/test_z_inst.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dynasm/Examples/test_z_inst.c b/dynasm/Examples/test_z_inst.c index ee005b5c..4633b6d8 100644 --- a/dynasm/Examples/test_z_inst.c +++ b/dynasm/Examples/test_z_inst.c @@ -202,6 +202,23 @@ static void save(dasm_State *state) | br r14 } +static void pc(dasm_State *state) { + dasm_State **Dst = &state; + int MAX = 10; + dasm_growpc(Dst, MAX+1); + + | j =>MAX + for (int i = 0; i <= MAX; i++) { + |=>i: + if (i == 0) { + | br r14 + } else { + | aghi r2, i + | j =>i-1 + } + } +} + typedef struct { int64_t arg1; int64_t arg2; @@ -222,7 +239,8 @@ test_table test[] = { { 2, 0, add_imm32, 16, "imm32"}, { 7, 3, save, 480, "save"}, { 7, 3, labmul, 21, "labmul0"}, - { 7, 0, labmul, 0, "labmul1"} + { 7, 0, labmul, 0, "labmul1"}, + { 0, 0, pc, 55, "pc"} }; static void *jitcode(dasm_State **state, size_t *size)