.org   000h
ljmp   start

.org   003h
ljmp   isr

.org   100h
start:
	lcall init
main:
	sjmp  main
	
init:
; Set up serial communication to the computer
	mov   tmod, #20h       ; set timer 1 for auto reload - mode 2   
    mov   tcon, #41h       ; run counter 1 and set edge trig ints
    mov   th1,  #0fdh      ; set 9600 baud with xtal=11.059mhz
    mov   scon, #50h       ; set serial control reg for 8 bit data
                           ; and mode 1
						  
	mov   IE,   #81h       ; Fully enable the edge triggered interrupt
	
	mov   dptr, #0xFE00    ; Set up PSoC UART flags for 9600 baud communication
	mov   a, #0x15
	movx  @dptr, a
	
	ret
	
isr:
	mov   dptr, #0xFE02    ; Read in the byte from the PSOC
	movx  a, @dptr
	
	mov   P1, a
	
	; Here I send the byte to the PC
	clr  scon.1            ; clear the tx  buffer full flag.
    mov  sbuf,a            ; put chr in sbuf
txloop:
    jnb  scon.1, txloop    ; wait till chr is sent
	
	mov   dptr, #0xFE00    ; Clear the PSoC UART flags thus clearing the external interrupt
	mov   a, #0x15
	movx  @dptr, a
	
	reti                   ; Return 
	