Thnq Set the 8251A in asynchronous mode as a transmitter and
Thnq
Set the 8251A in asynchronous mode as a transmitter and receiver with even parity enabled, 2 stop bits, 8-bit character length, frequency 160 kHz and rate 10K. Write an ALP to receive 100 bytes of data string and store it at 3000:4000H.Solution
Solution:
Asynchronous mode control word for transmitting 100 bytes of data
D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 1 1 1 1 0=FEH
2STOP BITS Even parity 8bit CLK scaled
enabled format
An ALP to initialize 8251 and receive 100 bytes of data
ASSUME CS:CODE
CODE SEGMENT
START : MOV AX,3000H
MOV DS,AX ; Data segment set to 3000H
MOV SI,4000H ; Pointer to destination offset
MOV CL,64H ; Byte count in CL
MOV AL,7EH ; Only one stop bit for
OUT OFEH,AL ; receiver is set
MOV AL,14H ; Load command word to enable
OUT 0FEH,AL ; the receiver and disable transmitter
NXTBT : IN AL,OFEH ; Read status
AND AL,38H ; Check FE, OE and PE
JZ READY ; If zero, jump to READY
MOV AL,14H ; If not zero, clear them
OUT OFEH,AL
READY: IN AL,0FEH ; Check RXRDY, if receiver is not ready
AND AL,02H
JZ READY ; wait
IN AL,0FCH ; If it is ready,
MOV [SI],AL ; receive the character
INC SI ; Increment pointer to next byte
DEC CL ; Decrement counter
JNZ NXTBT ; Repeat, if CL is not zero
MOV AH,4CH
INT 21H
CODE ENDS
END START
