From c37555c141befeefa05293b2efd3eca18a7e41a3 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Mon, 10 Feb 1997 17:16:28 +0000 Subject: [PATCH] * tic80-opc.c (tic80_symbol_to_value): Changed to accept a symbol class that restricts translation to just that class (general register, condition code, etc). --- opcodes/ChangeLog | 6 ++++++ opcodes/tic80-opc.c | 32 +++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 771a9964bf5..3aa9b2d8756 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,4 +1,10 @@ start-sanitize-tic80 +Mon Feb 10 10:12:41 1997 Fred Fish + + * tic80-opc.c (tic80_symbol_to_value): Changed to accept + a symbol class that restricts translation to just that + class (general register, condition code, etc). + Thu Feb 6 17:34:09 1997 Fred Fish * tic80-opc.c (tic80_operands): Add REG_0_E, REG_22_E, diff --git a/opcodes/tic80-opc.c b/opcodes/tic80-opc.c index 25a03f3e4aa..cc27b87d218 100644 --- a/opcodes/tic80-opc.c +++ b/opcodes/tic80-opc.c @@ -202,16 +202,29 @@ const struct predefined_symbol tic80_predefined_symbols[] = const int tic80_num_predefined_symbols = sizeof (tic80_predefined_symbols) / sizeof (struct predefined_symbol); -/* This function takes a predefined symbol name in NAME and translates - it to a numeric value, which it returns. If no translation is - possible, it returns -1, a value not used by any predefined - symbol. Note that the predefined symbol array is presorted case - independently by name. */ +/* This function takes a predefined symbol name in NAME, symbol class + in CLASS, and translates it to a numeric value, which it returns. + + If CLASS is zero, any symbol that matches NAME is translated. If + CLASS is non-zero, then only a symbol that has class CLASS is + matched. + + If no translation is possible, it returns -1, a value not used by + any predefined symbol. Note that the predefined symbol array is + presorted case independently by name. + + This function is implemented with the assumption that there are no + duplicate names in the predefined symbol array, which happens to be + true at the moment. + + */ int -tic80_symbol_to_value (name) +tic80_symbol_to_value (name, class) char *name; + int class; { + const struct predefined_symbol *pdsp; int low = 0; int middle; int high = tic80_num_predefined_symbols - 1; @@ -232,7 +245,12 @@ tic80_symbol_to_value (name) } else { - rtnval = tic80_predefined_symbols[middle].value; + pdsp = &tic80_predefined_symbols[middle]; + if ((class == 0) || (class & pdsp -> value)) + { + rtnval = pdsp -> value; + } + /* For now we assume that there are no duplicate names */ break; } } -- 2.30.2