Question: Write an assembly language program that identifies the class of IPv 4 addresses. It should start by reading from the keyboard a number of addresses

Write an assembly language program that identifies the class of IPv4 addresses. It should start by reading from the keyboard a number of addresses N (between 1 and 10) to be checked and the IPv4 of those N addresses. The IPv4 format, known as dotted quad or dotted decimal, is x.x.x.x, where each x can be any value between 0 and 255. Hence the IPv4 address must be between 0.0.0.0 and 255.255.255.255. Every valid IPv4 address should be translated into 32-bit integer that can be expressed in binary or hexadecimal notation, as illustrated in the following Figure.
Dot-decimal notation: 172.16.254.1
numbering Binary : 10101100.00010000.11111110.00000001
Octet's orde : 1st 2ed 3ed 4th
32-bit (4 byte)
Figure: Decomposition of the quad-dotted IPv4 address representation to its binary value [1]
The program must then display a list containing for each address: the class (A, B, C, D, or E) and the IPv4 address
as shown in the sample run. The class is determined according to the following table:
Class / Address range/ Address Octet Binary (range)
A /0.0.0.0 to 127.255.255.255/0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
B /128.0.0.0 to 191.255.255.255/1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
C /192.0.0.0 to 223.255.255.255/11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
D /224.0.0.0 to 239.255.255.255/111xxxxx xxxxxxxx xxxxxxxx xxxxxxxx
E /240.0.0.0 to 255.255.255.255/1111xxxx xxxxxxxx xxxxxxxx xxxxxxxx
Your program must define and use the following procedures:
Procedure Read_Input: This procedure reads the value of N address, and IPv4 of N addresses. If the user enters an invalid (out of range) value (for N) then it displays the error message Error, number is out of range. Try again! and allows the user to enter the value again and again until the entered value is valid. If the user enters an invalid value (for an IPv4 address) then it displays the error message Error, IPv4 address is not formatted correctly. Try again! and allows the user to enter the value again and again until the entered value is valid. This procedure makes use of the procedure Check_Int (which checks if a value is out of range) and
procedure Check_IPv4(which checks if a value is not formatted correctly).
Procedure Check_Int: This procedure takes as input parameters an integer value in EAX, a minimum value in EBX and a maximum value in ECX. If the value of EAX is between the values of EBX and ECX, this procedure returns in BL the value 1. Otherwise, it displays the error message Error, value out of range. Try again! and returns in BL the value 0.
Procedure Check_IPv4: This procedure takes as input parameters a string in buffer (as entered from keyboard), and its length in byteCount. If the value of buffer is formatted as per the IPv4 addressing standard (i.e.4 octets separated with dot . and each octet is between 0 and 255), this procedure returns in BL the value 1. Otherwise, it displays the error message Error, IPv4 address is not formatted correctly. Try again! and returns in BL the value 0.
Procedure char2int: This procedure takes as input parameters an ASCII character of a digit between 0and 9 in BL, and add its converted decimal value to EAX. If the addition procedure did not overflow, this procedure returns in BL the value 1. Otherwise, it returns in BL the value 0.
Procedure Print_IPv4Class: Displays the classes of the IPv4 addresses, by listing the addresses and their classes in the format shown in the sample run. It makes use of the procedure Find_Class defined below. It should print the IPv4 address with dotted decimal formatting.
Procedure Find_Class: This procedure takes as input parameter in EAX an IPv4 address and returns in EDX the offset of one of the following strings A,B,C,D, or E, based on the range of the given IPv4 address according to the above table.
Sample Run:
>>>>>> IPv4 Address Classes Calculator <<<<<<<
Enter the number of IPv4 Address (between 1 and 10): -1
Error, number is out of range. Try again!
Enter the number of IPv4 Address (between 1 and 10): 11
Error, number is out of range. Try again!
Enter the number of IPv4 Address (between 1 and 10): 6
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 127.255.255.255.
Error, IPv4 address is not formatted correctly. Try again!
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 127.255.255.256
Error, IPv4 address is not formatted correctly. Try again!
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 127.255.255.255
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 191.255.255.255
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 223.255.255.255
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 239.255.255.255
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 240.255.255.255
Enter the IPv4 Address (xxx.xxx.xxx.xxx): 00189.234.23.32
IP Class IPv4 Address
--------------------------------
A 127.255.255.255
B 191.255.255.255
C 223.255.255.255
D 239.255.255.255
E 240.255.255.255
B 189.234.23.32
Write the program in assembly language and write all implementation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!