Converting individual pieces of assembly to machine code : <p>I am trying to convert assembly to machine code. I have a MINGW compiler where if i type ./convert.exe mov %a  then it should output  0x01 0xc0. I am thinking of using a struct listing each assembly code with its corresponding machine value. At the moment i keep getting errors like "request for member opcode in something not a structure". Any help would be appreciated.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

struct _Instruction {
char mnemonic[10];
unsigned char opcode;} typedef Instruction;

Instruction instruction_list[] = {
{"mov", 0x01},
{"add", 0x04},
{"sub", 0x05},
{"mul",0x06},
{"div", 0x07},
{"and",0x08},
{"or",0x09},
{"xor",0x0a},
{"cmp",0x0b},
{"",-1},
};

Instruction get_inst(char mnemonic[]);

int main2(int argc, char *argv[])
{

char* instruction = argv[1];
Instruction get_inst = get_Instruction(instruction);

printf("%s  ;  %s",instruction_list.mnemonic,instruction_list.opcode);
return 0;
}

Instruction get_inst(char mnemonic[])
{
int i;

for(i=0; instruction_list[i].opcode != -1; i++)
{
  if(!strcmp(instruction_list[i].mnemonic, mnemonic))
  {
    return instruction_list[i];
  }
}
return instruction_list[i]; 
}
</code></pre>
