Thursday, March 26, 2015

Program To Find Factorial Of any no ~ Assembly language

include irvine32.inc

.data
msg byte "Please enter a number: ",0,13h,10h
num dword ?
fact dword 1

.code
main proc
call clrscr
call crlf
mov edx,offset msg
call writestring
call readint
mov num,eax
mov ecx,num
mov ebx,1

D2:
mov eax,fact
mul ebx
mov fact,eax
inc ebx
loop D2

call crlf
mov eax,fact
call writeint
exit
main endp
end main

Find No is Prime or Consonant ~ Assembly Language

include irvine32.inc
.data
msg1 byte "Plese Enter the No to Find its Prime or not :",0,13h,10h
msg2 byte "No is Prime",0,13h,10h
msg3 byte "No is Consunant",0,13h,10h
num dword ?
loop1 dword ?
result dword ?
.code
main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call readint
mov num,eax

mov loop1,eax
sub loop1,2
mov eax,loop1
mov ecx,eax
mov ebx,2

L1:
mov eax,num
mov edx,0
div ebx
mov result,edx

cmp result,0
je b
jne next
next:
inc ebx
loop L1

call crlf
mov edx,offset msg2
call writestring
jmp s
b:
call crlf
mov edx,offset msg3
call writestring
s:
exit
main endp
end main


Program To Find No is Even or Odd ~ Assembly Language

include irvine32.inc
.data
msg byte "Plese enter a no : ",0,13h,10h
msg1 byte "NO is Even ",0,13h,10h
msg2 byte "No is Odd ",0,13h,10h
num word ?
result word ?
.code
main proc
call clrscr
call crlf
mov edx,offset msg
call writestring
call readint
mov num,ax
mov bx,2
mov ax,num
mov dx,0
div bx
mov result,dx
cmp result,0
JE E
JNE O

E:
call crlf
mov edx,offset msg1
call writestring
jmp stop
O:
call crlf
mov edx,offset msg2
call writestring

stop:
exit
main endp
end main


Sunday, March 22, 2015

C++ Program to print Hexagonal Shape

#include<iostream.h>
#include<conio.h>
void main()
{   int d=0,b=0;
clrscr();
for(int i=9;i<=19;i++){
gotoxy(i,12);
cout<<char(2);
}
for(int j=9;j<=19;j++){
gotoxy(j,26);
cout<<char(2);
}
d=9;
for( b=8;b<=14;b++){
d=d-1;
gotoxy(d,b+5);
cout<<char(2);
} d=19;
for( b=18;b<=24;b++){
d=d+1;
gotoxy(d,b-5);
cout<<char(2);
} d=9;
for( b=20;b>=14;b--){
d=d-1;
gotoxy(d,b+5);
cout<<char(2);
}d=27;
for( b=14;b<=20;b++){
d=d-1;
gotoxy(d,b+5);
cout<<char(2);
}
cout<<"\n\n\n\n Who's it is :) . . . .";
getch();}


Binary Search ~ Program to search a value from array using Binary search

#include<iostream.h>
#include<conio.h>

void binary_search(int *A,int value,int s,int e);

void display(int *arr,int count)
{
for(int i=0;i<count;i++)
{ cout<<arr[i]<<"\t";}
}
void binary_search(int *A,int value,int s,int e)
{
int mid=0;
mid=(s+e)/2;
if(value==A[mid])
{ cout<<"\nValue found\n"; }
else if(value>A[mid])
{ s=mid+1;
 binary_search(A,value,s,e);
}
else if(value<A[mid])
{
e=mid-1;
binary_search(A,value,s,e);
}
else
{ cout<<"not found";}
}

void main()
{
clrscr();
int A[]={5,4,9,7,8,1,3,2,6},value=0;
cout<<"\nEnter Value You Want to Search: ";
cin>>value;
binary_search(A,value,0,9);
cout<<"\n\nArray is following:\n";
display(A,9);

getch();
}


Saturday, March 21, 2015

Program To Print Table of Any Number :: Assembly Language

Read Also:  

include irvine32.inc

.data
result dword ?
num dword ?
msg byte "Enter number You Want To Print Table",0,13h,10h
msg1 byte " * ",0
msg2 byte " = ",0

.code
main proc
call clrscr
call crlf
mov edx,offset msg
call writestring
call crlf
call readint
mov num,eax
mov ecx,10
mov ebx,1
L1:
mov eax,num
call writeint
mul ebx
mov edx,offset msg1
call writestring
mov result,eax
mov eax,ebx
call writeint
mov edx,offset msg2
call writestring
mov eax,result
call writeint
call crlf
inc ebx
loop L1
exit
main endp
end main




Saturday, March 14, 2015

How To Program In Assembly Language

As we Know Assembly Language is a Low Level language ...
 So Their is a Compiler IDE for almost every programming language so for assembly we use Masm615 to compile over assembly code .

Download MASAM615 :: :: Click Here-

Download masm615 from above link and extract it in any where in your PC Disk drives..
 How to Extract: 
Move that .Rar file to any disk or folder then Right Click on it and Chose Extract Files like

then open notepad and write your code in it like


and Save As it with extension of .asm 

Complete code of Hello World in Assembly  

Then save that Notepad file in Your Masm615 Folder
 Now How To Compile it:
Open cmd (Command Prompt )


it whould be like it

so if you save masm615 in Your C: Disk then For go back to C:
just Type CD \


then it will go back to C:
if you save Your Masm in other disk simple type Disk Name with Colon like D: , E: 


now to open Masm615 simple type cd masm615


Now type make32 and the name of notepad file

like: make32 hello

and press ENTER


if their is no error in your code it will compile successfully and show cmd like this then again press Enter 


and type again the name of your note pad file



and that's it your output is here in the cmd


Small review :
C:\Document and setting\ugd>
C:\Document and setting\ugd>cd \
C:\>cd masm615
C:\masm615>
C:\masm615>make32 hello
.
.
.
Press any key to continue [Enter]
C:\masm615>hello


OUTPUT ON THE TOP OF CMD SCREEN

IMPORTANT PROGRAMS IN ASSEMBLY LANGUAGE

Thursday, March 12, 2015

Simple Calculator Program in Assembly Language

Read Also:  


This Program have Option of addition, subtraction, multiplication, division
it will get values from user and then show the result using cmd
-----------------------------

include irvine32.inc

.data
line   byte    "  This is a Simple Calculator in Assembly  ",0,13h,10h
line1  byte    "  Chosee Operation:  '+'   '-'  '/'  '*'   ",0,13h,10h
line11       byte    "   Addition:      '+'        ",0,13h,10h
line12       byte    "  Subtraction:    '-'  ",0,13h,10h
line13       byte    "  Multiplication: '*'  ",0,13h,10h
line14       byte    "  Division:       '/'  ",0,13h,10h
line15       byte    "  Repete:         'R'  ",0,13h,10h
line16       byte    "  Exit:           'E'  ",0,13h,10h

line2  byte    "  Addition:         ",0,13h,10h
line3  byte    "  Subtraction:      ",0,13h,10h
line4  byte    "  Multiplication:   ",0,13h,10h
line5  byte    "  Division:         ",0,13h,10h

msg   byte   " Enter First Integer:  ",0,13h,10h
msg1  byte   " Enter second Integer: ",0,13h,10h

put  byte   " Result is Equal to = ",0
put1  byte   " First No  is:  ",0
put2 byte   " Second No is:  ",0

num1 word ?
num2 word ?

button byte ?

.code
main PROC
call clrscr
mov edx,offset line
call writestring
call crlf

start:
call crlf
mov edx,offset line1
call writestring
call crlf
mov edx,offset line11
call writestring
call crlf
mov edx,offset line12
call writestring
call crlf
mov edx,offset line13
call writestring
call crlf
mov edx,offset line14
call writestring
call crlf
mov edx,offset line15
call writestring
call crlf
mov edx,offset line16
call writestring
call crlf
call crlf

mov edx,offset button
call readchar
mov button,al

cmp button,'+'
JE addition

cmp button,'-'
JE subtraction

cmp button,'*'
JE multiplication

cmp button,'/'
JE division

cmp button,'r'
JE start
JNE stop

addition:
mov edx,offset line2
call writestring
call crlf
mov edx,offset msg ;Read first no
call writestring
call readint
mov num1,ax

mov edx,offset msg1 ;read 2nd no
call writestring
call readint
mov num2,ax

mov edx,offset put1 ;display both no
call writestring
mov ax,num1
call writeint
call crlf
mov edx,offset put2
call writestring
mov ax,num2
call writeint
call crlf
call crlf
mov edx,offset put
call writestring
mov ax,num1
add ax,num2
call writeint
call crlf

Jmp start

subtraction:
mov edx,offset line3
call writestring
call crlf
mov edx,offset msg ;Read first no
call writestring
call readint
mov num1,ax

mov edx,offset msg1 ;read 2nd no
call writestring
call readint
mov num2,ax

mov edx,offset put1 ;display both no
call writestring
mov ax,num1
call writeint
call crlf
mov edx,offset put2
call writestring
mov ax,num2
call writeint
call crlf
call crlf
mov edx,offset put
call writestring
mov ax,num2
sub ax,num1
call writeint
call crlf

JMP start

multiplication:
mov edx,offset line4
call writestring
call crlf
mov edx,offset msg ;Read first no
call writestring
call readint
mov num1,ax

mov edx,offset msg1 ;read 2nd no
call writestring
call readint
mov num2,ax

mov edx,offset put1 ;display both no
call writestring
mov ax,num1
call writeint
call crlf
mov edx,offset put2
call writestring
mov ax,num2
call writeint
call crlf
call crlf
mov edx,offset put
call writestring
mov ax,num1
mov bx,num2
mul bx
call writeint
call crlf

JMP start

division:
mov edx,offset line5
call writestring
call crlf
mov edx,offset msg ;Read first no
call writestring
call readint
mov num1,ax

mov edx,offset msg1 ;read 2nd no
call writestring
call readint
mov num2,ax

mov edx,offset put1 ;display both no
call writestring
mov ax,num1
call writeint
call crlf
mov edx,offset put2
call writestring
mov ax,num2
call writeint
call crlf
call crlf
mov edx,offset put
call writestring
mov ax,num1
mov bx,num2
mov dx,0
div bx
call writeint
call crlf

JMP start
stop:
exit
main endp
end main





















Assembly Program to Divide 2 Integers

include irvine32.inc
.data
msg  byte " This Program will Divide 2 Integer numbers: ",0,13h,10h
msg2 byte " First No is  =  ",0
msg3 byte " Second No is =  ",0
msg4 byte " Result is equal to  =  ",0
num1 word 10
num2 word 5

.code
main proc
call clrscr
mov edx,offset msg
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
mov ax,num1
call writeint
call crlf

mov edx,offset msg3
call writestring
mov ax,num2
call writeint
call crlf

call crlf
mov edx,offset msg4
call writestring
mov ax,num1
mov bx,num2
mov dx,0
div bx
call writeint
call crlf

exit
main endp
end main


Assembly Program to Multiply 2 integers

include irvine32.inc
.data
msg  byte " This Program will Multiply 2 Integer numbers: ",0,13h,10h
msg2 byte " First No is  =  ",0
msg3 byte " Second No is =  ",0
msg4 byte " Result is equal to  =  ",0
num1 word 18
num2 word 20

.code
main proc
call clrscr
mov edx,offset msg
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
mov ax,num1
call writeint
call crlf

mov edx,offset msg3
call writestring
mov ax,num2
call writeint
call crlf

call crlf
mov edx,offset msg4
call writestring
mov ax,num1
mov bx,num2
mul bx
call writeint
call crlf

exit
main endp
end main

Assembly Program to Subtract two integers

include irvine32.inc
.data
msg  byte " This Program Subtract 2 Integer numbers: ",0,13h,10h
msg2 byte " First No is  =  ",0
msg3 byte " Second No is =  ",0
msg4 byte " Result is equal to  =  ",0
num1 word 110
num2 word 20

.code
main proc
call clrscr
mov edx,offset msg
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
mov ax,num1
call writeint
call crlf

mov edx,offset msg3
call writestring
mov ax,num2
call writeint
call crlf

call crlf
mov edx,offset msg4
call writestring
mov ax,num1
sub ax,num2
call writeint
call crlf

exit
main endp
end main


Assembly Program to add two Integers

include irvine32.inc

.data
msg  byte " This Program Add 2 Integer numbers: ",0,13h,10h
msg2 byte " First No is  =  ",0
msg3 byte " Second No is =  ",0
msg4 byte " Sum is equal to  =  ",0
num1 word 10
num2 word 20

.code                                     ;;;code start from here
main proc
call clrscr
mov edx,offset msg
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
mov ax,num1
call writeint
call crlf

mov edx,offset msg3
call writestring
mov ax,num2
call writeint
call crlf

call crlf
mov edx,offset msg4
call writestring
mov ax,num1
add ax,num2
call writeint
call crlf

exit
main endp
end main


Monday, March 9, 2015