

  
;SERIAL48.ASM
;BY CHRIS TARDIF
;   POB 1541        * THIS WILL ADD A SERIAL OUT PORT TO THE 8048  *
;   TUCSON AZ       * THIS IS FREE AND CLEAR TO THE PUBLIC DOMAIN  *
;    85702          * IF YOU FIND A BETTER WAY LET ME KNOW IF YOU  *
;                   * HAVE ANY GOOD ROUTINES YOU WISH TO SHARE OR  *
:   6-21-94         * NEED, CONTACT ME AT THIS ADDRESS.            *
   


;INT VECTORS
        ORG     00H
        JMP     RESET
        ORG     07H
        JMP     INTTIMR
        
        ORG     10H
INTTIMR:STOP    TCNT
        MOV     A,#08H
        MOV     R7,A
HERE:   DJNZ    R7,HERE         ;BAUDVAL FINE TUNE
        CLR     F1
        RETR

          ;START PROGRAM HERE
RESET:  CLR     F1
        EN      TCNTI
        
START:  IN      A,P1            ;INPUT DATA TO SEND
        CALL    SEND
        JMP     START
        
SEND:   CLR     F1
        MOV     R2,A
        MOV     R3,#09D         ;NOT INCLUDING STARTBIT
        ANL     P2,#0FEH        ;START BIT
        NOP
        CPL     F1
        MOV     A,#0FBH         ;BUADVAL FOR 1200 BAUD AT 3.579 MHz
        MOV     T,A
        STRT    T
        JMP     LASTBIT
        
        
NEXTBIT:MOV     A,#0FBH         ;BAUDVAL
        MOV     T,A
        STRT    T
        CPL     F1
        
LASTBIT:DJNZ    R3,TXMIT        ;IS THIS THE LAST BIT?
STOPBIT:JF1     STOPBIT         ;WAIT HERE FOR INTERUPT
        ORL     P2,#01H         ;BEGIN STOP BIT
        NOP                     ;NEEDED?
        CPL     F1
        MOV     A,#0FBH         ;BAUDVAL
        MOV     T,A
        STRT    T
        JF1     $               ;wait here 4 nxt int,end of stopbit
        STOP    TCNT
        CLR     F1
        JMP     START           ;start all over with a new byte
        
TXMIT:  MOV     A,R2
        RRC     A
        MOV     R2,A
        JC      OUT1
        
OUT0:   JF1     OUT0            ;wait here for interupt
        ANL     P2,#0FEH        ;put out a 0 bit
        JMP     NEXTBIT         ;and get ready for nextbit
        
OUT1:   JF1     OUT1            ;wait here for interupt
        ORL     P2,#01H         ;put out a 1 bit
        JMP     NEXTBIT         ;and get ready for next bit

END

