I need to simulate a computer with basic instruction set: Read, Write, Load, Store, Add, Subtract, Divide, Multiply and Branch.
I have no idea how i should set up my memory except that it can be an array. No idea how to set up the registers or interpret code supplied by a user using the above mnemonics to provide an executable program! Yes my simulation should be able to read a text file provided by someone coding with the stated instruction set.
Can anyone provide any assistance or guide lines? This is a 2nd year project at my university....
Posted on 2009-06-18 20:34:01 by Smiles
vote #1, just as clueless.  But I think that a good start would be to write subroutines with set arguments and just parse the text file and pass those variables to your internal subroutine.  Start with the easy instructions, then move on; just to get the creativity flowing.
Posted on 2009-06-18 21:20:48 by GoldStar611
Decode instructions, use jump-tables, do high-level execution of software-interrupts (that will provide BIOS and optionally DOS). .
Posted on 2009-06-19 13:36:55 by Ultrano
Here's an example of call-table (do ask such questions in the board, not PM :) )


handleValue_00 proc
ret
handleValue_00 endp

handleValue_01 proc
ret
handleValue_01 endp

handleValue_02 proc
ret
handleValue_02 endp

...
handleValue_FF proc
ret
handleValue_FF endp


CallTable1 dd handleValue_00,handleValue_01,handleValue_02, .... handleValue_FF




ExecuteBytes proc
  NextByte:
movzx eax, byte ptr
inc esi
call dword ptr CallTable1

cmp ShouldEmulatorExit,0
je NextByte

ret
ExecuteBytes endp


In some of those handleValue_xx procs, you will have to read more bytes from , depending on the instruction.
Posted on 2009-06-22 06:41:31 by Ultrano
Any suggestions on how I might implement my memory? I was thinking an array....
Posted on 2009-06-22 19:11:57 by Smiles
Of course an array :)
Posted on 2009-06-22 20:06:59 by Ultrano
Yup, definitely arrays FTW, man ^^
Posted on 2009-06-23 00:24:47 by ti_mo_n