Wednesday, June 29, 2011

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 

12 comments:

  1. valuable. I appreciate your service for the thousands of students

    ReplyDelete
    Replies
    1. Thanks for this inspiring comment, I have a lot more notes to publish but due to time complexity, I am failing, but I will.

      Delete
  2. Thank U very much for this explanation of handshaking
    actually my example is Blood Pressure communicate through Temperature device

    many thanks ^^

    ReplyDelete
  3. do you mind if u PLZ check my hand shaking pseudo-code??
    uploaded here :
    http://www.4shared.com/file/tX0M79AU/hand_shaking.html

    ReplyDelete
    Replies
    1. Sorry I missed your comment and came back after a long time.

      And also sorry as this is not what I practice now a days, these were my class notes which I made 3-4 years ago while studying CSE. I can't step ahead with checking your pseudo-code.

      Delete
  4. im goin to get a straight A with such a wonderful explanation .thank

    ReplyDelete

Leave your valuable thoughts before leaving..