Is it ok to do whatever we want with invalid memory address inputs?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is it ok to do whatever we want with invalid memory address inputs?

chris1255
There seem to be less and less threads as the course goes on. However, I did find this one (http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Memory-Mapped-I-O-Misunderstanding-td2744686.html), in which Mark states:


For the HACK computer, memory addresses
0..16K-1 read and write from the RAM16K chip,
16K..24K-1 read and write from Screen chip addresses 0..8K-1, respectively,
24K reads from the Keyboard chip.
24K+1..
64K-1 undefined what will happen (I.e., "don't try this at home, kids!")

Coming from C++, the 24K+ part being undefined is very familiar to me. Currently, my memory chip passes the test, but to make the decision of which chip to pass the inputs to, assumes that the Keyboard chip is 8K in length.

In other words, an address from 0-16K will cause the inputs to be delegated to the RAM16K chip, an address of 16K-24K will cause the inputs to be delegated to the Screen chip, and an address of 24K-32K will cause interaction with the Keyboard chip. I don't mention 32K-64K because the address input is 15 bits wide.

Is it ok to take "undefined" to mean that if an invalid address is passed in, it's the passer's fault and the chip can do as it pleases, including causing all 8K memory addresses past the starting range of the Keyboard chip to act as if the address was the Keyboard chip's single address (e.g. passing in 28967 would act as if 24576 was passed in)?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it ok to do whatever we want with invalid memory address inputs?

cadet1620
Administrator
chris1255 wrote
Is it ok to take "undefined" to mean that if an invalid address is passed in, it's the passer's fault and the chip can do as it pleases, including causing all 8K memory addresses past the starting range of the Keyboard chip to act as if the address was the Keyboard chip's single address (e.g. passing in 28967 would act as if 24576 was passed in)?
Yes, it's quite common to simplify hardware based on the limited range of legal inputs. My Memory works as yours does; Any address that isn't RAM or Screen reads the Keyboard.

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it ok to do whatever we want with invalid memory address inputs?

chris1255
Thank you for the clarification and quick reply :)
Loading...