;
;  Kill the Bit game by Dean McDaniel, May 15, 1975
;
;  Object: Kill the rotating bit. If you miss the lit bit, another
;	   bit turns on leaving two bits to destroy. Quickly 
;	   toggle the switch, don't leave the switch in the up
;	   position. Before starting, make sure all the switches
;	   are in the down position.	   
;
;  Modified by Mike Douglas, July 2019, to demonstrate the data path
;  of the address latch and incrementer/decrementer in the 8080, which
;  as a side effect, drives the address bus, and hence, the front panel
;  LEDs, during the execute cycle of several 16 bit instructions. In
;  this example, the SPHL (load SP from HL) is used to drive the MSB of
;  the address LEDs

	org	0

	lxi	h,0		;initialize counter
	lxi	d,8000h		;D=display bit, C=0
	lxi	b,0Eh		;higher value = faster

loop	xchg			;put pattern from D into H
	sphl			;display on MSB of address LEDs
	sphl
	sphl
	sphl
	xchg			;restore D and H

	dad	b		;increment timer
	jnc	loop		;loop until timer wraps
	
	in	0FFh		;input data from sense switches
	xra	d		;kill bits in D with switch
	rrc			;rotate display right one bit
	mov	d,a		;move data to display reg
	jmp	loop		;repeat sequence

	end
