(Задание 02 курса Assembly Language)

Write a stand-alone assembly language program that emulates in a very crude way a receiver for a data packet which is being transmitted in serial form across a transmission line. The packet contains a bit string which can be parsed and decoded. Your program reads a stream of “bits” in the transmission simulated by a stream of ASCII character ‘0’s and ‘1’s which you must read with the GetCh Macro or using INT 21H. The most significant bits come first so that for example the first 8 bits is 00000010 for the STX character, as indicated below The bits should first be reconstituted into bytes and treated according to the “COMP 2003 transmission protocol” (CTP ) defined as follows. The first byte will be the ASCII “Start Of Text” character, STX or 02H. The next 3 bytes should be the ASCII characters for ‘C’ ‘T’ ‘P’. The next 32 bits or 4 bytes will consist of four 1 byte integers which is a crude IP (internet) address. Next follows an undetermined number of bytes of text. Next follows an “End of Text” character, ETX or 03H Next follows a checksum WORD which is an integer whose value is the number of ones in the data part of the transmission, i.e. the text only . Finally there is an EOT or “End of transmission” character or 04H.

You should structure your program as follows: The main procedure should first call a procedure called “sipo” (serial in parallel out) which receives 3 pointers on the stack which point to 1) an array called “address” which contains the 4 bytes of the address. (Note that the stack uses 2 byte items) 2) An array called “message” which contains the bytes of the message and 3) a word variable called “checksum” which contains the checksum. The procedure “sipo” reads the bits as they come in and places the appropriate data items into the appropriate locations, while discarding the transmission bytes with the ASCII charactersCTP, as well as the characters STX,ETX and EOT.

When “sipo” sees an ETX character it puts a NULL character at the end of the message. The main program then calls a procedure “checker” which receives a pointer to the message, both on the stack. It calculates the check sum and returns the checksum value in AX. The main program will then compare the two values for the check sum and if they are different prints out an error message: “Error in Transmission”. If they are the same it prints out the address and message in the following format: The IP address is The message is: “hello”

NOTE: This is the format for the output but not the output you expect from the data file provided. Further specifications: 1) The check sum byte contains the number of ones in the user text characters only . 2) NOTE: To avoid typing a long stream of ‘0’s and ‘1’s for each run, set up a file such as a2_data.txt and have the input directed from the file using the input redirect in DOS. e.g > myprog < datafile.txt NOTE: Your program should strictly follow the specifications given here. Also, make sure to submit enough evidence that indicates that you have thoroughly tested your program. This will require setting up a number of test files. For convenience make them short with only a few text characters. 3) Assume that all the control characters are correct order. Check only for the check sum.


This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

1 Response to Задание 2: CTP-протокол


» Описание курса Computer Science Student

Сентябрь 13th, 2009 at 10:04

[...] Задание 2: CTP-протокол [...]

Comment Form