		org #0000
		di
		ld a,#ff	; flash LEDs to show we're running...
		out (#f8),a
		ld a,0
		out (#f8),a
		ld sp,#400	; stack pointer to 1K
start		ld de,#8000	
		ld a,0
		ld b,#ff
loop		call prog_byte
		inc de
		inc a
		djnz loop
test		ld hl,#8000
		ld b,#ff	; 255 bytes to iterate through
		ld c,#f8	; address of our device
		otir		; spew onto our device
		halt		
		jp test

; prog_byte:
; A = byte to program
; DE = address to program

prog_byte	ld c,a		; save accumulator
		ld a,#aa	; command seq byte 1
		ld (#8555),a	; command seq addr 1
		ld a,#55	; command seq byte 2
		ld (#82AA),a	; command seq addr 2
		ld a,#A0	; write command byte
		ld (#8555),a	; send write command
		ld a,c		
		ld (de),a	; Program!
		ret

; Non maskable interrupt handler does nothing. But if we're halted,
; it'll restart 'test' again.
		defb "some pad out bytes 2 make NMI handler appear"

nmi		retn		; do nothing 
		nop
		nop
		nop

