typing_test.tac (2034B)
1 # typing_test.tac - test program that reads from the keyboard component, echoes 2 # input and records the buffer in RAM. Once the user returns, 3 # it plays back the buffer. Handles backspaces and typing 4 # beyond the buffer limit. 5 # Uses the ExampleConfigurationROM circuit 6 ###################### Set up our buffer pointer to live in GRC 7 setup: li 32 8 mov GRA GRC 9 ###################### Set up our polling address 10 poll: sop_xor 11 li 252 12 sp GRA 13 ###################### Load the bitmask for available data 14 li 128 15 ###################### Poll until data is available 16 p_loop: lb GRB 17 cmp GRB GRA 18 jmp p_loop 19 ###################### Handle buffering the data and echo 20 ###################### Echo the byte 21 sb GRB 22 ###################### Clears the byte out of the buffer in the keyboard 23 sb GRA 24 ###################### Did we read a backspace character? If so, handle that 25 lli 8 26 cmp GRA GRB 27 jmp bcksp 28 ###################### Write the byte in the buffer in RAM 29 sp GRC 30 sb GRB 31 ###################### Increment the buffer pointer 32 cin GRC GRC 33 ###################### If we have reached the end of the buffer, restart 34 li 112 35 cmp GRA GRC 36 jmp setup 37 ###################### If the user pressed the enter key, output the buffer 38 lli 10 39 cmp GRB GRA 40 jmp output 41 jmp poll 42 ###################### Handle backspaces 43 bcksp: li 32 44 ###################### Are we at the start of the buffer? If so, we can return 45 cmp GRA GRC 46 jmp poll 47 ###################### Decrement the buffer pointer 48 lli 1 49 sop_sub 50 op GRC GRA GRC 51 jmp poll 52 ###################### Echo out all the things in the buffer to the TTY 53 output: li 32 54 o_loop: sp GRA 55 lb GRB 56 push 57 li 252 58 sp GRA 59 sb GRB 60 pop 61 cin GRA GRA 62 cmp GRA GRC 63 jmp setup 64 jmp o_loop