7. To write a program to initiate 8251 and to check the transmission and reception of character.

 ORG 0000h  ; Starting address of the program


; Set up the 8251

LXI D, 8000h  ; Load the control word for 8251 into DE (mode 1, 8-bit character length, 1 stop bit, no parity)

MOV A, D      ; Move the control word from DE to A

OUT 80h      ; Send the control word to the 8251


; Transmit a character

MOV A, 'A'    ; Load the character to be transmitted into A

OUT 81h      ; Send the character to the 8251 for transmission

WAIT_FOR_TX:

IN 80h       ; Read the status register of the 8251

ANI 02h      ; Mask the TXRDY bit (bit 1)

JZ WAIT_FOR_TX ; Wait for TXRDY bit to be set


; Receive a character

WAIT_FOR_RX:

IN 80h       ; Read the status register of the 8251

ANI 01h      ; Mask the RXRDY bit (bit 0)

JZ WAIT_FOR_RX ; Wait for RXRDY bit to be set

IN 82h       ; Read the received character from the 8251 into A


HLT          ; End of the program