Update to the KIM-1 Simulator

Nils, a very enthousiast PAL-1 user discovered in an old German magazine, 1979, HobbyComputer 1, a small phonebook program for the KIM-1.
It is a command line utility, extremely small and quite clever. See the post about it here.

So he entered the code in assembler and did some tests on his PAL-1 (it worked) and in the KIM-1 Simulator, which was not working.
He found the ‘database’ corrupted.

Of course I had to look at it and see what was going on. It had to be something about using zeropage pointers into the database.
And it was. In the source an instruction appeared:

INY  ; Y = 0

followed by an indirect addressing, Y into the database and preceded by a call to getch, reading a character from the keyboard.
Y was not used in the program before, so in the Simulator it was uncertain what the value was.

GETCH is known to destroy the Y register, delivering the character in register A. How is unspecified.
In the KIM-1 Simulator the KIM-1 GETCH is patched to the ACIA routines of the emulated 6850 serial interface.
Those routines do not use Y, so it is left untouched.

So time to study the KIM-1 routines. In the delay a bit routine the Y register is filled with the final state of a counter, TIMH.
It looks like the decrement ends with the value $FF, when the BPL becomes false, the whole purpose of the use of Y seems to determine that end of the loop?

 1ED4  AD F3 17  DELAY   LDA   CNTH30                           
 1ED7  8D F4 17          STA   TIMH
 1EDA  AD F2 17          LDA   CNTL30
 1EDD  38        DE2     SEC   
 1EDE  E9 01     DE4     SBC   #$01 
 1EE0  B0 03             BCS   DE3  
 1EE2  CE F4 17          DEC   TIMH
 1EE5  AC F4 17  DE3     LDY   TIMH
 1EE8  10 F3             BPL   DE2
 1EEA  60                RTS

Anyway, the KIM-1 Simulator 0.9.4. GETCH routine now returns with Y=$FF and the phonebook program seems to work.