You are on page 1of 6

Microcontroller and Embedded Systems (MTS - 311) LAB REPORT

Microcontroller & Embedded


Systems
(MTS-311)

DE-43 Mechatronics
Syndicate – B

LAB REPORT
Week#5 AT89C51 Controller and Keil µVision

Names of Group Members:


 NS Saad Irfan CMS ID #388842
 NS Muhammad Rohail Abid CMS ID #365743

Submitted to: LD Qasim

Page 1 of 6
Microcontroller and Embedded Systems (MTS - 311) LAB REPORT

Introduction:

In this lab, we learned compare instructions like CJNE, JNC, and JC. We learned how
these commands operate and how they are used in Keil µVision by doing tasks.

Objective:

 To be able to use conditions and make decisions using the CJNE command on Keil.
 To be able to write a code that compares two values and stores data accordingly.

Compare Instructions:

When it comes to assembly language the compare instructions act like an if-else
statement used in c programming, the CJNE command compares the two numbers and updates
the carry bit accordingly, using which we can compare two numbers and make logical
decisions.

Format for CJNE :

CJNE, DEST-BYTE, SCR-BYTE, REL-ADDRESS ; This command compares and


jumps the two numbers are not equal, the values of dest-byte and scr-byte are compared and if
the two numbers are not equal the program would jump to the rel-address.

JNC:

This command is called jump if not carry which means it would operate when there is
0 stored in the carry bit.

Format for JNC:

JNC, DEST-TYPE,SCR-BYTE,REL-ADDRESS ; IF there is 0 stored in the carry bit


the program would go on else it would shift and move to rel-address, and ignore any code in
between.

JC:

This command is called jump if carry, it operates when there is 1 stored in the carry bit.

Page 2 of 6
Microcontroller and Embedded Systems (MTS - 311) LAB REPORT

Format for JC:

JC, DEST-TYPE,SCR-BYTE,REL-ADDRESS ; IF there is 1stored in the carry bit the


program would go on else it would shift and move to rel-address, and ignore any code in
between.

Sample code:

Fig #1, Sample Task Code

Fig #2, Sample Task Code Keil Implementation

Page 3 of 6
Microcontroller and Embedded Systems (MTS - 311) LAB REPORT

Fig #3, Sample Task Code Keil Implementation with Result

Lab Task 1: Write a program to implement the following C code in assembly

Fig #4, Lab task 1

Page 4 of 6
Microcontroller and Embedded Systems (MTS - 311) LAB REPORT

Fig #5, Lab Task 1 Keil Implementation

Fig #6, Lab Task 1 Keil Result


Page 5 of 6
Microcontroller and Embedded Systems (MTS - 311) LAB REPORT

Fig #7, Lab Task 1 Keil Result 2

Conclusion:

At the end of this lab, we were able to make a logical code that helped compare numbers
and make decisions using the CJNE, JC, and JNC compare instructions.

Page 6 of 6

You might also like