Computer Science - Journal
Paper I - Software
Visual Basic
Program No 1 : Program to calculate Area of circle and Rectangle
Private Sub area_circle_Click()
Text2.Text = 3.14 * Val(Text1.Text) * Val(Text1.Text)
End Sub
Private Sub area_rect_Click()
Text5.Text = Val(Text3.Text) * Val(Text4.Text)
End Sub
Private Sub circle_Click()
Shape2.Visible = False
Label2.Visible = False
Label3.Visible = False
Text3.Visible = False
Text4.Visible = False
Text5.Visible = False
area_rect.Visible = False
Shape1.Visible = True
Label1.Visible = True
Text1.Visible = True
Text2.Visible = True
area_circle.Visible = True
End Sub
Private Sub clear_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub rectangle_Click()
Shape2.Visible = True
Label2.Visible = True
Label3.Visible = True
Text3.Visible = True
Text4.Visible = True
Text5.Visible = True
area_rect.Visible = True
Shape1.Visible = False
Label1.Visible = False
Text1.Visible = False
Text2.Visible = False
area_circle.Visible = False
End Sub
Program No 2 : Program using Drag-Drop
Private Sub Form_Load()
Picture1.BackColor = vbRed
End Sub
Private Sub object_DragDrop(Source As Control, X As Single, Y As Single)
Picture1.BackColor = vbBlue
End Sub
Private Sub object_DragOver(Source As Control, X As Single, Y As Single, State
As Integer)
Picture1.BackColor = vbGreen
End Sub
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Picture1.BackColor = vbBlue
End Sub
Private Sub Picture1_DragOver(Source As Control, X As Single, Y As Single,
State As Integer)
Picture1.BackColor = vbGreen
End Sub
Program No 3 : Program using List Box
Private Sub addl1_Click()
Dim str1 As String
str1 = InputBox("please enter name of new item")
List1.AddItem str1
End Sub
Private Sub addl2_Click()
str2 = InputBox("please enter name of new item")
List2.AddItem str2
End Sub
Private Sub backward_Click()
List1.AddItem List2.Text
End Sub
Private Sub end_Click()
End
End Sub
Private Sub forward_Click()
List2.AddItem List1.Text
End Sub
Private Sub reml1_Click()
Dim r1
r1 = List1.ListIndex
List1.RemoveItem r1
End Sub
Private Sub reml2_Click()
Dim r2
r2 = List2.ListIndex
List2.RemoveItem r2
End Sub
Program No 4 : Program to declare Result using Case Condition
Private Sub clear_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub result_Click()
Dim t1 As Boolean
t1 = True
s1 = Val(Text1.Text)
s2 = Val(Text2.Text)
s3 = Val(Text3.Text)
s4 = Val(Text4.Text)
s5 = Val(Text5.Text)
s6 = Val(Text6.Text)
Avg = (s1 + s2 + s3 + s4 + s5 + s6) / 6
Select Case t1
Case s1 < 40 Or s2 < 40 Or s3 < 40 Or s4 < 40 Or s5 < 40 Or s6 < 40
Text7.Text = "Failed"
Case Avg < 60
Text7.Text = "Second Class"
Case Else
Text7.Text = "First Class"
End Select
End Sub
Program No 5 : Program using scientific calculator
Private Sub cmdsin_Click( )
Dim s As Double
s = Sin(Val(Text1.Text) * 3.142 / 180)
Text2.Text = s
End Sub
Private Sub cmdcos_Click( )
Dim c As Double
c = Cos(Val(Text1.Text) *3.142 / 180)
Text2.Text = c
End Sub
Private Sub cmdtan_Click( )
Dim t As Double
t = Tan (Val(Text1.Text) * 3.142/ 180
Text2.Text = t
End Sub
Private Sub cmdlog_Click( )
Dim I As Double
I = Log(Val(Text1.Text)) / 2.303
Text2.Text = I
End Sub
Private Sub cmdreciprocal_Click( )
Dim r As Double
r = 1/(Val(Text1.Text))
Text2.Text = r
End Sub
Private Sub cmdsqroot_Click( )
Dim sq As Double
sq = Sqr(Val(Text1.Text))
Text2.Text = sq
End Sub
Private Sub cmdsq_Click( )
Dim squa As Double
squa = Val(Text1.Text) * Val(Text1.Text)
Text2.Text = squa
End Sub
Private Sub cmdclear_Click( )
Text1.Text =
Text2.Text =
End Sub
Private Sub cmdexit_Click( )
Dim S1, S2 As String
S1 = MsgBox(DO U WANT TO EXIT, vbYesNo)
If S1 = vbYes Then
S2 = MsgBox(THANKS)
Unload Me
End If
End Sub
Program No 6 : Program to create Graphic Editor
Private Sub big_Click()
Shape1.height = 2500
Shape1.Width = 2500
End Sub
Private Sub blue_Click()
Shape1.FillColor = vbBlue
End Sub
Private Sub green_Click()
Shape1.FillColor = vbGreen
End Sub
Private Sub medium_Click()
Shape1.height = 2000
Shape1.Width = 2000
End Sub
Private Sub red_Click()
Shape1.FillColor = vbRed
End Sub
Private Sub small_Click()
Shape1.height = 1500
Shape1.Width = 1500
End Sub
Private Sub thick_Click()
Shape1.BorderWidth = 5
End Sub
Private Sub thicker_Click()
Shape1.BorderWidth = 10
End Sub
Private Sub thin_Click()
Shape1.BorderWidth = 1
End Sub
Program No 7 : Program to calculate sum of 100 numbers
Dim i, a, s As Integer
Private Sub add_Click()
i=0
a=0
s=0
Do While i <= 100
a = InputBox("Please enter 100 numbers to be added")
s=s+a
i=i+1
Loop
End Sub
Private Sub clear_Click()
Text1.Text = ""
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub result_Click()
Text1.Text = s
End Sub
Program No 8 : Validate Name, Date of Birth and Telephone number
Private Sub clear_Click()
name1.Text = ""
dob.Text = ""
tele.Text = ""
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub valid_Click()
Dim a, L As Integer
a=0
L = Len(name1.Text)
If L = 0 Then
MsgBox ("Name cannot be Blank")
a=1
Else
For i = 1 To L
ch = UCase(Mid(name1.Text, i, 1))
If Not ((ch >= "A" And ch <= "Z") Or (ch = "")) Then
MsgBox ("Invalid Name")
name1.Text = ""
name1.SetFocus
a=1
i=L+1
End If
Next
End If
If IsDate(dob.Text) <> True Then
MsgBox ("Enter a valid Date of Birth")
dob.Text = ""
dob.SetFocus
a=1
End If
If IsNumeric(tele.Text) <> True Then
MsgBox ("Enter valid Telephone number")
tele.Text = ""
tele.SetFocus
a=1
End If
If a = 0 Then
MsgBox ("All fields are valid")
MsgBox ("Thank you")
End If
End Sub
C++
Program No 1 : Calculate area and circumference of circle using class
#include<iostream.h>
#include<conio.h>
class circle
{
private: float r,a,c,x,y;
public: circle()
{ r=7; x=6; y=8; }
void area()
{ a=3.14*r*r; }
void circum()
{ c=2*3.14*r; }
void print()
{
cout<<"The radius of the circle is"<<r;
cout<<"\n\nThe x,y coordinate of center is"<<x<<","<<y;
cout<<"\n\nThe area of circle is="<<a;
cout<<"\n\nThe circumference of circle is"<<c;
}
};
void main()
{ clrscr();
circle c;
c.area();
c.circum();
c.print();
}
Output
The radius of the circle is 7
The x,y, coordinate of center is 6,8
The area of circle is 153.860001
The circumference of circle is 43.959999
Program No 2 : Search a number using binary search
#include<iostream.h>
#include<conio.h>
int bsearch(int[],int);
void main()
{
int a[10],i,d,loc;
clrscr();
cout<<"enter any 10 numbers in ascending order";
for(i=0;i<10;i++)
{
cin>>a[i];
}
cout<<"enter the number to be searched";
cin>>d;
loc=bsearch(a,d);
if(loc)
cout<<"\nNumber found at location:"<<loc;
else
cout<<"\nNumber not found";
getch();
}
int bsearch(int y[],int dt)
{
int mid,lb,ub;
lb=0; ub=10-1;
while(ub>=lb)
{
mid=(ub+lb)/2;
if(y[mid]==dt)
return mid+1;
if(y[mid<dt)
lb=mid+1;
else
ub=mid-1;
}
return 0;
}
Output
Enter any 10 numbers 1 3 4 5 6 8 9 12 14 15
Enter to be searched 8
Number found at location 6
Enter any 10 numbers 1 3 4 5 6 8 9 12 14 15
Enter to be searched 18
Number not found
Program No 3 : Sort numbers using Bubble Sort
#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,j,temp;
cout<<"Enter the elements of the array\n";
for(i=0;i<10;i++)
{
cin>>a[i];
}
cout<<"Original array is";
for(i=0;i<10;i++)
{
cout<<a[i];
}
for(i=0;i<10;i++)
{
for(j=0;j<10-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
cout<<"After Bubble sort Ascending order is\n";
for(i=0;i<10;i++)
{
cout<<a[i];
}
getch();
}
//Output
Enter the elements of the array
10
9
8
7
6
5
4
3
2
1
Original Array is
10
9
8
7
6
5
4
3
2
1
After Bubble sort Ascending order is
1
2
3
4
5
6
7
8
9
10
Program No 4 : Program using class inheritance
#include<iostream.h>
#include<conio.h>
class student
{
protected: int rollno;
public: void setno(int a)
{
roll no=a;
}
void dispro()
{
cout<<"Roll no="<<rollno<<endl;
}
};
class test: public student
{
protected: float marks1,marks2;
public: void setmarks(float x,float y)
{
marks1=x; marks2=y;
}
void dismarks()
{
cout<<"Marks obtained in 1st test="<<marks1<<endl;
cout<<"Marks obtained in 2nd test="<<marks2<<endl;
}
};
class sports
{
protected: float score;
public: void setscore(float x)
{
score=x;
}
void dispscore()
{
cout<<"\nScore in sports="<<score<<endl;
}
};
class result: public test, public sports
{
float total;
public: void display()
{
total=marks1+marks2+score;
dispro();
dispmarks();
dispscore();
cout<<"Total marks"<<total<<endl;
}
};
void main()
{
clrscr();
result s1;
s1.setno(100);
s1.setmarks(20,20);
s1.setscore(10);
s1.display();
getch();
}
Program No 5 : Program using Constructor and Destructor
#include<iostream.h>
#include<conio.h>
class ratio
{
public: ratio()
{
cout<<"\n\nThe Object is born";
}
void f1()
{
cout<<"\n\nNow object is alive";
}
~ratio()
{
cout<<"\n\nObject dies";
}
};
void main()
{
clrscr();
ratio r;
r.f1();
getch();
}
Output
The object is Born
Now object is alive
Object dies
Program No 6 : Program polar-rectangle & rectangle-polar conversion
#include<iostream.h>
#include<conio.h>
#include<math.h>
class rectangle
{
float x,y;
public:void getdata1()
{
cout<<"Enter the rectangular coordinates";
cout<<"\nx=";
cin>>x;
cout<<"\ny=";
cin>>y;
}
void con_rec_pol()
{
float r,t;
r=sqrt(x*x+y*y);
t=atan(y/x)*180/3.14;
cout<<"\nRectangle to polar conversion is";
cout<<"\n r="<<r;
cout<<"\n theta="<<t;
}
};
class polar
{
float r,t;
public:void getdata2()
{
cout<<"\n\nEnter the polar coordinates";
cout<<"\nr=";
cin>>r;
cout<<"\ntheta=";
cin>>t;
}
void conv_pol_rec()
{
float x,y;
x=r*cos(t*3.14/180);
y=r*sin(t*3.14/180);
cout<<"\n\nPolar to Rectangle conversion is";
cout<<"\n x="<<x;
cout<<"\n y="<<y;
}
};
void main()
{
clrscr();
rectangle rect1;
rect1.getdata1();
rect1.con_rec_pol();
polar pol1;
pol1.getdata2();
pol1.conv_pol_rec();
getch();
}
Output
Enter the rectangular coordinates
x=2
y=3
Rectangle to polar conversion is
r=3.605551
theta=56.338493
Enter the polar coordinates
r=3.605551
theta=56.338493
Polar to rectangle conversion is
x=2
y=3
Program No 7 : Program with a Ratio class using Member Function
#include<iostream.h>
#include<conio.h>
class ratio
{
int num,den;
public:void assign();
double convert();
void invert();
void print();
};
void ratio::assign()
{
cout<<"Enter numerator"<<endl;
cin>>num;
cout<<"Enter denominator"<<endl;
cin>>den;
}
double ratio::convert()
{
return (num/den);
}
void ratio::invert()
{
int temp;
temp=num;
num=den;
den=temp;
}
void ratio::print()
{
cout<<num<<"/"<<den<<endl;
}
void main()
{ clrscr();
ratio r;
r.assign();
cout<<"Original ratio is=";
r.print();
cout<<"Inverse ratio is=";
r.convert();
r.invert();
r.print();
getch();
}
Output
Enter Numerator
2
Enter Denominator
3
Original Value is = 2/3
Inverse Value is = 3/2
Program No 8 : Program using virtual function
#include<string.h>
#include<iostream.h>
#include<conio.h>
class Person
{
private: char name[80];
public: Person()
{
strcpy(name,"BOB");
}
virtual void print()
{
cout<<"\nName of the person assigned through base object is"<<name;
}
};
class student:public Person
{
private: char name1[80];
public: student()
{
strcpy(name1,"TOM");
}
void print()
{
cout<<"\nName of the person assigned through derived object"<<name1;
}
};
void main()
{
clrscr();
Person *p,x;
student y;
p=&x;
p->print();
p=&y;
p->print();
getch();
}
// Output
Name of the person assigned through base object is BOB
Name of the person assigned through derived object is TOM
HTML
Program No 1 : Design a HTML Page for College
Home.html
<html><head>
<title> College profile</title></head>
<body bgcolor="green">
<marquee behavior=alternate><h1 align="center"><font color=red> PACE
Junior Science College</font></h1> </center></marquee><br>
<p><font face="Century" color="white"> Four years ago, IIT-ian's Pace
introduced the unique concept of integrated learning for Competitive Exams,
Board Exams
through partnerships with the most reputed schools and colleges across
Mumbai.</p><br><br>
<p>In 2009, the Government of Maharashtra entrusted IIT-ian's Pace with the
responsibility to manage two Junior Science colleges in collaboration with the
MCGM. These colleges offer integrated Competitive Exam preparation and
Board
preparation under one roof.</p><br><br>
<p>Today, the success of this concept has led to a revolution for competitive
exams and boards. In a landmark
ruling, <u>the Government of Maharashtra awarded IIT-ian's Pace</u>
special permission to run 6 Pace Junior Science colleges across
Mumbai.</font> <br><br>
<h3><a href="courses.html">Courses</a><br>
<a href="admission.html">Admission process</a><br>
<img src="pace.jpg"></img >
</body>
</html>
Admission.html
<html><head><title>Admission</title></head>
<body>
<marquee><font color=red><h2>6 Pace Junior Science Colleges (Andheri,
Borivali, Dadar, Nerul, Powai, Thane)</h2></font></marquee><br><br>
<b><u>Eligibility Criteria</u>:</b> Direct admission to the students scoring
90% and above in PCM in X Boards or
IX Final exams. Aptitude test is compulsory for other students.<br>
<br><br>
<b><u>Admission Form</u>:</b> To be collected from the respective Pace
Junior Science Colleges/ centers
<br><br>
<b><u>Documents required</u>:</b><br>
<ol type="A">
<li>X standard mark sheet (original with attested copy)</li>
<li>School Leaving Certificate</li>
<li>5 passport size photographs</li>
</ol>
<br><h3><a href="courses.html">Courses</a><br>
<a href="home.html">Home</a>
</body>
</html>
Courses.html
<html><head>
<title> Courses offered</title></head>
<body bgcolor=green><font color=black>
<marquee><h2>Courses available at PACE Junior Science
College</h2></marquee></font>
<font size=5 color=white><pre>
<ol>
<li> XI and XII
IITJEE / AIEEE </li>
<li> XI and XII
MH-CET </li>
<li> XI and XII </li>
</ol></pre></font>
<u><i><h3> <font color=black>Vocational subjects offered at Pace Junior
Science College</font> </h3></i></u>
<font size=4 color=white><ul>
<li>Electrical Maintenance </li>
<li> Computer Science </li>
</ul></font>
<br><h3><a href="admission.html">Admission</a><br>
<a href="home.html">Home</a>
</body>
</html>
Program No 2 : Design a HTML Page to draw Table
Table1.html
<html><head><title>table</title></head>
<body bgcolor="brown">
<font face="Arial Rounded MT Bold" size="2" color="yellow">
<marquee>Record</marquee>
<table border=1 align=center>
<caption>College cut offs</caption>
<tr>
<th align="center">Year</th>
<th align="center">Stream</th>
<th align="center">Cut off (%)</th>
</tr>
<tr>
<th rowspan="2">FYJC</th>
<td align="center">Commerce</th>
<td align="center"> 75 </th>
</tr>
<tr>
<td align="center">Science</td>
<td align="center">90</td>
</tr>
<tr>
<th align="center">FYBCom</th>
<td align="center">IT</td>
<td align="center"> 70 </td>
</tr>
<tr>
<th rowspan="2">FYBSc</th>
<td align="center">IT</td>
<td align="center"> 80 </td>
</tr>
<tr>
<td align="center">CS</td>
<td align="center">85</td>
</tr>
</table>
<p><a href="home.html"><img src="Sunset.jpg" height=200
width=250></img></a></p>
</font> </body> </html>
Paper II : Hardware
Programs for 8085 Microprocessor
Q 1) A Block of data is stored in memory location starting from C040. Length of the
block is stored in register D. Write a program to transfer the entire block of data to
another memory location starting from memory location C050
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
50
C005
C0
C006
C007
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
LXI B, C050H
;Initialize the register pair
BC to memory location C050
H
MVI D, 05 H
;Set the counter for 05
numbers in register D
MOV A,M
;Copy the data content of HL
pair to accumulator
;Store the data content of
accumulator to register pair
BC
;Increment the memory
location of HL register pair
by 1
;Increment the memory
location of BC register pair
by 1
;Decrement the counter by 1
05
C008
:UP
C009
STAX B
C00A
INX H
C00B
INX B
C00C
DCR D
C00D
JNZ
C00E
08
C00F
C0
C010
UP:
RST 1
;If counter 0 (reg.D
0)then jump to memory
location c008
;Stop the execution
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
01 H
02 H
03 H
04 H
05 H
After Execution :
A=
D=
F=
C050 =
C051 =
C052 =
C053 =
C054 =
F=
S Z X AC X P X CY
Q2) A Block of data is stored in memory location starting from C040. Length of the
block is stored in register D. Write a program to transfer the entire block of data to
another memory location starting from memory location C050 in reverse order.
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
54
C005
C0
C006
C007
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
LXI B, C054H
;Initialize the register pair
BC to memory location C054
H
MVI D, 05 H
;Set the counter for 05
numbers in register D
MOV A,M
;Copy the data content of HL
pair to accumulator
;Store the data content of
accumulator to register pair
BC
;Increment the memory
location of HL register pair
by 1
;Increment the memory
location of BC register pair
by 1
;Decrement the counter by 1
05
C008
:UP
C009
STAX B
C00A
INX H
C00B
DCX B
C00C
DCR D
C00D
JNZ
C00E
08
C00F
C0
C010
UP:
RST 1
;If counter 0 (reg.D
0)then jump to memory
location c008
;Stop the execution
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
01 H
02 H
03 H
04 H
05 H
After Execution :
A=
D=
F=
C050 =
C051 =
C052 =
C053 =
C054 =
F=
S Z X AC X P X CY
Q3)A block of data is stored in memory location starting from memory location
C040 . Another block of data is stored in memory location starting from memory
location C050. Length of the blocks is stored in register D. Write a program to
exchange / swap the data contents of both these blocks
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
50
C005
C0
C006
C007
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
LXI B, C050H
;Initialize the register pair
BC to memory location C050
H
MVI D, 05 H
;Set the counter for 05
numbers in register D
LDAX B
;Load the data contents of
register pair BC to
accumulator
;Copy the data content of
accumulator to register E
;Copy the data content of
register pair HL to
accumulator
;Store the data content of
accumulator to register pair
BC
;Copy the data content of
register E to register pair HL
;Increment the memory
location of HL register pair
by 1
;Increment the memory
location of BC register pair
by 1
;Decrement the counter by 1
05
C008
: UP
C009
MOV E , A
C00A
MOV A ,M
C00B
STAX B
C00C
MOV M , E
C00D
INX H
C00E
INX B
C00F
DCR D
C010
C011
C012
C013
JNZ
UP:
08
C0
RST 1
;If counter 0 (reg D 0
)then jump to memory
location c008
;Stop the execution
OUTPUT :
Before Execution :
C040 = 01 H
C041 = 02 H
C042 = 03 H
C043 = 04 H
C044 = 05 H
C050
=
C051
=
C052
=
C053
=
C054
=
06H
07H
08H
09H
0AH
After Execution :
A=
D=
F=
C040 =
C041 =
C042 =
C043 =
C044 =
C050
=
C051
=
C052
=
C053
=
C054
=
S Z X AC X P X CY
Q 4) A block of data is stored in memory location starting from C040 . Length of the
block is stored in register B. Write a program to add the data content of the memory
location and store the result at the end of the block.
Memory Op- Labels
Location Code
C000
C001
Comments
XRA A
;Clear the data content of
accumulator
;Initialize the register pair
HL to memory location C040
H
LXI H, C040H
C002
40
C003
C0
C004
C005
Mnemonics
MVI B, 05 H
;Set the counter for 05
numbers in register B
ADD M
;Add the data content of
register pair HL to
accumulator
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by
05
C006
:UP
C007
INX H
C008
DCR B
C009
JNZ
C00A
06
C00B
C0
UP:
C00C
MOV M ,A
C00D
RST 1
;If counter 0 (reg B 0
)then jump to memory
location C005
;Copy the data content of
accumulator to register pair
HL
;Stop the execution
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
01 H
02 H
03 H
04 H
05 H
After Execution :
A=
B=
F=
=
C045
F
S Z X AC X P X CY
Q 5) A block of data is stored in memory location starting from C041 . Length of the
block is stored in memory location C040. Write a program to add the data content of
the memory location and store the result at the end of the block.
Memory Op- Labels
Location Code
C000
C001
Mnemonics
Comments
XRA A
;Clear the data content of
accumulator
;Initialize the register pair
HL to memory location C040
H
LXI H, C040H
C002
40
C003
C0
C004
MOV B , M
C005
INX H
C006
:UP
ADD M
C007
INX H
C008
DCR B
C009
JNZ
C00A
06
C00B
C0
UP:
C00C
MOV M ,A
C00D
RST 1
;Copy the counter stored at
memory location to register
B
;Increment the memory
location of HL register pair
by 1
;Add the data content of
register pair HL to
accumulator
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by 1
;If counter 0(reg B 0 )
then jump to memory
location C005
;Copy the data content of
accumulator to register pair
HL
;Stop the execution
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
C045
05H
01 H
02 H
03 H
04 H
05 H
After Execution :
A=
B=
F=
=
C046
F
S Z X AC X P X CY
Q 6) A block of data is stored in memory location starting from C040 . Length of the
block is stored in register B. Write a program to find the largest number from the
given block of data and store it at the end of the block.
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
Comments
LXI H, C040H
;Initialize the register pair HL
to memory location C040 H
MVI A, 00 H
;Assign the lowest value of
data to accumulator
MVI B, 05 H
;Set the counter for 05
numbers in register B
CMP M
;Compare the data content of
register pair HL with the
data content of accumulator
;If carry flag is not set then
jump to memory location
C00C
00
C005
C006
Mnemonics
05
C007
: UP
C008
JNC NEXT :
C009
0C
C00A
C0
C00B
MOV A , M
C00C
:
NEXT
INX H
;Copy the data content of
register pair HL th
accumulator
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by 1
C00D
DCR B
C00E
JNZ UP :
;If counter 0 (reg B 0
)then jump to memory
location C007
C011
MOV M , A
C012
RST 1
;Store the largest number at
the end of block
;Stop the execution
C00F
07
C010
C0
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
01 H
02 H
0A H
04 H
05 H
After Execution :
A=
B=
F=
=
C045
F
S Z X AC X P X CY
Q 7) A block of data is stored in memory location starting from C040 . Length of the
block is stored in register B. Write a program to find the smallest number from the
given block of data and store it at the end of the block.
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
Comments
LXI H, C040H
;Initialize the register pair HL
to memory location C040 H
MVI A, FF H
;Assign the highest value of
data to accumulator
MVI B, 05 H
;Set the counter for 05
numbers in register B
CMP M
;Compare the data content of
register pair HL with the
data content of accumulator
;If carry flag is set then jump
to memory location C00C
FF
C005
C006
Mnemonics
05
C007
: UP
C008
JC NEXT :
C009
0C
C00A
C0
C00B
MOV A , M
C00C
:
NEXT
INX H
;Copy the data content of
register pair HL th
accumulator
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by 1
C00D
DCR B
C00E
JNZ UP :
;If counter 0 (reg B 0
)then jump to memory
location C007
C011
MOV M , A
C012
RST 1
;Store the smallest number at
the end of block
;Stop the execution
C00F
07
C010
C0
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
06 H
07 H
0A H
08 H
01 H
After Execution :
A=
B=
F=
=
C045
F
S Z X AC X P X CY
Q 8) A block of data is stored in memory location starting from C040. Length of the
block is stored in register B. Write a program to find the first occurrence of the
number AB H from the given block of data and if the number is not found store FFFF
H in HL - pair
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
Comments
LXI H, C040H
;Initialize the register pair HL
to memory location C040 H
MVI A, AB H
;Load the data AB H to
accumulator
MVI B, 05 H
;Set the counter for 05
numbers in register B
CMP M
;Compare the data content of
register pair HL with the
data content of accumulator
;If Zero flag is set then jump
to memory location C013
AB
C005
C006
Mnemonics
05
C007
: UP
C008
JZ NEXT :
C009
13
C00A
C0
C00B
INX H
C00C
DCR B
C00D
JNZ UP :
;If counter 0 (reg B 0
)then jump to memory
location C007
LXI H, FFFF H
;Initialize the register pair HL
to memory location FFFF H
RST 1
;Stop the execution
C00E
07
C00F
C0
C010
C011
FF
C012
FF
C013
:NEXT
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by 1
OUTPUT :
Case I:
Before Execution :
C040 = 01 H
C041 = 02 H
C042 = AB H
C043 = 04 H
C044 = AB H
After Execution :
A=
B=
H=
L=
F=
F=
Case II:
S Z X AC X P X CY
Before Execution :
C040 = 01 H
C041 = 02 H
C042 = 03 H
C043 = 04 H
C044 = 05 H
After Execution :
A=
B=
H=
L=
F=
F=
S Z X AC X P X CY
Q 9) A block of data is stored in memory location starting from C040. Length of the
block is stored in register B. Write a program to find the number of times the data
AB H occurred from the given block of data and store the result at the end of the
block
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
LXI H, C040H
;Initialize the register pair HL
to memory location C040 H
MVI A, AB H
;Load the data AB H to
accumulator
MVI B, 05 H
;Set the counter for 05
numbers in register B
MVI C , 00 H
;Clear the data content of
register C
CMP M
;Compare the data content of
register pair HL with the
data content of accumulator
;If Zero flag is set then jump
to memory location C013
05
C007
C008
Comments
AB
C005
C006
Mnemonics
00
C009
: UP
C00A
JNZ NEXT :
C00B
0E
C00C
C0
C00D
INR C
C00E
:NEXT
INX H
;Increment the data content
of register C by 1
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by 1
C00F
DCR B
C010
JNZ UP :
;If counter 0 (reg B 0
)then jump to memory
location C006
C013
MOV M , C
C014
RST 1
;Copy the data content of
register C to register pair HL
;Stop the execution
C011
09
C012
C0
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
AB H
02 H
AB H
04 H
AB H
After Execution :
A=
B=
C=
=
C045
F=
S Z X AC X P X CY
Q 10) A block of data is stored in memory location starting from C040. Length of the
block is stored in register B. Write a program to find the total number of odd and
even numbers from the given block of data and stored it at the end of block
Memory OpLocation Code
C000
C001
40
C002
C0
Labels
C003
C004
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair HL
to memory location C040 H
MVI B, 05 H
;Set the counter for 05
numbers in register B
MVI D, 00 H
;Clear the data content of
register D
MVI E , 00 H
;Clear the data content of
register E
MOV A , M
;Copy the data content of
register pair HL to
accumulator
;Rotate the data content of
accumulator 1-bit position to
the right L.S.B. will shift in
carry as well as in M.S.B.
;If carry flag is set then jump
to memory location C012
05
C005
C006
C007
00
C008
C009
00
: up
C00A
RRC
C00B
JC NEXT :
C00C
C00D
C00E
12
C0
INR C
C00F
C010
C011
C012
C013
JMP DOWN :
13
C0
: NEXT
INR D
: DOWN
INX H
C014
DCR B
C015
JNZ UP :
;Increment the data content
of register C by 1
;Jump to memory location
C013
;Increment the data content
of register C by 1
;Increment the memory
location of HL register pair
by 1
;Decrement the counter by 1
;If counter 0 (reg B 0
)then jump to memory
location C009
Memory OpLocation Code
C016
09
Mnemonics
Comments
C018
MOV M , D
C019
INX H
C01A
MOV M , E
C01B
RST 1
;Store the number of odd
numbers in the next memory
location of register pair HL
;Increment the memory
location of HL register pair
by 1
;Store the number of even
numbers in the next memory
location of register pair HL
;Stop the execution
C017
Labels
C0
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
01 H
02 H
03 H
04 H
05 H
After Execution :
A=
B=
D=
E=
F=
C045 =
=
C046
F=
S Z X AC X P X CY
Q 11) Two numbers are stored in consecutive memory location starting from C040.
Write a program to multiply the numbers and store the result in the next memory
location.
Memory Op- Labels
Location Code
C000
C001
Mnemonics
Comments
XRA A
;Clear the data content of
accumulator
;Initialize the register pair
HL to memory location C040
H
LXI H, C040H
C002
40
C003
C0
C004
MOV B , M
C005
INX H
C006
:UP
ADD M
C007
DCR B
C008
JNZ
C009
06
C00A
C0
UP:
C00B
INX H
C00C
MOV M ,A
C00D
RST 1
;Copy the counter stored at
memory location to register
B
;Increment the memory
location of HL register pair
by 1
;Add the data content of
register pair HL to
accumulator
;Decrement the counter by 1
;If counter 0(reg B 0 )
then jump to memory
location C006
;Increment the memory
location of HL register pair
by 1
;Copy the data content of
accumulator to register pair
HL
;Stop the execution
OUTPUT :
Before Execution :
C040 = 03 H
C041 = 04 H
After Execution :
A=
B=
F=
=
C042
F=
S Z X AC X P X CY
Q 12) An one byte number is stored in memory location starting from C030. Write a
program to separate the two nibbles of the one byte number and store them in the
next memory location. Also write a program to multiply the separated nibbles and
store the result at the end of the block
Memory OpLocation Code
C000
Mnemonics
Comments
LXI H, C030H
;Initialize the register pair HL
to memory location C030 H
C003
MOV A , M
C004
ANI , 0F H
;Copy the data content of
register pair HL to
accumulator
;AND immediately the data
0F H with the data content of
accumulator
;Store the separated lower
order nibble to register B
;Increment the memory
location of HL register pair
by 1
;Store the separated nibble
to register pair HL
;Decrement the memory
location of HL register pair
by 1
;Copy the data content of
register pair HL to
accumulator
;AND immediately the data
F0 H with the data content of
accumulator
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Rotate the data bit of
accumulator one bit position
C001
30
C002
C0
C005
Labels
0F
C006
MOV B , A
C007
INX H
C008
MOV M ,A
C009
DCX H
C00A
MOV A , M
C00B
ANI , F0 H
C00C
F0
C00D
RRC
C00E
RRC
C00F
RRC
C010
RRC
C011
INX H
C012
INX H
C013
MOV M , A
C014
XRA A
C015
:UP
C016
ADD M
DCR B
C017
JNZ
C018
15
C019
C0
UP :
C01A
INX H
C01B
MOV M ,A
C01C
RST 1
to right L.S.B will shift in
carry as well as in M.S.B
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Increment the memory
location of HL register pair
by 1
;Increment the memory
location of HL register pair
by 1
;Store the separated nibble
to register pair HL
;Clear the data content of
accumulator
;Add the data content of
register pair HL to
accumulator
;Decrement the data content
of register B by 1
;If counter 0(reg B 0 )
then jump to memory
location C015
;Increment the memory
location of HL register pair
by 1
;Store the result of
multiplication of the
separated nibble at the end of
block
;Stop the execution
OUTPUT :
Before Execution :
C030 = 32 H
After Execution :
A=
B=
F=
C031 =
C032 =
=
C033
F=
S Z X AC X P X CY
Q 13) Two numbers are stored in consecutive memory location starting from C040.
Write a program to subtract the numbers and store the absolute difference result in
the next memory location.
Memory Op- Labels
Location Code
C000
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
C003
MOV A , M
C004
INX H
C005
SUB M
;Copy the data content of
register pair HL to
accumulator
;Increment the memory
location of HL register pair
by 1
;Subtract the data content of
register pair HL with the
data content of accumulator
;If the result in accumulator
is positive then jump to
memory location C00B
C001
40
C002
C0
C006
JP
C007
0B
C008
C0
DOWN :
C009
CMA
C00A
INR A
C00B
:
DOWN
INX H
C00C
MOV M ,A
C00D
RST 1
;Compliment the data
content of accumulator
;Increment the data content
of accumulator by 1
;Increment the memory
location of HL register pair
by 1
;Copy the data content of
accumulator to register pair
HL
;Stop the execution
OUTPUT :
Case I :
Before Execution :
C040 = 09 H
C041 = 04 H
After Execution :
A=
F=
=
C042
F
S Z X AC X P X CY
Case II :
Before Execution :
C040 = 04 H
C041 = 09 H
After Execution :
A=
F=
=
C042
F
S Z X AC X P X CY
Q 14)Two numbers are stored in memory location starting from C040 . Write a
program to divide the two numbers and store the quotient and remainder in the
next consecutive memory locations.
Memory OpLocation Code
C000
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
MVI C , 00H
;Clear the data content of
register C
C005
MOV A , M
C006
INX H
;Copy the data content of
register pair HL to
accumulator
;Increment the memory
location of HL register pair
by 1
;Compare the data content of
HL pair with the data
content of accumulator
;If carry flag is set then jump
to memory location C010
C001
40
C002
C0
Labels
C003
C004
00
C007
:UP
C008
CMP M
JC DOWN :
C009
10
C00A
C0
C00B
SUB M
C00C
INR C
C00D
JMP UP:
C00E
07
C00F
C0
C010
:DOWN
INX H
C011
MOV M , C
C012
INX H
;Subtract the data content of
register pair HL from data
content of accumulator
;Increment the data content
of register C by 1
;Jump to memory location
C007
;Increment the memory
location of HL register pair
by 1
;Store the quotient in the
next memory location
;Increment the memory
location of HL register pair
by 1
C013
MOV M , A
C014
RST 1
OUTPUT :
Before Execution :
C040 = 09 H
C041 = 02 H
After Execution :
A=
C=
F=
C042 =
=
C043
F
S Z X AC X P X CY
;Store the remainder in the
next memory location
;Stop the execution
Q 15)A 4-byte number is stored in memory location starting from C040. Write a
program to find whether the given 4-bybe number is a palindrome or not . If it is a
palindrome then store 00 H in memory location C060 and if it is not a palindrome
then store FF H in memory location C060. For eg. Take the 4-byte number as
AB5005BA H
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
43
C005
C0
C006
C007
C008
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
LXI D, C043H
;Initialize the register pair
DE to memory location C043
H
MVI B , 02H
;Set the counter for 2
numbers in register B
LDAX D
;Load the data contents of
register pair DE to
accumulator
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Rotate the data bit of
accumulator one bit position
to right L.S.B will shift in
carry as well as in M.S.B
;Compare the data content of
register pair HL with data
content of accumulator
;If zero flag is set then jump
02
: UP
C009
RRC
C00A
RRC
C00B
RRC
C00C
RRC
C00D
CMP M
C00E
JZ NEXT:
C00F
19
C010
C0
to memory location C019
C011
C012
MVI A , FF H
;Load data FF H immediately
to accumulator
STA C060 H
;Store the data contents of
accumulator to memory
location C060
JMP END :
;Jump to memory location
C024
INX H
;Increment the memory
location of HL register pair
by 1
;Decrement the memory
location of DE register pair
by 1
;Decrement the data content
of register B by 1
;If counter 0(reg B 0 )
then jump to memory
location C008
FF
C013
C014
60
C015
C0
C016
C017
24
C018
C0
C019
:NEXT
C01A
DCX D
C01B
DCR B
C01C
JNZ UP :
C01D
08
C01E
C0
C01F
C020
;Load data FF H immediately
to accumulator
STA C060 H
;Store the data contents of
accumulator to memory
location C060
RST 1
;Stop the execution
00
C021
C022
60
C023
C0
C024
MVI A , 00 H
:END
OUTPUT :
Case I
Before Execution :
C040 =
C041 =
C042 =
C043 =
AB H
50 H
05 H
BA H
After Execution :
A=
B=
F=
=
C060
F
S Z X AC X P X CY
Case II
Before Execution :
C040 =
C041 =
C042 =
C043 =
AB H
50 H
55 H
BA H
After Execution :
A=
B=
F=
=
C060
F
S Z X AC X P X CY
Q 16) A 2-byte number is stored in memory location starting from C040 beginning
with lower order byte byte. Another 2- byte number is stored in memory location
starting from C050 beginning with lower order byte. Write a program to add these
two numbers and store the result in memory location starting from C060 beginning
with lower order byte.
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
C005
C006
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
LXI B, C050H
;Initialize the register pair
HL to memory location C050
H
LDAX B
;Load the data contents of
register pair BC to
accumulator
;Add the data contents of
register pair HL to
accumulator
;Store the data contents of
accumulator (Lower order
byte)to memory location
C060
;Increment the memory
location of HL register pair
by 1
;Increment the memory
location of BC register pair
by 1
;Load the data contents of
register pair BC to
accumulator
;Add the data contents of
register pair HL along with
carry to accumulator
;Store the data contents of
accumulator (Higher order
byte)to memory location
C061
;Stop the execution
50
C0
C007
ADD M
C008
STA C060
C009
60
C00A
C00B
CO
INX H
C00C
INX B
C00D
LDAX B
C00E
ADC M
C00F
STA C061
C010
61
C011
C012
C0
RST 1
OUTPUT :
Before Execution :
C040 = C9 H
C041 = AB H
After Execution :
A=
F=
C060 =
C061 =
F=
S Z X AC X P X CY
C050 = C2 H
C051 = FE H
Q 17) A 4-byte number is stored in memory location starting from C040 beginning
with lower order byte byte. Another 4- byte number is stored in memory location
starting from C050 beginning with lower order byte. Write a program to add these
two 4- byte numbers and store the result in memory location starting from C040
beginning with lower order byte.
Memory Op- Labels
Location Code
C000
C001
Mnemonics
Comments
XRA A
;Clear the data content of
accumulator
;Initialize the register pair
HL to memory location C040
H
LXI H, C040H
C002
40
C003
C0
C004
C005
C006
C007
50
C0
C008
04
C009
:UP
LXI B, C050H
;Initialize the register pair BC
to memory location C050 H
MVI D , 04 H
;Set the counter of 4
numbers to register D
LDAX B
;Load the data contents of
register pair BC to
accumulator
;Add the data contents of
register pair HL along with
carry to accumulator
;Copy the data contents of
accumulator to register pair
HL
;Increment the memory
location of HL register pair
by 1
;Increment the memory
location of BC register pair
by 1
;Decrement the data content
of register B by 1
;If counter 0(reg D 0 )
then jump to memory
location C009
C00A
ADC M
C00B
MOV M , A
C00C
INX H
C00D
INX B
C00E
DCR D
C00F
JNZ UP:
C010
09
C011
C012
C0
RST 1
;Stop the execution
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C9 H
AB H
FD H
FE H
C050 =
C051 =
C052 =
C053 =
After Execution :
A=
D=
F=
C040 =
C041 =
C042 =
C043 =
F=
S Z X AC X P X CY
C2 H
FF H
C9 H
FF H
Q 18) A block of data is stored in memory location starting from C041. Length of
data is stored in memory location C040. Write a program to add this numbers by
using DAD instruction. Store the two byte result at the end of the block
Memory Op- Labels
Location Code
C000
C001
40
C002
C0
C003
C004
00
C005
00
C006
C007
00
C008
00
C009
C00A
: UP
Mnemonics
Comments
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
LXI B, 0000H
;Initialize the register pair BC
to
0000 H
LXI D, 0000H
;Initialize the register pair
DE to
0000 H
MOV A ,M
;Copy the data contents of
register pair HL to
accumulator .
;Increment the memory
location of HL register pair
by 1
;Copy the data contents of
register pair HL to register C
.
;The content of register H are
exchanged with that of
register D and the content of
register L are exchanged
with that of register E
;The content of register pair
BC are added to the contents
of Hl pair. Result is placed in
register H and L
;The content of register H are
exchanged with that of
INX H
C00B
MOV C ,M
C00C
XCHG
C00D
DAD B
C00E
XCHG
C00F
DCR A
C010
JNZ
C011
0B
C012
C0
UP :
C013
INX H
C014
MOV M , E
C015
INX H
C016
MOV M , D
C017
RST 1
OUTPUT :
Case I : Before Execution :
C040 = 05 H
C041 = C9 H
C042 = AB H
C043 = FD H
C044 = FE H
C045 = C9 H
After Execution :
A=
F=
C046 =
C047 =
F=
S Z X AC X P X CY
register D and the content of
register L are exchanged
with that of register E
;Decrement the data content
of register A by 1
;If counter 0(reg A 0 )
then jump to memory
location C00B
;Increment the memory
location of HL register pair
by 1
;Copy the data contents of
register E to register pair HL
;Increment the memory
location of HL register pair
by 1
;Copy the data contents of
register Dto register pair HL
;Stop the execution
Q 19) A block of data is stored in memory location starting from C041. Length of
data is stored in memory location C040. Write a program to sort the content of the
block in ascending order.
Memory Op- Labels
Location Code
C000
:START
C001
Mnemonics
MVI B ,00 H
00
C002
Comments
Set the data content of
register to 00H
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
C005
MOV C, M
C006
INX H
C007
MOV A , M
C008
DCR C
;Copy the data contents of
register pair HL to register C
.
;Increment the memory
location of HL register pair
by 1
;Copy the data contents of
register pair HL to
accumulator .
;Decrement the data content
of register C by 1
(Decrement the counter by
1)
;Increment the memory
location of HL register pair
by 1
;Compare the data content of
register pair HL with data
content of accumulator
If Carry flag = 1then jump to
memory location C015.
C003
40
C004
C0
C009
: UP
INX H
C00A
CMP M
C00B
JC DOWN :
C00C
15
C00D
C0
C00E
MOV D , M
C00F
MOV M , A
C010
DCX H
; Copy the data contents of
register pair HL to register D
.
; Copy the data contents of
register pair HL to
accumulator .
;Decrement the memory
C011
MOV M , D
C012
INX H
C013
MVI B, 01 H
C014
01
C015
:
DOWN
C016
DCR C
JNZ
C017
09
C018
C0
C019
UP :
DCR B
C01A
JZ
C01B
00
C01C
C0
C01D
location of HL register pair
by 1
;Copy the data contents of
register D to register pair HL
;Increment the memory
location of HL register pair
by 1
START :
RST 1
;Decrement the data content
of register C by 1
(Decrement the counter by
1)
;If counter 0(reg C 0 )
then jump to memory
location C009
;Decrement the data content
of register B by 1
If Zero flag = 1 then jump to
memory location C000
;Stop the execution
OUTPUT :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
C045 =
05 H
04 H
03 H
02 H
05 H
01 H
After Execution :
A=
B=
F=
C041 =
C042 =
C043 =
C044 =
C045 =
F=
S Z X AC X P X CY
Q 20) A block of data is stored in memory location starting from C041. Length of
data is stored in memory location C040. Write a program to sort the content of the
block in descending order.
Memory Op- Labels
Location Code
C000
:START
C001
Mnemonics
MVI B ,00 H
00
C002
Comments
Set the data content of
register to 00H
LXI H, C040H
;Initialize the register pair
HL to memory location C040
H
C005
MOV C, M
C006
INX H
C007
MOV A , M
C008
DCR C
;Copy the data contents of
register pair HL to register C
.
;Increment the memory
location of HL register pair
by 1
;Copy the data contents of
register pair HL to
accumulator .
;Decrement the data content
of register C by 1
(Decrement the counter by
1)
;Increment the memory
location of HL register pair
by 1
;Compare the data content of
register pair HL with data
content of accumulator
If Carry flag 1then jump to
memory location C015
C003
40
C004
C0
C009
: UP
INX H
C00A
CMP M
C00B
JNC DOWN :
C00C
15
C00D
C0
C00E
MOV D , M
C00F
MOV M , A
C010
DCX H
;Copy the data contents of
register pair HL to register D
.
;Copy the data contents of
register pair HL to
accumulator .
;Decrement the memory
C011
MOV M , D
C012
INX H
C013
MVI B, 01 H
C014
01
C015
:
DOWN
C016
DCR C
JNZ
C017
09
C018
C0
C019
UP :
DCR B
C01A
JZ
C01B
00
C01C
C0
C01D
location of HL register pair
by 1
;Copy the data contents of
register D to register pair HL
;Increment the memory
location of HL register pair
by 1
START :
RST 1
;Decrement the data content
of register C by 1
(Decrement the counter by
1)
;If counter 0(reg C 0 )
then jump to memory
location C009
;Decrement the data content
of register B by 1
If Zero flag = 1 then jump to
memory location C000
;Stop the execution
Output :
Before Execution :
C040 =
C041 =
C042 =
C043 =
C044 =
C045 =
05 H
04 H
03 H
02 H
05 H
01 H
After Execution :
A=
B=
F=
C041 =
C042 =
C043 =
C044 =
C045 =
F=
S Z X AC X P X CY