This program is to find the product of numbers in an array:
We initalize the registers, then we move the size of the array to a counter and reduce its size bu one. SI is incremented to point to the 1st number of the array and move the 1st number into accumularot.
The 2nd number is moved into BL,, we multiply both the numbers abd this is continued till the numbers in the list, exhaust and finally the result is stored in AX.
Code:
MOV SI, 2000
MOV DI,4000
MOV AX,O
MOV BX,0
MOV CX,0
MOV CL,[SI]
SUB CL,[SI]
INC SI
MOV AL,[SI]
AGAIN: INC SI
MOV BL, [SI]
MUL BL
LOOP AGAIN
MOV [DI],AX
INT A5
Thus the program for product of numbers in an array can be executed using the above code.
Showing posts with label array. Show all posts
Showing posts with label array. Show all posts
Dec 2, 2008
Oct 18, 2008
Program to perfrom sum of elements in an array
Program to perform sum of elements in an array
Following is the assembly language program to find the sum of elements in a given array. This code is for 16-bit addition with 64 stack size.
Code:
MOV AX,@DATA ; Load AX with data
MOV DS,AX ; Load DX with AX
MOV ALPBCD ; Load AL with N1
MOV BL,AL ; load BL with AL
AND AL, OFH ; AND AL with OF H
MOV UBCD2,AL; Load N3 with AL
AND BL, OFOH
MOV CX,0004 ; Load CX with 0004
ROR BL,CL Rotate right BL,CL times
MOVE N2,BL
INT 3
Related links
all experts
bytes
wiki
Following is the assembly language program to find the sum of elements in a given array. This code is for 16-bit addition with 64 stack size.
Code:
MOV AX,@DATA ; Load AX with data
MOV DS,AX ; Load DX with AX
MOV ALPBCD ; Load AL with N1
MOV BL,AL ; load BL with AL
AND AL, OFH ; AND AL with OF H
MOV UBCD2,AL; Load N3 with AL
AND BL, OFOH
MOV CX,0004 ; Load CX with 0004
ROR BL,CL Rotate right BL,CL times
MOVE N2,BL
INT 3
Related links
all experts
bytes
wiki
Labels:
array,
sum of elements
Subscribe to:
Posts (Atom)