Sep 13, 2009

Advance microprocessor 8086 programs


Arithmetic operation
Practical-1
Aim: Write a program to addition of two numbers.
Software requirements: TASM Simulator
Logic:
assume cs:code,ds:data
data segment
a dw 0001h
b dw 0005h
sum dw ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov ax,a
mov bx,b
add ax,bx
mov sum,ax
mov ah,04ch
int 21h
code ends
end start
Output:

Conclusion:
The program of  addition of two numbers is successfully executed with the use of tasam simulator.
Practical-2
Aim: Write a program to multiply two 16 bit numbers.
Software requirements: TASM Simulator
Logic:
assume cs:code,ds:data
data segment
a dw 0002h
b dw 0005h
multi dw ?
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,a
mov bx,b
mul bx
mov multi,ax
mov ah,04ch
int 21h
code ends
end start
Output:

Conclusion:
The program of to multiply two 16 bit numbers is successfully executed with the use of tasam simulator.
Practical-3
Aim: Write a program to add and subtract two 4 digit BCD numbers.
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
A DB 41H
B DB 29H
SUM DB ?
DIF DB ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL,A
MOV CL,AL
MOV BL,B
ADD AL,BL
DAA
MOV SUM,AL
MOv AL,CL
SUB AL,BL
DAS
MOV DIF,AL
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of  add and subtract two 4 digit BCD numbers is successfully executed with the use of tasam simulator
Practical-4
Aim: Write a program to find sum of an integer 8-bit array.
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
A DB 01H,05H,06H
SUM DB ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CL,03H
MOV AL,00H
MOV BL,00H
LEA SI,A
AGAIN:
MOV BL,[SI]
ADD AL,BL
INC SI
LOOP AGAIN
DAA
MOV SUM,AL
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of  find sum of an integer 8-bit array is successfully executed with the use of tasam simulator.
Practical-5
Aim: Write a program to count the number of odds and evens from the given 8-bit array.
Software requirements: TASM Simulator
Logic:
assume cs:code,ds:data
data segment
n dw 1001h,8002h,0a003h,0b004h,5505h
d db ?
data ends
code segment
start : mov ax,data
mov ds,ax
mov cl,05h
lea si,n
again : mov ax,[si]
shl ax,1
jnc nocount
inc dl
nocount : inc si
shr ax,1
dec cl
jnz again
mov d,dl
mov ah,04ch
int 21h
code ends
end start
Output:

Conclusion:
The program of count the number of odds and evens from the given 8-bit array is successfully executed with the use of tasam simulator
Practical-6
Aim: Write a program to count the number of 1’s in 16-bit data.
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N DW 2306H
O DB ?
DATA ENDS
CODE SEGMENT
START : MOV AX,DATA
MOV DS,AX
MOV AX,N
MOV CL,0FH
MOV DL,00H
AGAIN  :  SHR AX,1
JNC NOCOUNT
INC DL
NOCOUNT :  LOOP AGAIN
MOV O,DL
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of count the number of 1’s in 16-bit data is successfully executed with the use of tasam simulator.
Practical-7
Aim: Write a program to find a factorial of a given number.
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N DW 3
ANS DW ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,0001H
MOV CX,N
AGAIN:
MUL CX
DEC CX
JNZ AGAIN
MOV ANS,AX
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of find a factorial of a given number is successfully executed with the use of tasam simulator.
Practical-8
Aim: Write a program to find factors of the given number.
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N Dw 06H
ANS Dw ?
MSG DB '  FACTORS '
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,9
LEA DX,MSG
MOV AX,06h
MOV CL,06h
lea di,ans
AGAIN:
mov ax,06h
DIV cl
CMP AH,00H
JZ FCT
DEC CL
JNZ AGAIN
JZ PEND
FCT:
mov [di],cl
inc di
INC BL
DEC CL
JNZ AGAIN
PEND:
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of find factors of the given number is successfully executed with the use of tasam simulator.
Practical-10
Aim: Write a program to find complete Fibonacci series till n th number. 
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N DB 09H
A DB 01H
B DB 00H
MSG DB 'FIBONACCI','     ','SERIES'
SUM DB 01H
ANS DB ?
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV AH,9
LEA DX,MSG
MOV AL,A
MOV BL,B
MOV CL,N
MOV DL,SUM
lea si,ans
AGAIN:
CMP DL,CL
JNC AOUT
ADD AL,BL
CMP AL,CL
JNC AOUT
MOV DL,AL
mov [si],al
inc si
MOV AL,BL
MOV BL,DL
JMP AGAIN
AOUT:
MOV ANS,DL
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of find complete Fibonacci series till n th number is successfully executed with the use of tasam simulator.
Practical-11
Aim: Write a program to find a total number of negative elements in a given array.
Software requirements: TASM Simulator
Logic:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N DW 1001H,8002H,0A003H,0B004H,5505H
D DB ?
DATA ENDS
CODE SEGMENT
START : MOV AX,DATA
MOV DS,AX
MOV CL,05H
LEA SI,N
AGAIN : MOV AX,[SI]
SHL AX,1
JNC NOCOUNT
INC DL
NOCOUNT : INC SI
SHR AX,1
DEC CL
JNZ AGAIN
MOV D,DL
MOV AH,04CH
INT 21H
CODE ENDS
END START
Output:

Conclusion:
The program of find a total number of negative elements in a given array is successfully executed with the use of tasam simulator.

2 comments:

  1. thats wht i wanted!!!

    ReplyDelete
  2. hey bro... nice to meet you :D
    Can you help me? about TASM assembLy program in your bLog... pLease show the syntax Logic and print screen the output too for SHL & SHR make TASM...??
    pLease heLp me, I have a practice in my campus. Please bro... :D

    repLy pLease~

    ReplyDelete