Sat, 29 Oct 2011, 19:35
A student who wants to probe I/O registers more deeply sent me the following email. Only read it if you have time on your hands. If you are busy working the problems or otherwise preparing for the midterm, save this for after the midterm or whenever (or, if ever) you want to read it. > Hi Dr. Patt > > In our TA session on Friday, the TA was going over the data path with us. I > asked him a hypothetical question - what would happen if I tried to store > a value into the KBDR? Answer: The corresponding key on the keyboard would start to wiggle. > Take this short little program: > > .ORIG x3000 > LD R0, ASCIIA > STI R0, KBDR > HALT > ASCIIA .FILL x41 > KBDR .FILL xFE02 > .END > > In the data path, there is literally no wire going *into *KBDR. When I > asked the TA what would happen when I ran this code, he said he didn't > know. So I turn to you - what would happen if I tried to run this program > in an actual physical LC3? The real answer is it would do whatever the microarchitect who designed it specified. There are lots of things that one could write code to do that violate the specification of the machine. ...like writing into an input device. Makes no sense. In those cases, the microarchitect can design the computer to do whatever he/she want it to do. My guess is that 90% of microarchitects would implement it as a no-op. That is, the x41 would be written to the wind, and the program would move on. Another reasonable possibility would be to cause the computer to interrupt the program and execute an operating system routine that would deal with the situation. We have a name for such interruptions. We call them exceptions. But the concept is well beyond what I expect you to get out of EE306. That would be the choice I think of 90% of the remaining 10%. > When I ran the code in the simulator, it put > the value x41 into memory location xFE02. However, this obviously wouldn't > actually happen because 1) xFE02 isn't a memory location, it's a data > register and 2) in the data path, there is literally no wire going > *into *KBDR. > So what would actually happen in a real LC3 (or what would happen if the > simulator was perfect)? > > Thanks, > <<name withheld to protect the student who doesn't have enough work to do>> I am disappointed that the simmulator stores x41 into xFE02. The Simulator should have a test on a Store instruction to be sure it is not writing to an input device. One more thing to fix on the next version of the Simulator. Yale Patt ps. I was just kidding about the key on the keyboard wiggling. :-)