Tuesday, September 25, 2012

8086 program to add 2 32-bit numbers

To write 8086 Assembly Language Program to add two 32-bit signed & unsigned number

code:

MOV AX,5000H ; Initialize DATA SEGMENT
MOV DS,AX ; to 5000H
MOV AX,[1000H] ; take lower 16-bit of NUM1 in AX
MOV BX,[2000H] ; take lower 16-bit of NUM2 in BX
ADD AX,BX ; AX = AX + BX
MOV [3000H],AX ; Store lower 16-bit result at NUM3
MOV AX,[1002H] ; take higher 16-bit of NUM1 in AX
MOV BX,[2002H] ; take higher 16-bit of NUM2 in BX
ADC AX,BX ; AX = AX + BX + CF (add with carry)
MOV [3002H],AX ; Store higher 16-bit result at NUM3
HLT ; Halt 8086


Windows Shortcuts


                                                                 Windows Shortcuts

Execute below command s from run promt

appwiz.cpl  ----> Add/Remove Programs
 access.cpl  ----> Accessibility Controls

 hdwwiz.cpl  ----> Add Hardware Wizard

  control admintools   ----> Administrative Tools
  wuaucpl.cpl   ----> Automatic Updates

 fsquirt   ----> Bluetooth Transfer Wizard
  calc   ----> Calculator

  certmgr.msc   ----> Certificate Manager

  charmap   ----> Character Map


Monday, September 10, 2012

Prime Numbers Program

Write a program to find prime numbers upto entered number in shortest number of loops


Solution:


#include<stdio.h>
main()
{
int a,b,c,d;
clrscr();
printf("Enter number upto which you want prime numbers:\n");
scanf("%d",&a);
 for(c=2;c<a;c++)//c=2 for excluding 1
  {
for(b=1,d=0;b*b<=c;b++)//d must be initialised every time
{
if(c%b==0)
d++;
}
if(d==1)
printf("%d\t",c);
  }
getch();
return(0);
}

LOOP Program in c


(f) Write a program to produce the following output:
ABCDEFGFEDCBA
ABCDEF   FEDCBA
ABCDE       EDCBA
ABCD           DCBA
ABC                CBA
AB                     BA
A                          A

Solution:


#include<stdio.h>
main()
{
int i,j,k,m;
clrscr();
for(k=72;k>64;k--)
{
for(i=65;i<k;i++)
printf("%c",i);
for(m=2*(72-k)-1;m>0;m--)//for providing odd No. of spaces
printf(" ");
if(k==72)
j=k-2;
else
j=k-1;
for(j;j>64;j--)
printf("%c",j);

printf("\n");
}
}