MC Lab
MC Lab
MC Lab
ECE DEPARTMENT
INDEX
KEIL IDE is basically an assembler and a compiler. Either an Assembly or C language code can
be written in KEIL.
1) Create a new folder for project to avoid getting mixed up with files.
2) Go to PROJECT > NEW uVISION PROJECT
3) Give some name and click SAVE
4) When prompted, select proper device that you're using ( i.e. ATMEL > AT89C51 )
5) When prompted, select YES
6) Click on FILE > NEW button and write your code (Assembly or C language)
7) SAVE the file with proper extension. For Assembly “name.asm” and for C “name.c”
8) Now write the code and notice how the code gets highlighted according to syntax.
9) Right click SOURCE GROUP 1 in the Project workspace.
10) Add the code you have written into the Project workspace.
11) Go to PROJECT Menu > Build target
12) Notice successful build. Ignore the warnings.
13) Debugging in Keil uVision: When you‟re done writing your code, compile it. Keil will
notify you of all the syntax errors (if any) in the program. Double click the error message and
the cursor will automatically move to the exact statement containing the error. Read the error
message and make changes accordingly.
14) When you‟re done fixing all the syntax errors, you may proceed to debugging your code.
You can do this by using the Debug Menu.
When prompted, simply click OK button to confirm that you‟re aware of this fact that the
evaluation version of Keil uVision which has a code size limit of 2K bytes.
15) Once the Debugging Mode is active, there are only few and simple things that you need to
know about. Here is the list as labelled in the picture below
These are the simple steps to write a code in Keil and compile it.
Aim:
To write and execute an assembly language program to add the given two 8 bit
numbers.
Objectives:
To add any two 8 bit numbers using immediate addressing and to store the result
Algorithm:
Program:
ORG 0000H
MOV A, #Data1
ADD A, #Data2
MOV 30H, A
HLT: SJMP HLT
END
Results:
Input: Output:
Conclusion:
Thus an assembly language program of 8 bit addition is written and executed
successfully.
Aim:
To write and execute an assembly language program to subtract the given two 8
bit numbers.
Objectives:
To subtract a small number from a large number using immediate addressing and to
store the result
Algorithm:
Program:
Results:
Input: Output:
Memory Address Data Memory Address Data
- Data 1 30H
- Data 2
Conclusion:
Thus an assembly language program of 8 bit subtraction is written and executed
successfully.
Aim:
To write and execute an assembly language program to add the given two 8 bit
numbers with carry.
Objectives:
To add any two 8 bit numbers using immediate addressing and to store the result and
carry
Algorithm:
Program:
Results:
Conclusion:
Aim:
To write and execute an assembly language program to copy a block of 10 bytes of data
from one location to another
Objectives:
To copy a block of 10 bytes of data from one location to another and show the result
Algorithm:
Program:
Results:
Conclusion:
Objectives:
To move a block of 8 bytes of data from address 50H to 57H to location starting
from 51H.
Algorithm:
Program:
Results:
Conclusion:
Aim:
To write and execute an assembly language program to exchange a block of 8
byte of data from RAM address 50H to 57H with 60H to 67H.
Objectives:
To transfer the content of a block of data to another block and vice versa
Algorithm:
Program:
Results:
Conclusion:
EXERCISE:
Aim:
To write and execute an assembly language program to burn the word
„MICROCONTROLLER‟ in the flash ROM and also read the data into internal
RAM locations
Objectives:
To burn the word „MICROCONTROLLER‟ in the flash ROM starting from
0400H and also read the data into internal RAM locations starting from 60H
Algorithm:
Program:
Result:
Conclusion:
Algorithm:
Program:
Result:
Conclusion:
EXERCISE:
Algorithm:
Program:
Result:
Conclusion:
Expt 10: WAP to generate and store natural numbers from 1 to N terms and also find the
sum of these numbers. Assume that the value N is stored in location 30H. Store generated
natural number from 40H. Store the resultant sum in Accumulator.
Algorithm:
Program:
Result:
Conclusion:
Algorithm:
Program:
Result:
Conclusion:
Expt 12: WAP to subtract two 8 bit numbers stored in external RAM location 4501
(minuend) and 4500 (subtrahend). The result should be in location 4502 and the sign bit in
location 4503.
Algorithm:
Program:
Result:
Conclusion:
Expt 13: WAP to find the largest number from a given array. Assume that the array is
present in internal RAM from 50H. Size of the array is 10H
Expt 14: WAP to search and find address of a given byte of data from 10 memory location
in external RAM starting from 1000H. Save the address in R2 (Lower order address) and
R3 (Higher order address).
Expt 15: WAP to count number of positives, negative and zeros in an array of signed
numbers stored in external RAM starting at 1000H. Size of array is 100 bytes.
Expt 16: WAP to count even and odd numbers in an array of 10 numbers stored in
external RAM starting at address 1000H.
Expt 17: WAP to sort 10 numbers in internal RAM location from 40H in ascending order.
Suggested Readings: