advance processor practicals
Post on 19-Oct-2015
36 Views
Preview:
DESCRIPTION
TRANSCRIPT
ADVANCED MICROPROCESSOR ROLL NO.: 39
AIM : WRITE A Program for 16-bit addition.PROGRAM:
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 endsend startoutput:
conclusion: We are able to perform the program of adding 16-bit number successfully using Tasam Simulator.AIM : WRITE A Program for 16-bit multiplication.PROGRAM:
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 endsend startoutput:
conclusion: We are able to perform the program of 16-bit multiplication, successfully using Tasam Simulator.AIM : WRITE A Program for bcd addition.PROGRAM:
ASSUME cs:code,ds:data
data segment
a db 41h
b db 29h
sum db ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov al,a
mov bl,b
add al,bl
daa
mov sum,al
mov ah,04ch
int 21h
code ends
end startOUTPUT:
conclusion: We are able to perform the program of bcd addition, successfully using Tasam Simulator.aim: write a Program for bcd subtraction.program:
ASSUME cs:code,ds:data
data segment
a db 41h
b db 29h
dif db ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov al,a
mov bl,b
sub al,bl
das
mov dif,al
mov ah,04ch
int 21h
code ends
end startoutput:
conclusion: We are able to perform the program of bcd subtraction, successfully using Tasam Simulator.aim: write a Program for bcd array addition.program:
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 startOUTPUT:
conclusion: We are able to perform the program of bcd array addition, successfully using Tasam Simulator.AIM : WRITE A Program to count the number of odds and evens from the given 8-bit array.PROGRAM:ASSUME CS:CODE,DS:DATaDATa SEGMENT
ARR DB 02H,03H,04H,05H,09H
ODD DB ?
EVEN1 DB ?
DATa ENDS
CODE SEGMENT
START:MOV AX,DATa MOV DS,AX
MOV AX,0000H
LEA SI,ARR
MOV CL,05H
MOV BX,0000H
AGAIN:
MOV AL,[SI]
RCR AL,1
JC OD
INC BL
INC SI
LOOP AGAIN
OD:INC BH
INC SI
LOOP AGAIN
MOV ODD,BH
MOV EVEN1,BL
MOV AH,04CH
INT 21H
CODE ENDS
END STARToutput:conclusion: We are able to perform the program of counting number of odd and even elements in a given 8-bit array successfully using Tasam Simulator.AIM : WRITE A Program to count the nuMber of 1s in 16-bit data.PROGRAM:assume cs:code,ds:data
data segment
n dw 2006h
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: We are able to perform the program of counting number of 1s in a given 16-bit number successfully using Tasam Simulator.AIM : WRITE A Program to find FacTORIAL OF A GIVEN NUMBER.
PROGRAM:
ASSUME CS:CODE,DS:DATADATA 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 STARToutput:
Conclusion: We are able to perform the program of finding factorial of a given number successfully using Tasam Simulator
AIM : WRITE A Program for finding factors of a given number.PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N DW 06H
ANS DB ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,N
MOV BL,00H
MOV CX,N
AGAIN:MOV AX,N
DIV CL
CMP AH,00H
JZ FCT
DEC CX
JNZ AGAIN
JZ PEND
FCT:
INC BL
DEC CX
JNZ AGAIN
PEND:MOV ANS,BL
MOV AH,04CH
INT 21H
CODE ENDS
END START
output:
Conclusion: We are able to perform the program of finding factors of a given number successfully using Tasam Simulator.AIM : WRITE A Program to find prime numbers in a given range.
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
NO1 DW 0004h
NO2 DW 0009h
MSG DB ' PRIME ' PRIMENO DW ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,9
LEA DX,MSG LEA SI,PRIMENO
MOV DX,NO1
AGAIN: MOV CL,00H
MOV BH,00H
MOV BL,01H
AGAIN1:MOV AX,DX
DIV BL
CMP AH,00H
JZ FACTO
INC BL
CHECK:CMP DX,BX
JNC AGAIN1
JMP RETURN
FACTO:INC CL
INC BL
JMP CHECK
RETURN: CMP CL,03
JC PRIME
NEXT: INC DX
CMP NO2,DX
JC PEND
JMP AGAIN
PRIME: MOV [SI],DX
INC SI
JMP NEXT
PEND: MOV AH,4CH
INT 21H
CODE ENDS
END START
Output:
conclusion: We are able to perform the program of finding prime numbers in a given range successfully using Tasam Simulator.
AIM : WRITE A Program to find complete fibonacci series till Nth number.
PROGRAM:assume cs:code,ds:data
data segment
r db 09h
a db 00h
b db 01h
c db 01h
ANS DB ?
MSG DB ' FIBONACCI '
data ends
code segment
start:
mov ax,data
mov ds,ax
LEA DX,MSG
mov al,a
mov bl,b
mov cl,c
mov dl,r
lea si,ANS
mov [si],bl
inc si
again:
cmp cl,dl
jnc exit
add al,bl
cmp al,dl
jnc exit
mov cl,al
mov [si],Al
inc si
mov al,bl
mov bl,cl
jmp again
exit:
mov ah,04ch
int 21h
code ends
end start
Output:
conclusion: We are able to perform the program of finding complete Fibonacci series till the given number successfully using Tasam Simulator.AIM : WRITE A Program to find a total number of negative elements in a given array.PROGRAM: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 startOutput:
conclusion: We are able to perform the program of counting number of negative elements in a given array successfully using Tasam Simulator.
AIM : WRITE A Program to convert any decimal number to any given number system.
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
NO1 DW 07h
NO2 DB 2h
ARR DB ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,NO1
MOV CL,NO2
MOV BX,0000H
AGAIN: DIV CL
MOV ARR[BX],AH
INC BX
// INC CH
CMP AL,01H
JNZ AGAIN
MOV AH,09H
MOV DX,OFFSET ARR
MOV Ah,04CH
INT 21H
CODE ENDS
END START
Output:
conclusion: We are able to perform the program of converting DECIMAL number to BINARY format, successfully using Tasam Simulator.AIM : WRITE A PROGRAM TO CONVERT ANY NUMBER FROM ANY NUMBER SYSTEM TO DECIMAL VALUE.PROGRAM:
ASSUME DS:DATA,CS:CODE
DATA SEGMENT
B DW 0012H
MSG DB 'H2D'
RESULT DW ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,9
LEA DX,MSG
MOV BX,B
MOV AX,0
MOV CX,0
NEXT: CMP BX,0
JZ ENDPG
DEC BX
MOV AL,CL
ADD AL,01
DAA
MOV CL,AL
MOV AL,CH
ADC AL,00H
DAA
MOV CH,AL
JMP NEXT
ENDPG: MOV RESULT,CX
MOV AH,4CH
INT 21H
CODE ENDS
END START
Output:
conclusion: We are able to perform the program of converting HEXA-DECIMAL number to DECIMAL format, successfully using Tasam Simulator.AIM: Write a program to convert ASCII to Packed BCD.
PROGRAM:
assume cs:code,ds:data
data segment
a db 5
b db 9
c db ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov al,a
mov bl,b
and al,0fh
ror al,4
and bl,0fh
or al,bl
mov c,al
mov ah,4ch
int 21h
code ends
end startOutput:
conclusion: We are able to perform the program of converting ascii to packed bcd, successfully using Tasam Simulator.AIM: Write a program to convert ASCII to BCD.
PROGRAM:
assume cs:code,ds:data
data segment
n dw 'N'
ans dw ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov ax,n
mov bx,0000h
add ax,bx
daa
mov ans,ax
mov ax,04ch
int 21h
code ends
end startOutput:
conclusion: We are able to perform the program of converting
Ascii to bcd, successfully using Tasam Simulator.AIM: WRITE A Program to sort an array in ascending order.PROGRAM:
ASSUME CS:CODE,DS:DATADATA SEGMENT
A DB 09H, 0FH, 06H
RESULT DB ?
MSG DB SORTINGDATA ENDS
CODE SEGMENT
START : MOV AX,DATA
mOV DS,AX
MOV AH,9
LEA DX,MSGINITIAL : LEA BX,A
MOV DL,00H
MOV CL,02H
CHECK : MOV AL,[BX]
INC BX
MOV AH,[BX]
CMP AL,AH
JC NXT
MOV CH,[BX]
MOV [BX],AL
DEC BX
MOV [BX],CH
INC BX
MOV DL,01HNXT: DEC CL
JNZ CHECK
MOV DH,DL
ROR DH,1
JC INITIAL
INT 21H
CODE ENDS
END STARTOutput:
conclusion: We are able to perform the program of sorting an array in ascending order, successfully using Tasam Simulator.AIM : WRITE A PROGRAM TO FIND MAXIMUM AND MINIMUM NUMBER FROM A GIVEN ARRAY.PROGRAM:ASSUME CS:CODE,DS:DATA
DATA SEGMENT
VALUES DB 87H, 56H, 42H
MSG DB ' MAXMIN 'DATA ENDS
CODE SEGMENT
START : MOV AX,DATA
MOV DS,AX
MOV AH,9
LEA DX,MSGINITIAL : LEA BX,VALUES
MOV DL,00H
MOV CL,02H
CHECK : MOV AL,[BX]
INC BX
MOV AH,[BX]
CMP AL,AH
JC NXTBYT
MOV CH,[BX]
MOV [BX],AL
DEC BX
MOV [BX],CH
INC BX
MOV DL,01H
NXTBYT : DEC CL
JNZ CHECK
MOV DH,DL
ROR DH,1
JC INITIAL
MOV DH,[BX]
MOV DL,[BX-2]
MOV [BX+1],DL
MOV [BX+2],DH
INT 21HCODE ENDS
END STARTOutput:
conclusion: We are able to perform the program of finding minimum and maximum number from a given array, successfully using Tasam Simulator.AIM: Write a program to sort an array such that positive and negative values are at alternative position. Assume array length to be even and having equal numbers of positive and negative values.
PROGRAM:
assume cs:code,ds:data
data segment
arr db 80h,07h,90h,02h,24h,81h
t1 db ?
t2 db ?
msg db ' POSITIVE NEGATIVE ALTERNATE'
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,0000h
lea si,arr
lea di,t1
mov bl,00h
mov cx,0006h
again:mov ah,[si]
and ah,80h
jz m2
mov ah,[si]
mov [di],ah
inc di
jmp doit
m2: mov ah,[si]
push ax
doit: inc si
loop again
mov cx,0003h
lea si, arr
m1: dec di
mov ah,[di]
mov [si],ah
inc si
pop ax
mov [si],ah
inc si
loop m1
mov ah,4ch
int 21h
code ends
end start
Output:
conclusion: We are able to perform the program of sorting an array such that positive and negative numbers are in alternate position, successfully using Tasam Simulator.AIM : Write a program to convert a string from lowercase to uppercase.PROGRAM:
assume cs:code,ds:data,es:data
data segment
lower db 'am '
upper db ?
data ends
code segment
start : mov ax,data
mov ds,ax
mov es,ax
mov cl,04h
mov dx,0000h
lea si,lower
lea di,upper
again : mov bl,[si]
and bl,11011111b
mov [di],bl
inc dx
inc si
inc di
dec cl
jnz again
int 3
code ends
end start
Output:
conclusion: We are able to perform the program of converting string from lowercase to uppercase, successfully using Tasam Simulator.AIM: Write a program to compare two strings. First compare the length and then the characters. The comparison is in case sensitive. i.e. e and e are same.PROGRAM:
assume cs:code,ds:data,es:data
printmsg macro msg
mov ah,09h
mov dx,offset msg
int 21h
endm
data segment
cr equ 0dh
lf equ 0ah
len1 dw ?
len2 dw ?
input1 db 80 dup (?)
input2 db 80 dup (?)
msg1 db 'enter first string : ','$'
msg2 db cr,lf,'enter second string : ','$'
msg3 db cr,lf,'length is equal.$'
msg4 db cr,lf,'length is not equal.$'
msg5 db cr,lf,'both string are equal.$'
msg6 db cr,lf,'both string are not equal.$'
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov cx,00
printmsg msg1
lea si,input1
bake1: mov ah,01h
int 21h
mov [si],al
inc si
inc cx
cmp al,cr
jne bake1
mov len1,cx
mov cx,00
printmsg msg2
lea si,input2
bake2: mov ah,01h
int 21h
mov [si],al
inc si
inc cx
cmp al,cr
jne bake2
mov len2,cx
mov bx,len1
cmp cx,bx
jne exit1
printmsg msg3
lea si,input1
lea di,input2
mov cx,len1
cmpbk: mov al,[si]
cmp al,[di]
jne check1
inc si
inc di
loop cmpbk
jmp ok
check1:mov ah,al
add al,20h
cmp al,[di]
jne check2
inc si
inc di
dec cx
jnz cmpbk
jmp ok
check2:mov al,ah
mov ah,[di]
add ah,20h
cmp al,ah
jne exit2
inc si
inc di
dec cx
jnz cmpbk
ok: printmsg msg5
jmp exit
exit1: printmsg msg4
jmp exit
exit2 : printmsg msg6
exit: mov ah,4ch
int 21h
code ends
end startOutput:
conclusion: We are able to perform the program of comparing string, successfully using Tasam Simulator.AIM: Write a program to reverse given string.
PROGRAM:
assume cs:code,ds:data,es:data
printstring macro msg
mov ah,09h
mov dx,offset msg
int 21h
endm
data segment
cr equ 0dh
lf equ 0ah
buff db 80 dup(0)
revbuff db 80 dup(0)
msg1 db 'enter the string : ','$'
msg2 db cr,lf,'reverse of string = ','$'
data ends
code segment
assume ds:data,cs:code
start: mov ax,data
mov ds,ax
printstring msg1
mov si,offset buff
rdchar1:
mov ah,01h
int 21h
mov [si],al
inc si
cmp al,cr
jne rdchar1
; find the legth of a string
mov si,offset buff
mov bx,00
nxtchar2:
mov al,[si]
cmp al,cr
je skip1
mov [si],al
inc si
inc bx
jmp nxtchar2
skip1:
; reverse the string
mov si,offset buff
add si,bx
mov di,offset revbuff
mov cx,bx
nxtchar3:
dec si
mov al,[si]
mov [di],al
inc di
loop nxtchar3
mov al,'$'
mov [di],al
; display the reverse string
printstring msg2
printstring revbuff
mov ah,4ch
mov al,00h
int 21h
code ends
end start
Output:
conclusion: We are able to perform the program of reversing string, successfully using Tasam Simulator.
AIM: Write a program to check whether given string is palindrome or not.PROGRAM:
assume cs:code,ds:data,es:data
data segment
str1 db 'madam$'
msg1 db 'given string is palindrom$'
msg2 db 'given string is not palindrom$'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov cx,0000h
lea si,str1
label1: mov al,[si]
cmp al,'$'
jz label2
inc si
inc cx
jmp label1
label2: dec si
mov di,si
mov ax,cx
mov bl,02h
div bl
lea si,str1
mov cl,al
label4: mov al,[si]
cmp al,[di]
jnz label3
inc si
dec di
dec cl
jnz label4
lea dx,msg1
jmp label5
label3: lea dx,msg2
label5: mov ah,09h
int 21h
mov ah,4ch
int 21h
code ends
end start
Output:
conclusion: We are able to perform the program of checking if string is palindrome or not, successfully using Tasam Simulator.AIM: Write a program To count frequency of all the characters in a given string.PROGRAM:assume cs:code,ds:data,es:data
printmsg macro msg
mov ah,09h
lea dx,msg
int 21h
endm
data segment
str1 db 'bit$'
char db 50 dup (?)
data ends
code segment
assume ds:data,cs:code
start: mov ax,data
mov ds,ax
mov ax,0000h
lea di,str1
lea si,str1 ;comparing each char with the string
lea bx,char
mov cl,'$'
next3: mov al,[si]
mov [bx],al
inc bx
next1: cmp al,[di] ;cmp 1st char with the string
jnz next
inc ah ;counter->frq of the char
next: inc di
cmp [di],cl ;compare a char till end of the string
jnz next1
mov [bx],':'
inc bx
add ah,48
mov [bx],ah
inc bx
inc bx
mov ah,00h
mov di,00h
inc si
cmp [si],cl
jnz next3
printmsg char
mov ah,4ch
int 21h
code ends
end start
Output:
conclusion: We are able to perform the program of counting frequency of each character in a string, successfully using Tasam Simulator.AIM: Write a program to create a file result and store it in 500h bytes form the memory location 1000:100, if either an interrupt appears at INTR pin with type 0AH or an instruction equivalent to the above interrupt is executed.
PROGRAM:
assume cs:code,ds:data
data segment
fname db "RESULT","$"
msg db "FILE WASNT CREATED SUCCESSFULLY",0ah,0dh,"$"
data ends
code segment
start : mov ax,code
mov ds,ax
mov dx,offset isr0a
mov ax,250ah
int 21h
mov dx,offset fname
mov ax,data
mov ds,ax
mov cx,00h
mov ah,3ch
int 21h
jnc further
mov dx,offset msg
mov ah,09h
int 21h
jmp stop
further: int 0ah
stop : mov ah,04ch
int 21h
isr0a proc near
mov bx,ax
mov cx,500h
mov dx,1000h
mov ax,1000h
mov ds,ax
mov ah,40h
int 21h
iret
isr0a endp
code ends
end start
Output:
conclusion: We are able to perform the program of creating a file by handling the interrupt,successfully using Tasam Simulator.
AIM: Write a program To display hello world on screen.PROGRAM:assume cs:code,ds:data
data segment
msg db ' HELLO WORLD '
data ends
code segment
start : mov ax,data
mov ds,ax
mov ah,09ch
int 21h
code ends
end startOutput:
conclusion: We are able to perform the program printing Hello World on screen, successfully using Tasam Simulator.AIM: Write a program To display system date.PROGRAM:assume cs:code,ds:data,es:data
data segment
msg1 db 'date : '
msg db ??date,0ah
data ends
code segment
start: mov ax,data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov ah,4ch
int 21h
code ends
end start
Output:
conclusion: We are able to perform the program printing system date on screen, successfully using Tasam Simulator.AIM: Write a program which accepts password from user and checks whether it it true or not. If untrue, the program should give maximum 3 chances to verify and then it should be locked.
PROGRAM:
assume cs:code,ds:data,es:data
data segment
str1 db 15 dup(?)
password db 'bit,cr
username db 'bit, cr
msg1 db cr,lf,'enter your username : $'
msg2 db cr,lf,'enter your username again : $'
msg3 db cr,lf,'invalid user name!!!$'
msg7 db cr,lf,'invalid password!!!$'
msg5 db cr,lf,'enter your password : $'
msg6 db cr,lf,'enter your password again : $'
msg4 db cr,lf,'welcome to computer world$'
msg8 db cr,lf,'account is locked$'
lf equ 0ah
cr equ 0dh
data ends
code segment
start: mov ax,data
mov ds,ax
mov cl,01h
lea dx,msg1
mov ah,09h
int 21h
call usercheck
lea dx,msg5
mov ah,09h
int 21h
call passcheck
lea dx,msg4
mov ah,09h
int 21h
mov ah,4ch
int 21h
usercheck proc
l3: lea si,str1
l1: mov ah,08h ; interrupt for read a key from keyboard
int 21h
mov [si],al
inc si
cmp al,cr
jz end1
mov dl,al
mov ah,02h ; interrupt for write a string on screen
int 21h
jmp l1
end1: lea si,str1
lea di,username
l2: mov al,[si]
cmp al,[di]
jnz invalid
inc si
inc di
cmp al,cr
jz valid1
jmp l2
invalid:
cmp cl,03h
jnz disp0
lea dx,msg8
mov ah,09h
int 21h
jp exit
disp0: inc cl
lea dx,msg3
mov ah,09h
int 21h
lea dx,msg2
mov ah,09h
int 21h
jmp l3
valid1: ret
usercheck endp
passcheck proc
l4: lea si,str1
l5: mov ah,08h ; interrupt for read a key from keyboard
int 21h
mov [si],al
inc si
cmp al,cr
jz end2 mov dl,al
mov ah,02h ; interrupt for write a string on screen
int 21h
jmp l5
end2: lea si,str1
lea di,password
l6: mov al,[si]
cmp al,[di]
jnz invalid1
inc si
inc di
cmp al,cr
jz valid
jmp l6
invalid1:
cmp cl,03h
jnz disp
lea dx,msg8
mov ah,09h
int 21h
jp exit
disp: inc cl
lea dx,msg7
mov ah,09h
int 21h
lea dx,msg6
mov ah,09h
int 21h
jmp l4
valid: ret
passcheck endp
exit: mov ah,4ch
int 21h
code ends
end start
Output:
conclusion: We are able to see that on entering wrong passwords 3 times account gets locked, successfully using Tasam Simulator.
top related