pdp10-opcodes: add pdp10_instruction_from_name() for the assembler

This commit is contained in:
Mikael Pettersson
2013-07-23 20:45:12 +00:00
parent fadd664dc7
commit d080f69cbc
2 changed files with 20 additions and 0 deletions

View File

@@ -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 */

View File

@@ -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 <string.h>
#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;
}