Hi.
I've encountered problems with assembler code. I'm a newbie to assembler, so it seems difficult for me to solve it myself.
The task is: "To find minimal and maximal elements of the array."
All I've already done is searching for maximal element. I can't find out, how to make check for the minimal element and where I should put such verification. Or, probably, I should loop through elements second time after finding maximal element?
Code:
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void main() {
int N = 10, i;
clrscr();
int a[] = { 1, 4, -6, 12, -25, 10, 3, -4, 15, 7}, MAX, MIN, RESULT;
__asm{
mov cx, N
lea si, a
lodsw
mov bx, ax
mov dx, ax
dec cx }
m:
__asm{
lodsw
cmp dx, ax
jge m1
mov dx, ax
}
m1:
__asm{
loop m
mov MAX, dx
}
cout << "Max = " << MAX;
//cout << "Min = " << MIN;
getch();
}