I am new to C, and till now have only done python (a years worth at university), and am finding myself running into walls whenever i try to do seemingly simply stuff. One of the main issues in comparison is the lack of a interpreter and Ch is only of limited help. I figured that here at least i could get an idea of why im getting nowhere. Please excuse my long-windedness.
I have been tasked with creating a limited mips simulator in c that will take in >31 8 bit hex numbers (31 initial register values with $0=0 and some instructions) e.g. 00000000 000FF000 00... by reading them as input from another file (i am refering to calc.c < input_numbers), then perform the instructions input and print out the resulting register values. We are only tasked with performing 5 operations addu/subu (all unsigned) and the like and can ignore any others. We have also been advised to make use of uint32_t.
I have beat my head against the wall long enough to come up with a way to read in and then print out the values input using scanf and
a while loop utilizing getchar/EOF and scanf==1. I don't want to be more specific as i doubt my lecturer would want me to go into details on a public forum.
So now that i have the hex numbers read in (i used two arrays, one for the register initial values and another for instructions), how do i go about converting them to binary so that i can then (somehow, i am guessing by using bit masks to cut them down and if statements to match to the addu/subu/) play with them (verification would be nice btw...!) ?
I have a number like 00FF00FF stored in register. I want to convert it to register2 = 00000000111111110000000011111111 Using a for loop to iterate over all the elements in the array, i then assign it to a temp variable and WHAT? The lack of the python "for i in string" is painful! I have tried looking at binary/decimal/hex converters here and elsewhere but to no avail. I feel there should be some sort of simple solution - am i overlooking something obvious?
Thanks in advance - and i hope i conveyed that i have been trying to solve it myself, i normally don't have to resort to (posting on) forums.