Aim: Divide 8-Bit Number Stored in Memory Locations 4009H by Data Stored at Memory
Aim: Divide 8-Bit Number Stored in Memory Locations 4009H by Data Stored at Memory
EXPERIMENT-4
Program-1
Aim: Divide 8-bit number stored in memory locations 4009H by data stored at memory
location 4001H & store result of division at memory location 400AH. (Use Data Set -4)
Code:
.model program_4.1
.data
array db 2,4,6,8,10;Array
.code
divi: ;loop
mov al,0
mov al,array[di] ;stores value of array in al after each iteration
div bl;divide each element by 2
mov array[di],al;stores the result after dividing
inc di
loop divi;End of loop
END
Output:
Program-2
Aim: Divide 8-bit number stored in memory locations 4009H by data stored at memory
location 4001H & store result of module operation at memory location 400AH. .(Use Data
Set 2,4)
Code:
.model prog-4.2
.data
.code
next:;loop
mov AL, array2[bx] ; array2 will be passed into the al after each iteration
DIV array[bx] ; QUOTIENT SAVED IN al, AND REMAINDER IN AH, DIVIDEND
SAVED IN AX
mov result[bx], al
inc bx
Output:
Program-3
Aim: Write an assembly language program to find the largest number in an array.
Code:
.model prog-4.3
.data
array db 11,2,5,4,3;Array of 5 element
max db 1 DUP(?)
.code
MOV CX,5;counter
MOV BX,0;inderxed value at 0
MOV AL, ARRAY[BX] ; max=array[0]
MOV MAX, AL
CLC
NEXT:
MOV AL,MAX
HLT
MAXI:
MOV DL,ARRAY[BX]
MOV MAX,DL ;maximum number will be set
DEC CX
JMP NEXT
END
Output:
Program-4
Aim: Write an assembly language program to count the numbers in an array (negative &
positive)
Code:
.model prog-4.4
.data
vector db -1,-2,5,-3,6,-10,11,-6,12;array
countp db 0;positive number
countn db 0;negative number
.code
mov ax,@data;base address
next:
cmp vector[bx], 0h ; compares for positive number
loop next
hlt
positive:
inc countp ; increments positive value
inc bx
dec cx
jnz next
end
Output:
Program-5
Aim: Write an assembly language program to multiply two 16-bit numbers in memory
and store the result in memory.
Code:
org 100h
mul bx;multiplication
mov [004h],ax
mov [006h],dx
ret
Output: