|
|
|
 |
|
|
|
|
Assembly Language is used in order to increase the execution speed of a program, to interact with the Hardware and to directly program the Hardware.
This section contains programs describing the Basic Programming Structure of Assembly Language. This section also contains the solutions of exercise programs of the book "Assembly Language Programming and the Organization of IBM PC's" by Ytha Yu & Charles Marut [ First 10 chapters only ].
Select one of the Topics listed below:
|
Note: All the given files are in zip format, which can be uncompressed with the help of a compression tool. If you do not have any tool, then you can get one from Utilities : Compression Tools. |
|
|
Input - Output Instructions |
|
|
|
|
|
|
| AL-001 |
 |
An Assembly Language Program to display a character. |
| AL-002 |
 |
An Assembly Language Program to read a character and display it on a new line. |
| AL-003 |
 |
An Assembly Language Program to to display a string. |
| AL-004 |
 |
An Assembly Language Program to read two digits whose sum is less than 0, computes and display their sum [ without using variables ]. |
| AL-005 |
 |
An Assembly Language Program to read two digits such that second digit is less than the first digit, computes and display their difference [ without using variables ]. |
| AL-006 |
 |
An Assembly Language Program to read two digits whose sum is less than 0, computes and display their sum [ using variables ]. |
| AL-007 |
 |
An Assembly Language Program to read two digits such that second digit is less than the first digit, computes and display their difference [ using Variables ]. |
| AL-008 |
 |
An Assembly Language Program to read a letter in lower case and print it after converting it in to Upper case. |
| AL-009 |
 |
An Assembly Language Program to read a character and display it on new line with user prompts initialized by constants. |
| AL-010 |
 |
An Assembly Language Program that (a) prompt the user, (b) read first, middle, and last initials of a person's name, (c) display them down the left margin. |
| AL-011 |
 |
An Assembly Language Program to read one of the hex digits A-F, and display it on the next line in decimal. |
| AL-012 |
 |
An Assembly Language Program to display a 10*10 solid box of asterisks with INT 21H and function 9H. |
| AL-013 |
 |
An Assembly Language Program to (a) display "?", (b) read three initials, (c) display them in the middle of an 11*11 box of asterisks, (d) beep the computer. |
|
|
|
|
|
Flow Control Instructions |
|
|
|
|
|
|
| AL-014 |
 |
An Assembly Language Program to print all the ASCII characters. |
| AL-015 |
 |
An Assembly Language Program to print counting from 0 to 9. |
| AL-016 |
 |
An Assembly Language Program to print Upper Case Letters from A to Z. |
| AL-017 |
 |
An Assembly Language Program to print Lower Case Letters from a to z in reverse order. |
| AL-018 |
 |
An Assembly Language Program that reads a character and prints it only if it is '?' [ Simulation of If structure ]. |
| AL-019 |
 |
An Assembly Language Program that reads a two characters, compare them and prints the smallest character [ Simulation of If-Else structure ]. |
| AL-020 |
 |
An Assembly Language Program that reads a digit, computes and prints 'P' if it is positive, 'N' if it is negative and 'Z' if it is zero [ Simulation of switch-case statement ]. |
| AL-021 |
 |
An Assembly Language Program that reads a character and prints it only if it is a Upper Case Letter [ Simulation of If-Else then structure ]. |
| AL-022 |
 |
An Assembly Language Program that reads a character and prints it only if it is 'y' or 'Y' [ Simulation of If-Else then structure ]. |
| AL-023 |
 |
An Assembly Language Program to print all the ASCII characters i.e. 256 [ using for loop simulation ]. |
| AL-024 |
 |
An Assembly Language Program to print Upper Case Letters from A to Z [ Simulation of While Loop ]. |
| AL-025 |
 |
An Assembly Language Program to print Upper Case Letters from A to Z [ Simulation of Do-While Loop ]. |
| AL-026 |
 |
An Assembly Language Program to display a "?", read two capital letters, and display them on the next line in alphabetical order. |
| AL-027 |
 |
An Assembly Language Program that will prompt the user to enter a hex digit character [ "0"... "9" or "A"..."F" ], display it on the next line in decimal, and ask the user if he or she wants to do it again. If the user types "y" or "Y", the program repeats; if the user types anything else, the program terminates. If the user enters an illegal character, prompt the user to try again. |
| AL-028 |
 |
An Assembly Language Program that will prompt the user to enter a hex digit character [ "0"..."9" or "A"..."F" ], display it on the next line in decimal, and ask the user if he or she wants to do it again. If the user types "y" or "Y", the program repeats; if the user types anything else, the program terminates. If the user enters an illegal character, prompt the user to try again. If the user fails to enter a hex digit character in three tries, display a message and terminate the program. |
| AL-029 |
 |
An Assembly Language Program that prompts a user to enter a line of text. On the next line, display the capital letter entered that comes first alphabetically and the one that comes last. If no capital letters are entered, display "No Capital Letters". |
| AL-030 |
 |
An Assembly Language Program that reads a string of capital letters, ending with a carriage return, and display the longest sequence of consecutive alphabetically increasing capital letters read. |
|
|
|
|
|
Logic - Shift - Rotate Instructions |
|
|
|
|
|
|
| AL-031 |
 |
An Assembly Language Program to read a letter in Upper case and print it after converting it in to Lower case letter [ using OR Logic instruction ]. |
| AL-032 |
 |
An Assembly Language Program to read a letter in Lower case and print it after converting it in to Upper case letter [ using AND Logic instruction ]. |
| AL-033 |
 |
An Assembly Language Program that read a number from 0 to 9 and print E if it is even and print O if it is an odd number [ using TEST instruction ]. |
| AL-034 |
 |
An Assembly Language Program that multiply the contents of AL by 8 [ using SHL instruction ]. |
| AL-035 |
 |
An Assembly Language Program that divide the contents of AL by 4 [ using SHR instruction ]. |
| AL-036 |
 |
An Assembly Language Program that reads a binary number, stores it in BX, counts and display the number of 1 bits in BX without changing BX's contents. |
| AL-037 |
 |
An Assembly Language Program that reads a binary number, reverse its bit pattren and displays it on the next line. |
| AL-038 |
 |
An Assembly Language Program that reads a binary number, stores it in BX and display it. |
| AL-039 |
 |
An Assembly Language Program that prompts the user to enter a character, and on subsequent lines print its ASCII code in binary, and the number of 1 bits in its ASCII code. |
| AL-040 |
 |
An Assembly Language Program that prompts the user to enter a character, and prints the ASCII code of the character in hex on the next line. Repeat this process untill the user types a carriage return. |
| AL-041 |
 |
An Assembly Language Program that prompts the user to type a hex number of four hex digits or less, and outputs it in binary on the next line. If the user enters an illegal character, he or she should be prompted to begin again. Accept only upper case letters. The program may ignore input beyond four characters. |
| AL-042 |
 |
An Assembly Language Program that prompts the user to type a binary number of 16 digits or less, and outputs it in hex on the next line. If the user enters an illegal character, he or she should be prompted to begin again. The program may ignore input beyond 16 characters. |
| AL-043 |
 |
An Assembly Language Program that prompts the user to enter two binary numbers of up to 8 digits each, and print their sum on the next line in binary. If the user enters an illegal character, he or she should be prompted to begin again. Each input ends with a carriage return. |
| AL-044 |
 |
An Assembly Language Program that prompts the user to enter two unsigned hex numbers, 0 to FFFF, and print their sum on the next line. If the user enters an illegal character, he or she should be prompted to begin again. The program should be able to handle the possibility of unsigned overflow. Each input ends with a carriage return. |
| AL-045 |
 |
An Assembly Language Program that prompts the user to enter a string of decimal digits, ending with a carriage retuen, and prints their sum in hex on the next line. If the user enters an illegal character, he or she should be prompted to begin again. |
|
|
|
|
|
Stack - Procedures |
|
|
|
|
|
|
| AL-046 |
 |
An Assembly Language Program that reads a string of characters terminated by CR and display it in reverse order. |
| AL-047 |
 |
An Assembly Language Program to read a character and display it on next line using a procedure for goto next line. |
| AL-048 |
 |
An Assembly Language Program to (a) read a number in binary form, (b) display a number in binary form, (c) reverse the bit pattern of the number [ use procedures for each part ]. |
| AL-049 |
 |
An Assembly Language Program that read two numbers in binary form, computes and display their product by ADD and SHIFT instructions using procedures. |
| AL-050 |
 |
An Assembly Language Program that lets the user type some text, consisting of words separated by blanks, ending with a carriage return, and displays the text in the same word ordered as entered, but with the letters in each word reversed. |
| AL-051 |
 |
An Assembly Language Program that lets the user type in an algebric expression, ending with a carriage return, that contains round (parenthesis), square and curly brackets. As the expression is being typed in, the program evaluates each character. If at any point the expression is incorrectly bracketed [ too many right brackets or a mismatch between left and right brackets ], the program tells the user to start over. After the carriage return is typed, if the expression is correct, the program displays "expression is correct". If not, the programdisplays "too many left brackets". In both cases, the program ask the user if he or she wants to continue. If the user types 'Y', the program runs again. Your program does not need to store the input string, only check it for correctness. |
| AL-052 |
 |
An Assembly Language Program that displays a '?', calls READ to read a binary number, and calls RANDOM and WRITE to compute and display 100 random numbers. The numbers should be displayed four per line, with four blanks separating the numbers.
The following method can be used to generate random number in the range 1 to 32767.
- Start with any number in this range.
- Shift left once.
- Replace bit 0 by XOR of bits 14 and 15.
- Clear bit 15.
Write the following procedures :
a. A procedure READ that lets the user enter a binary number and stores it in AX.
b. A procedure RANDOM that recieves a number in AX and returns a random number in AX.
c. A procedure WRITE that displays AX in binary.
|
|
|
|
|
|
Multiplication - Division Instructions |
|
|
|
|
|
|
| AL-053 |
 |
An Assembly Language Program that will read a positive binary number and print its factorial in binary form using MUL instruction [ suppose that there is no overflow ]. |
| AL-054 |
 |
An Assembly Language Program that will read a binary number and print it on the next line in decimal form using DIV instruction. |
| AL-055 |
 |
An Assembly Language Program that will read a positive binary number and print its factorial in decimal form using MUL and DIV instructions [ suppose that there is no overflow ]. |
| AL-056 |
 |
An Assembly Language Program that will read a decimal number and print it on the next line using procedures for DECIMAL input and output. |
| AL-057 |
 |
An Assembly Language Program that will read a decimal number and print it on the next line using procedures INDEC and OUTDEC. The INDEC procedure should be able to handle the BackSpace key. |
| AL-058 |
 |
An Assembly Language Program that will read and print a decimal number using procedures INDEC and OUTDEC. Place the procedures in separate files and use the INCLUDE instruction. |
| AL-059 |
 |
An Assembly Language Program that will read a positive decimal number and print its factorial in decimal form using MUL and DIV instructions [ suppose that there is no overflow ]. |
| AL-060 |
 |
An Assembly Language Program that will read a decimal number and print it on the next line using procedures INDEC and OUTDEC. The INDEC procedure should be able to handle the OverFlow. |
| AL-061 |
 |
An Assembly Language Program that lets the user enter time in seconds, up to 65535, and outputs the time as hours, minutes, and seconds. Use Decimal input and output procedures for I/O.
|
| AL-062 |
 |
An Assembly Language Program that take a number of cents C, 0<=C<=99, and express C as half-dollars, quarters, dimes, nickels, and pennies. Use INDEC to enter C. |
| AL-063 |
 |
An Assembly Language Program that let the user to enter a fraction of the form M/N s.t. M is less than N, and the program prints the expansion to N decimal places, according to the following algorithm:
1. Print "."
Execute the following step N times:
2. Divide 10*M by N, getting quotient Q and remainder R.
3. Print Q.
4. Replace M by R and go to step 2.
Use INDEC procedure to read M and N and OUTDEC procedure to print Q.
|
| AL-064 |
 |
An Assembly Language Program that find the greatest common divisor [ GCD ] of two integers M and N, according to the following algorithm:
1. Divide M by N, getting quotient Q and remainder R.
2. If R=0, stop. N is the GCD of M and N.
3. If R<>0, replace M by N, N by R, and repeat step-1.
Use INDEC procedure to enter M and N and OUTDEC procedure to print the GCD.
|
|
|
|
|
|
Arrays - Addressing Modes |
|
|
|
|
|
|
| AL-065 |
 |
An Assembly Language Program that computes the sum of an array of size 10 with elements 10,20,30,40,50,60,70,80,90 and 100 respectively. Place the sum in AX and also display it. Use Register Indirect Mode to access the array elements. |
| AL-066 |
 |
An Assembly Language Program that initialize an array of size 10 with 0 using DUP instruction. Also display the array elements. |
| AL-067 |
 |
An Assembly Language Program that prompts the user to enter an array of size 10 and display it. |
| AL-068 |
 |
An Assembly Language Program to declare, initialize and print a 2D array of size 5x5. |
| AL-069 |
 |
An Assembly Language Program that prompts the user to enter an 2D array of size 5x5 in row major order and print the array. |
| AL-070 |
 |
An Assembly Language Program that declares and initialize a 2D array of size 4x5 in row major order, and print the contents of the 3rd row and 4th column using Register Indirect Mode. |
| AL-071 |
 |
An Assembly Language Program that declares and initialize an array of size 10, then display the contents of the array before & after reversing its contents using STACK. |
| AL-072 |
 |
An Assembly Language Program that declares and initialize an array of size 10, then display the contents of the array before & after reversing its contents using Register Indirect Mode. |
| AL-073 |
 |
An Assembly Language Program that declares and initialize an array of size 10, then display the contents of the array before & after sorting it in ascending order by using Bubble Sort method. |
| AL-074 |
 |
An Assembly Language Program that declares and initialize an array of size 10, then display the contents of the array before & after sorting it in ascending order by using Select Sort method. |
| AL-075 |
 |
An Assembly Language Program that declares and initializes a 2D array of size 4x5 in row major order, and print it. |
| AL-076 |
 |
An Assembly Language Program that declares and initializes a 2D array of size 4x5 in column major order, and print it. |
| AL-077 |
 |
An Assembly Language Program that declares and initializes a 2D array of size 5x7 in row major order, and print the array before and after clearing the 3rd row and 4th column using Based Index Mode. |
| AL-078 |
 |
An Assembly Language Program that will compute the class average on each exam. Suppose a class of five students is given four exams.The results are recorded as follows:
Student Name :: Test 1 - Test 2 - Test 3 - Test 4
Mary Allen : 67 - 45 - 98 - 33
Scott Baylis : 70 - 56 - 87 - 44
George Frank : 82 - 72 - 89 - 40
Keth Harris : 80 - 67 - 95 - 50
Sam Wong : 78 - 76 - 92 - 60
|
| AL-079 |
 |
An Assembly Language Program that will print the name of each student and his or her average [truncated to an integer] for the four exams. Suppose the class records are stored as follows:
CLASS DB 'Mary Allen',67,45,98,33
DB 'Scott Baylis',70,56,87,44
DB 'George Frank',82,72,89,40
DB 'Sam Wong',78,76,92,60
Note : Each name occupies 12 bytes.
|
| AL-080 |
 |
An Assembly Language Program that starts with an initially undefined byte array of max. 100, and lets the user insert single characters into the array in such a way that the array is always sorted in ascending order. The program should print a question mark, let the user to enter a character, and display the array with the new character inserted. Input ends when the user hits the ESC key. Duplicate characters should be ignored. |
|
|
|
|
|
The String Instructions |
|
|
|
|
|
|
| AL-081 |
 |
An Assembly Language Program that will copy a string STRING_1 into another string STRING_2 using the instruction MOVSB and REP, and also display it. |
| AL-082 |
 |
An Assembly Language Program that prompts the user to enter a string, then stores it in a variable using instruction STOSB. |
| AL-083 |
 |
An Assembly Language Program that will display a string using instruction LODSB. |
| AL-084 |
 |
An Assembly Language Program that prompts the user to enter a string, stores it and display it using procedures READ_STR and DISP_STR. |
| AL-085 |
 |
An Assembly Language Program that prompts the user to enter a string, then counts and display the number of vowels and consonants in the string using SCASB and REPNE instructions. |
|
|
|
|
|
Miscellaneous Programs |
|
|
|
|
|
|
| AL-086 |
 |
An Assembly Language Program to get and display the Current System Time. |
|
|
|
|
|