Hello there Im trying to simulate machine code and have been given a set of codes
::text file contains::
B404
239A
2421
5345
350C
C000
Im trying to read in each hex number into an unsigned int array, what am i doing wrong?
Code:
#include <stdio.h>
int main() {
FILE *f;
unsigned int instr[80];
f=fopen("a3.txt","r");
while ( fscanf(f,"%x",instr) != EOF){
int i=0;
fscanf(f,"%x",&instr[i]);
i++;
}
printf("%x %x %x",instr[0],instr[1],instr[2]);
return 0;
}
from there onwards i need to extract 2bytes from one instruction and show output according to a set of Instructions.
for example:
1RXY - Load register r with value at memory address XY.
output would be somthing like this
PC INSTRUCTION - [R0 R1 R2 R3..etc..]
All i need to know is how to read each set of instruction into the array. How do i go about doing this?
-regards