Description: A simple assembly language program to find maximum element in an unsorted array. For example: 7, 3, 10, 6, 15 then the output should be 15 stored in a memory location. Indirect addressing is useful for this kind of problems.
[org 0x0100]
mov ax , [arr]
mov si , [size]
mov dx , 1
mov bx , 2
findLargest:
mov cx , [arr+bx]
add bx , 2
add dx , 1
cmp ax , cx
jl valuePlace
cmpCounter:
cmp dx , si
jnz findLargest
jmp resultPlace
valuePlace:
mov ax , cx
jmp cmpCounter
resultPlace:
mov [result] , ax
mov ax,0x4c00
int 0x21
arr: dw 7,3,10,6,15
size: dw 5
result: dw 0
No comments
Post a Comment