Lab Manual
Transcription
Lab Manual
Lab Manual Microprocessor II (Pr): COT-413 Lab Instructions Whether an experiment contains one or several practicals /programs Several practicals / programs ? Lab Teacher forms groups of the students based on One practical / program All Students need to perform the practical/program Assign all practicals /programs among all groups Teacher decides whether the completed practicals / programs can be appropriately described using flow chart, algorithm, query statement, etc. Teacher issues necessary instructions to the students for writing practicals / programs accordingly Students write experiments in practical files and get them signed by the lab teacher Students make entries in the list of contents of the practical files and get them signed by the lab teacher Whether practical has been verified and signed by the lab teacher? ? If a student has not completed a practical, he/she is expected to complete it at his/her own with the help of his/her fellow students in his/her hostel The student completes the practical file and submits it to the concerned teacher in his/her office or mail box on next working day In case of an experiment containing several practicals, a lab teacher needs to think whether a practical performed by the students in one group needs to be repeated by the other groups in lab on the same day? OR A practical performed by the students in one group needs to be repeated as assignments to be completed by the students of other groups in their hostels? Here, an assignment includes both executing a program on computer and also writing the same in practical file. OR A practical performed by the students in one group needs to be repeated as assignments, only writing practicals in their practical files, for the students of other groups in their hostels? Teacher issues necessary instructions to the students accordingly. Lab Manual Microprocessor II (Pr) COT- 413 L T P - - 3 Practical exam: 40 Sessional: 60 Instructions The advance microprocessor lab experiments are designed for 32-bit programming by using Microsoft Macro Assembler MASM 6.15. The objective of designinig this lab manual is to make programming more efficient and productive.This lab manual includes various experiments as well as its variants also, some of the experiments are mandatory for every students but if a program has its variants than alternatively a students have to execute only one variant. This makes our lab classes more interesting. Our objective is to learn 32-bit programming by using simulator. In this we are using Microsoft Macro Assembler (MASM) 6.15. The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for Microsoft Windows. There are two versions of the assembler - 16-bit and 32-bit assembly. The Microsoft Macro Assembler has many macro features that make 32-bit programming much easier to learn. Microsoft Macro Assembler (MASM) 6.15 is an integrated software package written by Microsoft corpration exclusively designed for 32-bit programming. We are using a library called link library for basic input-output operation. Two versions of the link library exist that were originally developed by Kip Irvine. The 32-bit version is called Irvine32.lib and works in Win32 console mode under MS-Windows, while the 16-bit version is called Irvine16.lib and works under MS-DOS. Here, we are workng in Irvine32.lib. The following are the steps to use MASM 6.15: Step1: Download MASM615.exe, a self-extract executable file, fromhttp://www.ccse.kfupm.edu.sa/~mudawar/coe205/lab/index.htm Step2: Installation can be done in following way: Double click on MASM615.exe to extract the files. Specify the installation directory. Use C:\Program Files\MASM615 as the destination directory. Step3: Define an environment variable MASMDIR for the installation directory: Under Control Panel, double-click on System to obtain the System Properties dialog box. Under System Properties, click on the Advanced tab. Click on the Environment Variables button. Under Environment Variables, Click on the New button to add a New System Variable. Add MASMDIR as the variable name and the C:\Program Files\MASM615 1 as the variable value and press OK. The MASMDIR variable and its value should now appear under System Variables. If a different installation directory is chosen for MASM 6.15 then specify it in New System Variable – Variable value. Step4: Edit the Path system variable by inserting %MASMDIR%; (don't forget the semicolon) at the beginning of the variable value. Step5: Define a new system variable called INCLUDE with value %MASMDIR%\INCLUDE and press OK. This variable specifies the directory that contains the include (.inc) files. Step6: Define a new system variable called LIB with value %MASMDIR%\LIB and press OK. This variable specifies the directory that contains the link library (.lib) files. Step7: Check the environment variables. Open a Command Prompt and type: • SET MASMDIR • SET INCLUDE • SET LIB • PATH These commands should display the MASMDIR, INCLUDE, LIB, and PATH environment variables. If the installation steps are done properly, you can start using the MASM commands. Experiment 1 I. Write a program to read a 32-bit integer, store that number in EAX register and display it digit by digit. II. Write a program that uses a loop to input ten signed 32-bit integers from the user, stores the integer in an array and redisplays the integers. Experiment 2 I. Write a program that generates and displays 20 random strings each consisiting of 10 random capital letters {A,…Z}. II. Write a program that displays a single character ‘*’ at hundred random screen locations. Use a delay of 100 milliseconds before displaying the ‘*’ at the next random screen location. Experiment 3 I. Write a program that reads two one-digit numbers and output the maximum of two. Extend the program to read three one-digit integers and find max. 2 Experiment 4 I. Write an assembly program to perform addition, subtraction, multiplication and division of two 32-bit numbers. II. Write a program to find GCD of a given two 32-bit numbers. III. Write a program to find square and cube of a number. Experiment 5 I. Write a program to check whether a given string is palindrome or not. II. Write a program to reverse an input string. Experiment 6 I. Write some programs which uses multiple data segment and multiple code segments. Do these programs by defining segments in different files and link all of them to get the desired output. Experiment 7 I. Write a program to implement a rolling display of characters using display interface. Experiment 8 I. Develop and execute program to derive a stepper motor interface to rotate the motor in anti-clockwise direction in n steps. 3