There are three keys in the KIM Uno that are not used in the Enigma Z30 program. Those keys are [GO], [A] and [B]. The program has a built in expansion capability. If those keys are pressed, control branches to three vectors, KPUSHA, KPUSHB and KPUSHG. Those addresses contain a jump back to start, but it can be replaced with a jump anywhere. Eventually, control must be restored to the main loop for program execution to continue.
This is the relevand portion of the original code.
CMP #$0A BEQ KPUSHA CMP #$0B BEQ KPUSHB CMP #$13 BEQ KPUSHG JSR MOVROT JMP START ... KPUSHA JMP START KPUSHB JMP START KPUSHG JMP START
We are going to add the functionality to zeroise the encryption keys by resetting them to the default values at the push of a key. This functionality is useful in case an adversary barges into the encryption room, at the push of a key, the current encryption key is destroyed.
When the Z30 program initially starts executing, it checks memory address 0050 for the value 0. If it finds this memory is not initialized, it copies the default encryption key from address DEFVAL in program memory to this RAM address. If we skip the check for 0 and jump to the part of the routine that does the copy, we have effectively implemented a zeroise function. Best of all, we are only changing existing bytes, no code has been added.
And this is the changed code. A couple of lines were changed to use variable TMP01 to allow the timeout routine to clear the last encoded key automatically after [GO] is pushed. The added label adds no code.
INIT CLD LDA #$0 CMP *ENIGVA BNE INITOK ZEROIZ ;REM_ADD_THIS_LABEL LDA #$0B STA *TMP01 ;REM_CHANGE_TO_TMP01 LDX #$0 CPYINI LDA DEFVAL,X STA *ENIGVA,X INX DEC *TMP01 ;REM_CHANGE_TO_TMP01 BNE CPYINI INITOK START ... CMP #$0A BEQ KPUSHA CMP #$0B BEQ KPUSHB CMP #$13 BEQ KPUSHG JSR MOVROT JMP START ... KPUSHA JMP START KPUSHB JMP START KPUSHG JMP ZEROIZ ;REM_CHANGE_TO_ZEROIZ
Test your new functionality by executing the program and changing the rotors with the up/down keys. Then press the [GO] button. The display will return to 4321. Change the rotors again and press a key to encrypt it. While the input and output key are still shown on the right and before they are cleared back to 00, press the [GO] button. They rotors will return to 4321, the last input and output key are still shown, but will be cleared soon by the TIMEOUT routine.