
INICIO_TABLA EQU 040H
FIN_TABLA    EQU 0FFH

        .ORG 0H                 ;locate routine at 00H
        AJMP START              ;jump to START
        .ORG 03H                ;external interrupt 0
        RETI
        .ORG 0BH                ;timer 0 interrupt
        RETI
        .ORG 13H                ;external interrupt 1
        RETI
        .ORG 1BH                ;timer 1 interrupt
        RETI
        .ORG 23H                ;serial port interrupt
        RETI
        .ORG 25H                ;locate beginning of rest of program

SEND:   MOV SBUF, A             ;Transmit Byte
WAIT:   JNB TI, WAIT            ;Wait for transmission to be completed.
        CLR TI                  ;Clear Transmit Flag
        RET

START:  ;Main program (on power up, program jumps to this point)
        ;Set up control registers
        MOV PCON, #080H         ;to double baud rate
        MOV TH1,  #0FDH         ;Set up for 9600 baud rate
        MOV SCON, #01010000B    ;Mode = 8 bit UART
        MOV TMOD, #00100001B    ;Sets Timer1 to 8 bit auto reload
        MOV TCON, #01000000B    ;Turns Timer1 on
        MOV R0,#INICIO_TABLA

LOOP:   MOV A,@R0               ;Move Value in R0 to A (to be sent)
        CALL SEND               ;Send Value to PC
        INC R0                  ;Increase the 8 bit value of R0 by 1
        MOV A,R0
        CJNE A,#FIN_TABLA,LOOP  ;Go to LOOP(jump back to point labeled LOOP)

        JMP $
        END
