0% found this document useful (0 votes)
57 views10 pages

Aim: Divide 8-Bit Number Stored in Memory Locations 4009H by Data Stored at Memory

The document contains 5 assembly language programs. Program 1 divides an array of numbers stored in memory by a divisor stored in memory and stores the results back in the array. Program 2 performs modulo operations on two arrays storing the results in a third array. Program 3 finds the largest number in an array. Program 4 counts the positive and negative numbers in an array. Program 5 multiplies two 16-bit numbers stored in memory and stores the 32-bit result in memory.

Uploaded by

Samin Momin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views10 pages

Aim: Divide 8-Bit Number Stored in Memory Locations 4009H by Data Stored at Memory

The document contains 5 assembly language programs. Program 1 divides an array of numbers stored in memory by a divisor stored in memory and stores the results back in the array. Program 2 performs modulo operations on two arrays storing the results in a third array. Program 3 finds the largest number in an array. Program 4 counts the positive and negative numbers in an array. Program 5 multiplies two 16-bit numbers stored in memory and stores the 32-bit result in memory.

Uploaded by

Samin Momin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Microprocessor Architecture and Assembly Programming (CE341) 17CE058

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

mov ax,@data;Base Address


mov ds,ax;Moving to Base Address

mov ax,0; storing value 0 at ax register


mov cx,5;counter

mov di,0;Indexed pointing to value 0


mov bl,2;stores value 2-

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

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 1


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

Output:

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 2


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

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

array db 1,2,3,4,5;Array of 5 Elements


array2 db 2,4,9,16,5
result db 5 DUP(?); for storing result

.code

MOV DX, @data;Base address


MOV DS,DX;moving to base address
MOV CX, 5;counter
MOV BX, 0;storing value 0 at bx register

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

LOOP next;loop end


Ret

Output:

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 3


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 4


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

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 AX, @DATA;Base Address


MOV DS,AX;moving to base address

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

CMP AL,ARRAY[BX] ;performs subtraction


INC BX

JC MAXI ;when number is larger jump to max


LOOP NEXT

HLT
MAXI:

MOV DL,ARRAY[BX]
MOV MAX,DL ;maximum number will be set

DEC CX
JMP NEXT

END

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 5


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

Output:

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 6


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

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

mov ds,ax;moving to base address


mov al,0;value 0 at register al

mov bx,0;value 0 at register bx


mov cx,9;counter

next:
cmp vector[bx], 0h ; compares for positive number

jg positive ; checks for sf (sign flag)


inc bx
inc countn ; increments negative number

loop next
hlt

positive:
inc countp ; increments positive value

inc bx
dec cx

jnz next
end

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 7


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

Output:

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 8


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

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

mov bx,0400h;Base address


mov ds, bx;moving to base address

mov [00h],4000h;moving 4000 value at 4000 location


mov [02h],4025h;moving 4025 value at 4002 loaction

mov ax,[00h];storing value at ax register


mov bx,[02h];storing value at bx register

mul bx;multiplication

mov [004h],ax
mov [006h],dx

ret

Output:

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 9


Microprocessor Architecture and Assembly Programming (CE341) 17CE058

U & P U. Patel Department of Computer Engineering, CSPIT, CHARUSAT Page | 4. 10

You might also like