.equ    locat, 0x2000           ;Location for this program

;82C55 memory locations
.equ    port_a, 0x4000
.equ    port_b, 0x4001
.equ    port_c, 0x4002
.equ    port_abc_pgm, 0x4003

;for a more sophisticated example of how to manipulate the
;82C55 port pins, see:
;  http://www.ece.orst.edu/~paul/8051-goodies/82c55.txt

.equ	esc, 0x003E		;paulmon2's check for esc key

.org    locat
.db     0xA5,0xE5,0xE0,0xA5     ;signiture bytes
.db     35,255,0,0              ;id (35=prog)
.db     0,0,0,0                 ;prompt code vector
.db     0,0,0,0                 ;reserved
.db     0,0,0,0                 ;reserved
.db     0,0,0,0                 ;reserved
.db     0,0,0,0                 ;user defined
.db     255,255,255,255         ;length and checksum (255=unused)
.db     "Blink LEDs",0          ;max 31 characters, plus the zero
.org    locat+64                ;executable code begins here

startup:
	mov	dptr, #port_abc_pgm
	mov	a, #128
	movx	@dptr, a	;make all pins output
begin:
	mov	dptr, #table
loop:
	clr	a
	movc	a, @a+dptr	;get pattern to display
	acall	update
	inc	dptr
	lcall	esc
	jc	exit
	clr	a
	movc	a, @a+dptr	;get time to display this pattern
	jz	begin
	acall	delay
	inc	dptr
	sjmp	loop

exit:	ret

update:
	push	dph
	push	dpl
	mov	dptr, #port_c
	movx	@dptr, a
	pop	dpl
	pop	dph
	ret

delay:
	mov	r0, a
dly2:	mov	r1, #250
dly3:	nop
	nop
	djnz	r1, dly3
	djnz	r0, dly2
	ret



table:	.db	01111111b, 90
	.db	00111111b, 70
	.db	00011111b, 50
	.db	10001111b, 40
	.db	11000111b, 40
	.db	11100011b, 40
	.db	11110001b, 40
	.db	11111000b, 50
	.db	11111100b, 70
	.db	11111110b, 90
	.db	11111100b, 70
	.db	11111000b, 50
	.db	11110001b, 40
	.db	11100011b, 40
	.db	11000111b, 40
	.db	10001111b, 40
	.db	00011111b, 50
	.db	00111111b, 70
	.db	255,0


