web analytics

What is handshaking? Write a suitable example for handshaking with necessary assembly codes.

Handshaking: 

Handshaking is a I/O control method to synchronize I/O devices with the microprocessor. As many I/O devices accepts or release information at a much slower rate than the microprocessor, this method is used to control the microprocessor to work with a I/O device at the I/O devices data transfer rate.

Example: 

Supposing that we have a printer connected to a system. The printer can print 100 characters/second, but the microprocessor can send much more information to the printer at the same time. That’s why, just when the printer gets it enough data to print it places a logic 1 signal at its Busy pin, indicating that it is busy in printing. The microprocessor now tests the busy bit to decide if the printer is busy or not. When the printer will become free it will change the busy bit and the microprocessor will again send enough amounts of data to be printed. This process of interrogating the printer is called handshaking.

Following is an assembly code that tests the BUSY Flag and sends data to the printer if it is not busy or the busy flag is a logic 0.

PRINT PROC NEAR

IN AL, BUSY ; get busy flag
TEST AL, BUSY_BIT ; test busy bit
JNE PRINT ; if printer busy
MOV AL, BL ; get data from BL
OUT PRINTER, AL ; send data to printer
RET

PRINT ENDP

Free PHP, HTML, CSS, JavaScript editor – CodeLobster IDE

Thank you. Take a moment to share 🙏