changeset 619:3072fb746601

Added support for JR and JRcc in Z80 test generator
author Michael Pavone <pavone@retrodev.com>
date Mon, 29 Dec 2014 21:36:17 -0800
parents abc834e4a520
children 9d6fed6501ba
files ztestgen.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ztestgen.c	Mon Dec 29 21:24:12 2014 -0800
+++ b/ztestgen.c	Mon Dec 29 21:36:17 2014 -0800
@@ -289,7 +289,7 @@
 		reg_usage[inst->reg] = 1;
 	}
 	uint8_t counter_reg = Z80_UNUSED;
-	if (inst->op == Z80_JP || inst->op == Z80_JPCC) {
+	if (inst->op >= Z80_JP && inst->op <= Z80_JRCC) {
 		counter_reg = alloc_reg8(reg_usage, reg_values, 0);
 	}
 	puts("--------------");
@@ -366,6 +366,8 @@
 			uint16_t address = cur - prog + 3 + i; //2 for immed address, 1/2 for instruction(s) to skip
 			*(cur++) = address;
 			*(cur++) = address >> 8;
+		} else if(inst->op == Z80_JR || inst->op == Z80_JRCC) {
+			*(cur++) = 1 + i; //skip one or 2 instructions based on value of i
 		} else if (addr_mode == Z80_IMMED & inst->op != Z80_IM) {
 			*(cur++) = inst->immed & 0xFF;
 			if (word_sized) {
@@ -381,7 +383,7 @@
 		if (instlen == 3) {
 			*(cur++) = instbuf[2];
 		}
-		if (inst->op == Z80_JP || inst->op == Z80_JPCC) {
+		if (inst->op >= Z80_JP && inst->op <= Z80_JRCC) {
 			cur = inc_r(cur, counter_reg);
 			if (i) {
 				//inc twice on second iteration so we can differentiate the two
@@ -462,7 +464,7 @@
 
 uint8_t should_skip(z80inst * inst)
 {
-	return inst->op >= Z80_JR || (inst->op >= Z80_LDI && inst->op <= Z80_CPDR) || inst->op == Z80_HALT
+	return inst->op >= Z80_DJNZ || (inst->op >= Z80_LDI && inst->op <= Z80_CPDR) || inst->op == Z80_HALT
 		|| inst->op == Z80_DAA || inst->op == Z80_RLD || inst->op == Z80_RRD || inst->op == Z80_NOP
 		|| inst->op == Z80_DI || inst->op == Z80_EI;
 }