; parity generation
; even parity = 1
; input: 4000H
;output: 4004H
ORG 0H
IN_ADDR EQU 4000H
OUT_ADDR EQU 4004H
MAIN:
MOV DPTR,#IN_ADDR ; fill memory
MOV A,#02H
MOVX @DPTR,A
LCALL PARITY
SJMP MAIN
PARITY:
MOV DPTR,#IN_ADDR
MOVX A,@DPTR
MOV R5,A
MOV R2,#00
MOV R3,#08
loop1 : RRC A
JNZ loop2
INC R2
loop2 : DJNZ R3,loop1
MOV A,R2
MOV B,#02
DIV AB
MOV A,B
JNZ loop3
MOV A,#01
MOV R7,#0FFH
SJMP loop4
loop3 : MOV A,#00
MOV R7,#00
loop4: MOV DPTR,#OUT_ADDR
MOVX @DPTR,A
MOV P1,R7
RET
END
Related topics:
8051 Program - parity generation | 8051 Program - polling an io pin | 8051 Program - port loopback | 8051 Program - send ascii to port | 8051 Program - serializing data | 8051 Program - simple serial transmission | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
No comments:
Post a Comment