Saturday 20 October 2012

Accept n numbers through one program send it to the server program check their for prime numbers send only the prime numbers to client-Java Socket program

tcpserver1.java

import java.io.*;
import java.net.*;
class tcpserver1
{
public static void main(String args[])throws Exception
{
ServerSocket ss = new ServerSocket(6856);
Socket cs=ss.accept();
BufferedReader br = new BufferedReader(new InputStreamReader(cs.getInputStream()));
PrintStream ps = new PrintStream(cs.getOutputStream());
int[] a=new int[15];
int[] b= new int [15];
int k=0,n,i,j,f=0;
n=Integer.parseInt(br.readLine());
for(i=0;i<n;i++)
a[i]=Integer.parseInt(br.readLine());
for(i=0;i<n;i++)
{
for(j=2;j<a[i];j++)
{
if(a[i]%j==0)
{
f=1;
break;
}
}
if(f==0)
{
if(a[i]!=1)
{
b[k]=a[i];
k++;
}
}
f=0;
}
ps.println(k);
for(i=0;i<k;i++)
ps.println(b[i]);

}
}

tcpclient1.java

import java.io.*;
import java.net.*;
class tcpclient1
{
public static void main(String args[])throws Exception
{
Socket cs = new Socket("localhost",6856);

BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
BufferedReader br = new BufferedReader(new InputStreamReader(cs.getInputStream()));
PrintStream ps = new PrintStream(cs.getOutputStream());
int[] a=new int[15];
int[] b= new int [15];
int k,n,i;
System.out.println("Enter the limit");
n=Integer.parseInt(kb.readLine());
ps.println(n);
System.out.println("Enter the Numbers");
for(i=0;i<n;i++)
a[i]=Integer.parseInt(kb.readLine());
for(i=0;i<n;i++)
ps.println(a[i]);
k=Integer.parseInt(br.readLine());
for(i=0;i<k;i++)
b[i]=Integer.parseInt(br.readLine());
System.out.println("Prime nos\n");
for(i=0;i<k;i++)
System.out.println(b[i]);

}
}

Communication between two unrelated process using messege queue

MSGQ1.c 

#include<stdio.h>
#include<sys/msg.h>
#include<string.h>
#include<stdlib.h>
struct msgbuf
{
long mtype;
char mtext[30];
}ptr;
int main()
{
int i=0;
int id=msgget(52,0666|IPC_CREAT);
if(id>=0)
printf("Msg Q created sucessfully\n");
else
printf("Not created\n");
printf("Enter the msg type:\n");
scanf("%ld",&(ptr.mtype));

printf("Enter the msg\n");
scanf("%s",ptr.mtext);
int p=msgsnd(id,&ptr,(sizeof(ptr.mtext)),0);
if(p>=0)
printf("Msg send sucessfully\n");
else
printf("Msg not send\n");
}




MSGQ2.C



#include<stdio.h>
#include<sys/msg.h>
struct msgbuf
{
long mtype;
char mtext[30];
}ptr;
int main()
{

int id=msgget(52,0666|IPC_CREAT);
if(id>=0)
printf("Success\n");
printf("Enter the msgtype\n");
scanf("%ld",&ptr.mtype);

int p=msgrcv(id,&ptr,30,(ptr.mtype),0);
if(p>=0)
{
printf("Msg read sucessfully\n");
printf("Msg is:%s\n",ptr.mtext);
}
else
printf("Error\n");
}


Sample output


msgq1.c

Enter the msg type:
2
Enter the msg
kkk
Msg send sucessfully


msgq2.c

Success
Enter the msgtype
2
Msg read sucessfully
Msg is:kkk





Sunday 7 October 2012

Udp Client-Server Communication using java

UDP Client

import java.io.*;
import java.net.*;
class udpclient {
    public static void main(String args[])throws Exception
    {
       
        DatagramSocket cs = new DatagramSocket(2568);
        InetAddress ip = InetAddress.getByName("localhost");
        byte[] sD = new byte[1024];
        byte[] rD = new byte[1024];
 String sen;
        while(true)
        {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       sen= br.readLine();
      
       
        sD=sen.getBytes();
        DatagramPacket sPkt = new DatagramPacket(sD,sD.length,ip,6800);
        cs.send(sPkt);
        DatagramPacket rPkt = new DatagramPacket(rD,rD.length);
        cs.receive(rPkt);
        String str= new String(rPkt.getData());
        System.out.println("From Server:\n"+str);
        }
       
    }
   
}

UDP Server

import java.io.*;
import java.net.*;
class udpserver {
    public static void main(String args[])throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        DatagramSocket cs = new DatagramSocket(6800);
       
        byte[] sD = new byte[1024];
        byte[] rD = new byte[1024];
        while(true)
        {
          DatagramPacket rPkt = new DatagramPacket(rD,rD.length);
        cs.receive(rPkt);
        String str= new String(rPkt.getData());
        System.out.println("From Client:\n"+str);
InetAddress ip = rPkt.getAddress();
int port = rPkt.getPort();  
        String sen= br.readLine();
       
       
        sD=sen.getBytes();
        DatagramPacket sPkt = new DatagramPacket(sD,sD.length,ip,port);
        cs.send(sPkt);
      
        }
       
    }
   
}

Tcp client server communication using Java

TCP Client



import java.io.*;
import java.net.*;
 class tcpclient {
    public static void main(String args[])throws Exception
    {
        Socket s = new Socket("localhost",6700);
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        PrintStream ps2 = new PrintStream(s.getOutputStream());
        BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
        String str1,str2;
        while(true)
        {

            str1=kb.readLine();
            ps2.println(str1+"\n");
            str2=br.readLine();
            System.out.println(str2);
           
        }

       
    }
   
}

TCP Server


import java.io.*;
import java.net.*;
import java.lang.*;
class tcpserver {
    public static void main(String args[])throws Exception
    {
        ServerSocket ss = new ServerSocket(6700);
        Socket s = ss.accept();
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
        PrintStream ps = new PrintStream(s.getOutputStream());

        String str1,str2;
        while(true)
        {
            str1=kb.readLine();
           
               ps.println(str1);
          str2=br.readLine();
                System.out.println(str2+"\n");
               
               
           
        }
       
       
       
       
    }
   
}

Two unrelated programs uses shared memory

First program


#include<stdio.h>
#include<sys/shm.h>
#include<string.h>
int main()
{

int id=shmget(17,50,0666|IPC_CREAT);


if(id>=0)
{
printf("\nShared memory created with id:%d\n",id);
}
char *adr=shmat(id,NULL,0);
if(adr>=0)
printf("Memory attached\n");
printf("Enter a string\n");
char str[10];

scanf("%s",str);
strncpy(adr,str,sizeof(str));



}



Second program

#include<stdio.h>
#include<sys/shm.h>
#include<string.h>
int main()
{

int id=shmget(17,0,0666|IPC_CREAT);
char str[10];

if(id>=0)
{
printf("\nShared memory with id:%d\n is accessed",id);
}
char *adr=shmat(id,NULL,0);
if(adr>=0)
printf("\nMemory attached\n");
printf("\nThe string is\n%s",adr);
}


Sample output:

cc first.c
./a.out

Shared memory created with id:360454
Memory attached
Enter a string
Hello

cc second.c
./a.out

Shared memory with id:360454
 is accessed
Memory attached

The string is
hello


Saturday 19 May 2012

Make bootable pendrive for ubuntu(in windows platform)


It is very easy.
First download Universal-USB-Installer.
Just fix the locations of pendrive and ISO image.
Click create button.
That's it.

Download Universal- USB-Installer from here
                                                                            

Thursday 17 May 2012

A method to make one click buttons in php

Here is a method to make buttons which will disabled automatically after click. This is useful when you dealing with php scripts.There also other methods for this. Here is only the logic not complete code.

<?php
mysql_select_db("sample", $p);
$z1=$z2=0;
$r=mysql_query("SELECT * FROM sampletable");

while($rows=mysql_fetch_array($r))
{
$take=$rows['samples2'];


if($take=='a1')
$z1=1;
if($take=='a2')
$z2=1;
}

if($z1==1)
echo "<input type='submit' value='a1'  name='opt' disabled >";
else
echo "<input type='submit' value='a1'  name='opt' >";




if($z2==1)
echo "<input type='submit' value='a2'  name='opt' disabled >";
else
echo "<input type='submit' value='a2'  name='opt'>";


mysql_close($p);

?>







Validation of name fields using javascipt

The following code can be used for validating name like fields.(Useful when dealing with html forms)

This code uses two built in functions
1)charAt()
2) indexOf()

charAt()- Returns the character at the specified index in a string.

Ex: charAt(5)-->  character at 6th position(Starting with 0)

indexOf() - Returns the position of the first occurrence of a specified value in a string and return -1  if  not found.


Bellow code has a variable not_needed. You can simply specify the unwanted character inside the double quotes.


<script type="text/javascript">

function validate()
{
var not_needed = "!@#$%^&*()+=-[]\\\';,./{}|\":<>? 1234567890";


if(document.myform.name1.value =="")
{
alert("Invalid name");
return false;
}

for (var i = 0; i < document.myform.name1.value.length; i++)
{
  if (not_needed.indexOf(document.myform.name1.value.charAt(i)) != -1)
 {
  alert ("Invalid name");
  return false;
  }
}
}
</script>
Form

<form action="sample.php" name="myform" method="post" onsubmit="return validate()">
Name:  <input type="TEXT" name="name1">



Wednesday 2 May 2012

Sorting of matrix elements-C++ program


#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
    int a[20][20],n,b[20],m,i,j,k=0,t;
    cout<<"Enter the order\n";
    cin>>m>>n;
    cout<<"Enter the elements\n";
    for(i=0;i<m;i++)
    {
    for(j=0;j<n;j++)
    {
    cin>>a[i][j];
    b[k++]=a[i][j];
     }
     }
     for(i=0;i<(m*n);i++)
     {
     t=b[i];
     j=i;
     while(j>0 && b[j-1]>=t)
     {
               b[j]=b[j-1];
               j--;
               }
               b[j]=t;
               }
             
               cout<<"\n";
               cout<<"Before sorting\n";
               for(i=0;i<m;i++)
    {
    for(j=0;j<n;j++)
   
    cout<<a[i][j]<<"\t";
    cout<<"\n";
}
               cout<<"After sorting\n";
               k=0;
    for(i=0;i<m;i++)
   
    for(j=0;j<n;j++)
   
    a[i][j]=b[k++];
   
   
    for(i=0;i<m;i++)
    {
    for(j=0;j<n;j++)
   
    cout<<a[i][j]<<"\t";

cout<<"\n";
}

    getch();
}





Sample Output
Enter the order
 3 3
9
8
7
4
5
2
1
3
6
Before sorting
9   8   7
4   5   2
1   3   6
After sorting
1   2   3
4   5   6
7   8   9



No third variables and pointers-C++ swapping program


#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
    int a,b;
    cout<<"Enter two number:\t";
    cin>>a>>b;
    cout<<"\nBefore swapping:\t";
    cout<<a<<"\t"<<b;
   
    a=a+b;
    b=a-b;
    a=a-b;
    cout<<"\nAfter swapping:\t";
    cout<<"\t"<<a<<"\t"<<b;
    getch();
}

Monday 30 April 2012

Undo send mails-Eazy trick


                                                                           

Yes it is possible to undo our send mails.But with in seconds. Gmail provides this simple facility.
By default this facility is disabled. You should enable this.
For enable:
Go to Gmail Settings-->Labs

Enable Undo Send.

After this an Undo link will appear.(After mail sending)
But appears for certain seconds only.


Wednesday 7 March 2012

Masm program to check a given year is leap year or not


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro nu
mov dl,nu
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov bl,100
div bl
mov dh,ah
aam
mov bl,al
printnum ah
printnum bl
mov al,dh
aam
mov bl,al
printnum ah
printnum bl

endm

data segment
n db,0000
n1 db ,0000
msg1 db 0ah,0dh,"Enter a year$"
msg2 db 0ah,0dh,"Leap year$"
msg3 db 0ah,0dh,"Not leap year$"
msg4 db 0ah,0dh,"$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

printmsg msg1
mov ah,01h
int 21h
sub al,30h
mov ah,00
mov cx,1000
mul cx
mov n,ax

mov ah,01h
int 21h
sub al,30h
mov ah,00
mov cx,100
mul cx
add ax,n
mov n,ax

mov ah,01h
int 21h
sub al,30h
mov ah,00
mov cl,10
mul cl
add ax,n
mov n,ax

mov ah,01h
int 21h
sub al,30h
mov ah,00
add ax,n
mov n,ax

mov cx,0004
mov dx,0000
mov ax,n
div cx

cmp dx,0000
je t1
jmp t3
t1:
mov cx,0100
mov dx,0000
mov ax,n
div cx

cmp dx,0000
jne t2
jmp t3
t2:
printmsg msg2
jmp st1
t3:
mov ax,n
mov bx,400
div bx
cmp dx,0000
je t2

printmsg msg3



st1:
mov ah,4ch
int 21h
code ends
end start

Monday 6 February 2012

Masm program to sort n numbers


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov dh,100
div dh
mov n,ah
aam
mov dh,al
printnum ah
printnum dh
mov al,n
aam
mov dh,al
printnum ah
printnum dh
endm


data segment
num db 0
array db 50 dup(0)
n db 0



cr equ 0dh
msg0 db "Enter a limit(Ex:05)$"
msg1 db "Enter the nos(Ex:06)$"
msg2 db 0ah,0dh,"After sorting$"
msg4 db 0ah,"$"
msg5 db 0ah,0dh,"Before sorting$"
data ends

code segment
assume cs:code,ds:data

start:
mov ax,data
mov ds,ax
mov cl,00
printmsg msg0
mov ah,01h
int 21h
sub al,30h
mov n,al
mov ah,00
mov dh,10
mul dh
mov n,ax
mov ah,01h
int 21h
sub al,30h
mov ah,00
add ax,n

mov cl,ax
mov num,cl
printmsg msg4
printmsg msg1
lea si,array
l1:

mov ah,01h
int 21h
sub al,30h
mov ah,00
mov ch,10
mul ch
mov n,ax
mov ah,01h
int 21h
sub al,30h
mov ah,00
add ax,n
mov [si],ax

inc si
dec cl
printmsg msg4
cmp cl,00
jne l1



printmsg msg4
mov cl,num
mov ch,00
printmsg msg5
printmsg msg5
lea si,array
t1:
printmsg msg4
cmp cl,ch
je t2

mov ah,00
mov al,[si]
calcnum ax

inc ch
inc si
jmp t1
t2:
printmsg msg4
mov cl,num
mov bh,00
mov bl,00
mov dl,num
dec dl
lea si,array
i1:

cmp bh,cl
je stop
mov di,si
inc di
mov bl,bh
inc bl
j1:
cmp bl,cl
je jstop
mov ch,[si]
cmp ch,[di]
jc k1
xchg ch,[di]
mov [si],ch
k1:
inc bl
inc di
jmp j1
jstop:
inc si
inc bh
jmp i1
stop:


mov cl,num
lea si,array
printmsg msg4
printmsg msg2
q1:
printmsg msg4
mov ah,00
mov al,[si]
calcnum ax
dec cl
inc si
cmp cl,00
jne q1
mov ah,4ch
int 21h
code ends
end start




Count number of words in a sentence-Masm program


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

data segment

str db 40 dup(0)

cr equ 0dh
lf equ 0ah
msg1 db "Enter a string:$"
msg4 db 0ah,0dh,"$"
msg5 db 0ah,0dh,"No: of words$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,str
mov cl,00

printmsg msg1
printmsg msg4
mov ch,'$'
mov [si],ch
l1:
mov ah,01h
int 21h
cmp al,32
je v1
jmp v2
v1:inc cl
jmp v2
v2:cmp al,cr
je p3
sub al,30h
mov [si],al
inc si
mov [si],ch
jmp l1

p3:
mov si,offset str
mov ch,[si]
cmp ch,'$'
je d1
inc cl
jmp d2
d1:mov cl,00



d2:printmsg msg4
printmsg msg5
printmsg msg4
printnum cl




mov ah,4ch
int 21h
code ends
end start



Friday 3 February 2012

Masm program-Palindrome checking


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm


data segment
n db 0
array db 40 dup(0)
revarray db 40 dup(0)
cr equ 0dh
msg1 db "Enter a string:$"
msg2 db 0ah,0dh,"Palindrome$"
msg3 db 0ah,0dh,"Not Palindrome$"

msg4 db 0ah,0dh,"$"
msg5 db 0ah,0dh,"Reversed string$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,array
mov cl,00
printmsg msg1
printmsg msg4
l1:
mov ah,01h
int 21h
cmp al,cr
je p2
sub al,30h
mov [si],al
inc si
inc cl
jmp l1
p2:
mov n,cl
mov ch,'$'
mov [si],ch




printmsg msg4
dec si
lea di,revarray
x2:
mov al,[si]
mov [di],al
inc di
dec si
dec cl

cmp cl,00
jne x2
mov cl,'$'
mov [di],cl
lea di,revarray
printmsg msg4
printmsg msg5
printmsg msg4
y2:

mov dl,[di]
add dl,30h
mov ah,02h
int 21h
inc di

mov ch,[di]
cmp ch,'$'
jne y2
printmsg msg4

mov si,offset array
mov di,offset revarray
mov cl,n
w2:
mov al,[si]
cmp al,[di]
jne w1
inc si
inc di
dec cl
cmp cl,00
jne w2

printmsg msg2
jmp w4
w1:
printmsg msg3

w4:mov ah,4ch
int 21h
code ends
end start



Binary to Hexadecimal converter-Masm program


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov dh,100
div dh
mov num,ah
aam
mov dh,al
printnum ah
printnum dh
mov al,num
aam
mov dh,al
printnum ah
printnum dh
endm

multiply macro num1
mov ax,0001
mov dh,02
mov dl,00
l10:
cmp dl,num1
jz l9
mul dh
inc dl
jmp l10
l9:
endm

data segment
num dw ?
num1 db 0

array db 10 dup(0)

cr equ 0dh
msg1 db "Enter a binary number$"
msg2 db 0ah,0dh,"Hex Equivalant$"
a db "A$"
b db "B$"
c db "C$"
d db "D$"
e db "E$"
f db "F$"
msg4 db 0ah,"$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov cl,00


printmsg msg1
lea si,array
mov bx,si

printmsg msg4

l2:mov ah,01h
int 21h
cmp al,cr
je l1
sub al,30h
mov [si],al
inc si
inc cl
jmp l2

l1:
printmsg msg2
mov bx,0000
mov si,offset array

l5:

cmp cl,00
jne l6
jmp l7
l6:

multiply cl
mov dh,[si]
mul dh
add bx,ax
inc si
dec cl
jmp l5

l7:
printmsg msg4

mov ax,bx

mov dh,02
 div dh
mov ah,00

mov cl,00
mov si,offset array
mov dh,16
p1:

div dh

mov [si],ah
inc si
inc cl
cmp al,00
je p2
mov ah,00
jmp p1
p2:
dec si

b1:
mov al,[si]
cmp al,10
je a1
jmp a2
a1:
printmsg a
dec si
dec cl
r4:cmp cl,00
jne b1

jmp t1

a2:cmp al,11
je c1
jmp a3
c1:
printmsg b
dec si
dec cl
r3:cmp cl,00
jne r4

jmp t1

a3:cmp al,12
je c2
jmp a4
c2:printmsg c
dec si
dec cl
r2:cmp cl,00
jne r3

jmp t1

a4:
cmp al,13
je c3
jmp a5
c3:printmsg d
dec si
dec cl
r1:cmp cl,00
jne r2

jmp t1

a5:cmp al,14
je c4
jmp a6
c4:printmsg e
dec si
dec cl
z2:cmp cl,00
jne r1

jmp t1

a6:cmp al,15
je c5
jmp a7
c5:printmsg f
dec si
dec cl
z1:cmp cl,00
jne z2

jmp t1

a7:
printnum al
dec si
dec cl
cmp cl,00
jne z1



jmp t1

t1:mov ah,4ch
int 21h
code ends
end start






Binary to Decimal converter- Masm program


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov dh,100
div dh
mov num,ah
aam
mov dh,al
printnum ah
printnum dh
mov al,num
aam
mov dh,al
printnum ah
printnum dh
endm

multiply macro num1
mov ax,0001
mov dh,02
mov dl,00
l10:
cmp dl,num1
jz l9
mul dh
inc dl
jmp l10
l9:
endm

data segment
num dw ?
num1 db 0

array db 10 dup(0)

cr equ 0dh
msg1 db "Enter a binary number$"
msg2 db 0ah,0dh,"Decimal Equivalant$"

msg4 db 0ah,"$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov cl,00


printmsg msg1
lea si,array
mov bx,si

printmsg msg4

l2:mov ah,01h
int 21h
cmp al,cr
je l1
sub al,30h
mov [si],al
inc si
inc cl
jmp l2

l1:mov bx,0000
mov si,offset array

l5:

cmp cl,00
jne l6
jmp l7
l6:

multiply cl
mov dh,[si]
mul dh
add bx,ax
inc si
dec cl
jmp l5

l7:
printmsg msg4
printmsg msg2

printmsg msg4
mov ax,bx
mov dh,02
 div dh
mov ah,00
calcnum ax

mov ah,4ch
int 21h
code ends
end start






Thursday 2 February 2012

Fibonacci series-Masm program


printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov dh,100
div dh
mov num,ah
aam
mov dh,al
printnum ah
printnum dh
mov al,num
aam
mov dh,al
printnum ah
printnum dh
endm


data segment
num dw 0
a dw 0000
b dw ?

regx dw ?
msg1 db "Enter a non zero limit(Ex: 05)$"
msg2 db 0ah,0dh,"Fibnocci series $"
msg3 db 0ah,"$"
msg5 db 0ah,0dh,"Try again$"
data ends

code segment
assume cs:code,ds:data

start:
mov ax,data
mov ds,ax
printmsg msg1
mov ah,01h
int 21h
sub al,30h
mov ah,00
mov dh,10
mul dh
mov num,ax
mov ah,01h
int 21h
sub al,30h
mov ah,00
add ax,num


mov cx,ax
cmp cx,0000
je p1
jmp p2
p1:
printmsg msg5
mov ah,4ch
int 21h
jmp l5
p2:cmp cx,0001
je l9
jmp l7
l9:
printmsg msg3
printmsg msg2
calcnum a
mov ah,4ch
int 21h
jmp l5



l7:
mov bx,0001
cmp cx,0002
je l6
jmp l4
l6:printmsg msg3
printmsg msg2
calcnum a
printmsg msg3
calcnum bx
mov ah,4ch
int 21h
jmp l5

l4:
mov bx,0001
printmsg msg3
printmsg msg2
calcnum a
printmsg msg3
calcnum bx
sub cx,0002
l1:
printmsg msg3
mov dx,a
add dx,bx
mov b,dx
calcnum dx
mov dx,b
mov a,bx
mov bx,dx
dec cx
cmp cx,0000
jne l1


l5:
code ends
end start




Sunday 29 January 2012

Check a number is Armstrong or not-Masm program

printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm



data segment
n dw ?
p dw 00
rem dw ?
z dw ?

cr db,0dh,"$"
msg1 db "Enter a number(Ex:0123)$"
msg2 db 0ah,0dh,"Armstrong$"
msg3 db 0ah,0dh,"Not Armstrong$"
msg4 db 0ah,0dh,"$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax


printmsg msg1

mov ah,01h
int 21h
mov ah,00
sub al,30h
mov dx,1000
mul dx
mov n,ax
mov ah,01h
int 21h
mov ah,00
sub al,30h
mov dh,100
mul dh
add ax,n
mov n,ax
mov ah,01h
int 21h
sub al,30h
mov ah,00
mov dh,10
mul dh
add ax,n
mov n,ax
mov ah,01
int 21h
sub al,30h
mov ah,00
add ax,n

mov n,ax
mov z,ax
mov cl,04

l2:
mov ax,n
mov dh,10
div dh
mov rem,al
mov al,ah
mov ch,ah
mov ah,00
mul ch
mul ch
add ax,p
mov p,ax
mov ax,rem
mov n,ax
dec cl
cmp cl,00
jne l2


mov dx,p
cmp z,dx
je l3
l4:
printmsg msg3
jmp skip
l3:
printmsg msg2








skip:mov ah,04h
int 21h
code ends
end start



Masm program to find prime numbers upto a limit

printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov dh,100
div dh
mov num,ah
aam
mov dh,al
printnum ah
printnum dh
mov al,num
aam
mov dh,al
printnum ah
printnum dh
endm

data segment
num dw ?
i dw 02
j dw ?
n dw ?

msg1 db "Enter a limit$"
msg2 db 0ah,0dh,"Prime nos:$"
msg3 db 0ah,0dh,"$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

printmsg msg1

mov dh,02
mov ah,01h
int 21h
mov ah,00
sub al,30h

mov cl,10
mul cl
mov n,ax
mov ah,01h
int 21h
mov ah,00
sub al,30h

add ax,n
inc ax
mov n,ax

printmsg msg2


mov ah,00
mov cx,n
l3:
cmp cx,i
je l1

mov j,02
mov ax,i
mov dh,02
div dh
mov bl,al
l6:cmp j,bl
jnc l2
l7:mov ax,i
mov dl,j
div dl
cmp ah,00
je l9
inc j
jmp l6

l2:
jz l7
printmsg msg3
calcnum i
l9:inc i
jmp l3

l1:mov ah,04h
int 21h
code ends
end start

Factorial of a number-Masm program

printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm

printnum macro reg
mov dl,reg
add dl,30h
mov ah,02h
int 21h
endm

calcnum macro regx
mov ax,regx
mov dh,100
div dh
mov num,ah
aam
mov dh,al
printnum ah
printnum dh
mov al,num
aam
mov dh,al
printnum ah
printnum dh
endm

data segment
num dw  ?
msg1 db "Enter a number$"
msg2 db 0ah,0dh,"Factorial:$"
msg3 db 0ah,0dh,"$"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

printmsg msg1

mov ah,01h
int 21h

sub al,30h
mov ah,00


mov cl,al
mov ch,00
mov ax,0001


l1:
mul cx

dec cl
cmp cl,01
jne l1


mov bx,ax
printmsg msg2
calcnum bx


mov ah,04h
int 21h
code ends
end start

Saturday 28 January 2012

Opera's Turbo - Enable turbo for slow connections

                                                                                                                                                     
We know about the browser opera.Here is a small property of opera. New opera browser has a new technology known as Turbo. If you have slow internet connection then use turbo for an average speed.If you enable turbo then opera will compress the images and graphics elements in the pages.So web pages will load fastly.

Note:Turbo button is in the status bar. Enable it for speed up your browsing.

Friday 13 January 2012

Removable disk shotcuts in desktop-windows trick

You know in linux when you plug a pendrive ,its shotcut will appear in the desktop. That shotcut will automatically removed when you eject the pendrive.This is also possible in windows through the use of a simple software.
                                                                            
Just download and  install it. It will autometically start at startup.
Try and enjoy.

Download link.

Wednesday 4 January 2012

The Ultimate webcam software-Youcam

Cyberlink's YOUCAM is a super webcam software.Provides many fun  features and effects.Also gives facilities for chatting,video conferencing,work,play etc.

Other features
1)Use new Face Login to access online sites like Facebook and eBay.
2)100s of fun features like Augmented Reality, avatars, interactive effects, and gadgets.
3)Record super smooth HD videos
4)Upload your webcam videos straight from YouCam to Youtube.
5) Advanced facial tracking technology


                                                                                            
                                                                     
To download Youcam use this  link

Twitter Delicious Facebook Digg Stumbleupon Favorites More