Thank you very much, all of you.
First of all, after kindda bugling with the thing I decided to drop that stupid design
) and make my own
.
Due to the fact that this is a *very* simple CPU (I'm willing to end up writing a serious emulator, but I want to start small and go on later...2 weeks 'till holidays for me so I have a summer at disposal), all the instructions would fit in a nibble so it's no big deal.
Actually, since they would fit in a nibble (4 bits), I'd have room for 16 instruction => 15 "normal" instructions and 1 for halt (1111).
So we'd have the command like: [nibble][arg1][arg2][arg3] - which would be quite OK - some instructions may get 3 arguments (e.g. add r1 r2 r3 - r3 = r1+r2...though that's kindda obfuscated).
So we'd also have a nibble for each argument, that lets me have 16 registers as well.
Intstruction which imply memory would have an 8-bit argument which is the address. Which means that I'd get 256 memory locations, say, 16 bit each => (2^8 * 2 ^ 4) / 2*3 = 2^9 = 512 bytes of program memory. Which is okay (p.s. I know Z80 programming so I can keep them small...besides there's no big deal of a program you could do with this CPU).
The only (slight) problem would be the different size of the arguments, but I could easily fix that with the function that decodes the instruction (I'll immediately show you how).
Now, the idea is that I want something quite realistic though (sure, I'm not going for a full-fledged RISC CPU
so I can change things a bit
). The program memory would be a multi-dimensional array, say:
program(256,4). It would go like this:
program(i,0) - store the instruction
program(i,1) - store arg1
program(i,2) - store arg2
program(i,3) - store arg3
They will be all strings
'cause I'm not willing to get overcomplicated right now, no big deal about it though, may change this later.
If an argument is a memory location, arg1 (a register) remains the same, and then I just concatenate arg2 and arg3. Of course they would be binary, so after I make that an integer I'd also have to turn into decimal so that I can address that memory location, but that's easy to do as well. So far, it's okay I guess.
I plan to have two memory arrays anyway - one to store the program, one to store the data (e.g. output of the memory), that's how it's done on modern CPUs anyway.
Maybe I'll do a very basic output to LEDs
, that's shouldn't be hard to implement, no big deal really.
Hmm....I don't have very much time these days since school is coming to an end and I have a few marks to fix
) but I won't abandon everything, work will progress quite slowly though (I only used DARK Basic for a two or three weeks and done only some small, itty-bitty games, so my knowledge of the language is not complete). Thank you very much again, and I promise to keep you informed on this.
~There are alternatives to fighting~