I am looking for some advice on the best way to accomplish my task at hand. I am allowing a user to write a program of hex opcodes that represent 14 assembly-like functions. I need to “error check” my user’s program to make sure the program they enter contains only opcodes that are part of my 14 opcode list. Can someone please advice me as to what the best practice is for accomplishing a task like this?
Thank you!
Depending on the format of the “programs” your users are writing, there’s a lot of different ways to parse the program and determine the opcodes. Assuming that you just have a list of opcodes from their program (i.e.: a list of strings, each representing one opcode), you could quickly verify each opcode for validity with:
If you actually need to validate the syntax of each program, you could look into implementing a parser.