The Cursor Y Position on CR

If the next byte to display is CR, then cursor y position is incremented by 1. More formally,

if the following are true:
  • value of cell 27 at time t = 1
  • value of cell (10 + (number of characters read at t)) at time t = 13
  • cursor y at time t < 11

then cursor y at time (t + 1) = (cursor y at time t) + 1

When we press the "Enter" key, We want the display to move to the beginning of the next line. When we press the "Enter" key, the keyboard sets memory cell #8 to 13, which is the "carriage return" or "CR." When the display sees 13 in memory, it will increment cursor y by 1 as long as cursor y is not yet on the last line.

For example, suppose the following are true:

  • value of cell 27 at time 71 = 1
  • number of characters read at 71 = 0
  • value of cell 10 at time 71 = 13
  • cursor y at time 71 = 0

Since the display hasn't read any characters yet, the next cell to read from is 10 + 0, or 10. And the value of cell #10 is 13. Also, the cursor y value is 0, which is less than 11. Thus, we conclude that:

cursor y at time (71 + 1) = (cursor y at time 71) + 1

Which simplifes to:

cursor y at time 72 = 1

see here for the full proof.

Try running the simulator below and click on the "Enter" key to see the cursor y value increase.

Time: 0
LW Computer IO Simulator

Comments

Please log in to add comments