First of all hi to all, and sorry if the question is not for this forum but for beginners ( i didn't know what to choose ).
I implement a virtual machine ( or something like that it's an exercise ) and when i load the instructions from an array to simulator's memory ( which is 2048 length memory of 32-bits wide, and i can refer to a memory cell as a word=4bytes not to bytes themselves => registers also are 32bit - of type int ) i encounter the folowing problem : If the program in array has an instruction like Datum.datum( "string" ) i have to enter the string "string" in memory ( of the simulator ). I thought a way of storing this into memory as an integer through a register. The algorithm is this: if val is an integer then i do a val = (int)ch1 << 24 | (int) ch2 << 16 | (int) ch3 << 8 | (int) ch4; where ch is everytime taken by the string starting from the first symbol. Ok i take a number and i can store it in an int variable ( => register) and the contents of the register in the memory cell which is 32 bits wide and contains the bit pattern of the first 4 chars of the string and actually continue this way until i reach the end of the string and then add a null char as delimiter. But i cannot inverse the procedure to take from a memory cell the string. Any ideas? Maybe the whole concept is bad?