Aim: Write A Program Which Sets The Parity Bit. Code
Aim: Write A Program Which Sets The Parity Bit. Code
EXPERIMENT-5
Program-1
Aim: Write a program which sets the parity bit.
Code:
.model prac5_1
.data
number dB 00000000b
.code
mov ax,@data ;base address
mov ds,ax ; moving to base address
MOV ah,number; it will move parity bit to all
sahf;register to flag
Output:
Program-2
Aim: Write a program which transfers content of Flags to Register
Code:
.model prac5_2
.data
number dB 1010101b;
.code
mov ax,@data ; base address
mov ds,ax ; moving to base address
MOV ah,number;storing value at ah register
sahf;register to flag
mov ah,0;storing value 0 at ah register
lahf ; flag to register
Output:
Program-3
Aim: Write a program to add the two Hex Numbers 7AH and 46H and to store the sum at
memory location 2098 and flags status at 2097 location.
Code:
.model prac5_3
.data
num1 db 7ah;num1=7ah
num2 db 46h;num2=46h
.code
mov ax,@data; base address
mov ds,ax; moving to base address
mov bh,num1;moving value of num1 to bh register
adc bh,num2; adding num1 and num2 with carry
lahf; flag to fregister
end
Output:
Program-5
Aim: Using a Subroutine, write a program which adds two hex number 10H and F0H and
store result at 2040H location in memory. At the end of subroutine, clear the flag Z without
affecting other flags and return to main program.
Code:
.model prac5-5
.data
a dw 10h;a=10h
b dw 00f0h;b=00f0h
.code
endp;end of procedure
end
Output:
Program-6
Aim:. Write a program which set and resets zero flag at next iteration. (take number of
iteration equal to 5)
Code:
.model prac5.6
.data
.code
mov dh,4;dh=4
mov cx,5;counter =5
checking:
mov al,dh;moving value of dh to al
div bl
cmp ah,2;comparing ah with 0
jz set
jnz reset;
set:
lahf
jmp exit
reset:
lahf
and ah,10111111b;it will unset
sahf
exit:
inc dh
loop checking
end
Output:
Program-8
Aim: Implement a program to reverse a string using stack operations and stored in
same memory area
Code:
.model prac5-8
.stack 100h
.data
lea dx,string
; interrupt to exit
mov ah, 4ch
int 21h
rev proc
checkloop:
;this check loop will decide if the character is last or not
je lastsymbol
;if it is not the $ symbol then do this
push [si]
inc cx
jmp checkloop
lastsymbol:
;if jump is done then come here and set si again
je exit
; if not then execute
pop dx
; this is done becaue the values is only stored in dl and dh value is garbage so we need
want it
xor dh, dh
;this will help in reversing string
mov [si], dx
;decrementing cx
inc si
dec cx
jmp reversing
exit:
; add ^ to the end of string
rev endp
end
Output:
Program-9
Aim: Calculate the sum of series of even numbers from the list of numbers. The length
of the list is in memory location 2200H and the series itself begins from memory location
2201H. Assume the sum to be 8 bit number so you can ignore carries and store the sum
at memory location 2210H.
Code:
.model prac5-9
.data
.code
mov bx,200h;base address
mov [200h],bx
mov di,201h;first memory
mov bx,0;This will be used for zero flag
mov [222h],bx
mov bx,3;This is random value
mov cx,5
give:
mov [di],bx
inc bx
inc di
loop give
mov dh,[di]
div bl
cmp ah,[222h]
jz addition
jnz end;This will do nothing
addition:
add [210h],dh;This will act as addition
jmp end
end:
inc di
loop checking
end
Output:
Program-10
Aim: Write an assembly language program to arrange an array of 10 data in ascending
order. The length of the list is in memory location 2200H and the series itself begins
from memory location 2201
Code:
.model prac5-10
.data
.code
mov bx,200h;base address
mov ds,bx;moving to base address
mov cx,10;counter=10
giving:
mov [di],bx
dec bx
inc di
loop giving
outerloop:
innerloop:
mov ah,[di]
mov dh,[bx]
jnc exit
change:
mov dh,[bx]
exit:
mov si,205h;This will help in comparison
cmp si,bx
jz abc
inc bx
jmp innerloop
abc:
inc di;This will be done for second element
mov bx,di
inc bx;
mov si,205h
cmp si,di
jnz outerloop
end
Output:
Program-11
Aim: Write an assembly language program to fill the memory locations starting from
3000h, with n Fibonacci numbers
Code:
.model prac5-11
.data
.code
mov di,00h;di=0
mov cx,5;cx=5
fibo:
mov ax,[di]
mov bx,[di+1];third element
inc di;shift by 2
loop fibo
end
Output: