How could direct memory access be implemented?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How could direct memory access be implemented?

Jikep
Hello,
using A instructions + a computation in two lines and that way accessing RAM locations allows the instruction to be 16-bits long, however, how would direct memory access be implemented?

Just wondering, would that just be a case of having longer instructions: the address + the computation part in one? Or some other possible implementation is possible?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: How could direct memory access be implemented?

cadet1620
Administrator
To include a memory address would require a longer instruction word. RISC computers generally do this with a fixed size instruction. For the Hack computer, that would mean all instructions would be 32-bits and programs would be twice as long.

Other computers, for example the x86 family use variable length instructions; their length depends upon addressing modes in the initial byte(s) of the instruction. Depending on the instruction, it can take multiple clock cycles to read the entire instruction.

One of the unused C-instruction bits could be used to mean "direct addressing" which would cause the CPU to read the address to be used from the following word. The instruction, therefore, would require two words of RAM and two clocks to execute.

This direct addressing instruction would not be much different than an an A-instruction, C-instruction sequence, except that it would not disrupt the A register.

It would be a lot of work to add this to the current CPU design.

(Very similar to direct addressing mode is immediate addressing mode, where the address field in the instruction is used as a data value. This would allow instructions like D=D+42. It would be almost free to add immediate mode when adding direct addressing.)

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: How could direct memory access be implemented?

Jikep
Thank you for such a quick and profound answer! What other features from a modern CPU, like caching, could be added within the realm of possibility?

Thank You!
Reply | Threaded
Open this post in threaded view
|

Re: How could direct memory access be implemented?

cadet1620
Administrator
Memory caching would not have any effect on the Hack Computer since its memory is the same speed as its CPU.

Things that you can look in to are

Add some missing operations like Xor and shifting.

A CPU with more registers:
    Ideas for a Slightly More Powerful CPU

Multiple-clock-cycle instructions and simple pipelining:
    Von Neumann single memory version of Hack

Add a math coprocessor
    A Math Coprocessor for the Hack Computer

--Mark