diff --git a/include/pdp10-opcodes.h b/include/pdp10-opcodes.h index b51b8b8..3be61de 100644 --- a/include/pdp10-opcodes.h +++ b/include/pdp10-opcodes.h @@ -132,4 +132,6 @@ extern const unsigned int pdp10_num_extended_instructions; const struct pdp10_instruction *pdp10_instruction_from_high13(unsigned int high13); +const struct pdp10_instruction *pdp10_instruction_from_name(const char *name); + #endif /* PDP10_OPCODES_H */ diff --git a/lib/pdp10-opcodes.c b/lib/pdp10-opcodes.c index 76128b2..fd37c27 100644 --- a/lib/pdp10-opcodes.c +++ b/lib/pdp10-opcodes.c @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "pdp10-opcodes.h" /* @@ -983,3 +984,20 @@ const struct pdp10_instruction *pdp10_instruction_from_high13(unsigned int high1 return (void*)0; } + +const struct pdp10_instruction *pdp10_instruction_from_name(const char *name) +{ + unsigned int i; + + for (i = 0; i < pdp10_num_aliases; ++i) + if (strcmp(name, pdp10_alias[i].name) == 0) + return &pdp10_alias[i]; + + for (i = 0; i < pdp10_num_instructions; ++i) + if (strcmp(name, pdp10_instruction[i].name) == 0) + return &pdp10_instruction[i]; + + /* XXX: extended opcodes? */ + + return (void*)0; +}