Hi guys and girls,

The title is a little off, but I didn't really know what to title it. Anyways, Im writing a virtual CPU program in C, and essentially I'm working on a function that opens an asm file, and then converts the operands to binary and saves it to a bcd file. Issue I'm having is, certain operands in the ASM file, I want to converted to specific binary. So as an example, if the operation NOP is read in the .asm file, convert it to 000000 (6bit opcode fields). The highest operand I have is 0x13h, or 010011b.

As of right now, Im thinking of using strtok() to break up the asm file, and then compare each line of text to my 20 operands, and then if equal, save as a new string equal to the binary, and then append that to my new bcd file. But that is seeming to be a little tricky and finicky. There has to be a better way to do this. Any help is appreciated!