So i am trying learn assembly and my practice sheet has an example where i have to create a program to input 10 numbers one at a time into an array. I have to print the highest value and when it was entered. I have barely any exp in comparing but I want to somehow store the high value and compare it the locations?
code:
include irvine32.inc
.data
num dw 10 dup(0)
count db 1
prompt db "Enter a number: ",0
yesMsg db "hi val is in location ",0
hiMsg db "The high value is ",0
.code
main proc
mov ebx,offset num
mov ecx,10
LOOP1:
mov edx,offset prompt
call writestring
call readint
mov [ebx],ax
add ebx,2
loop LOOP1
mov ecx,10
mov ebx,offset num
sub eax,eax
call crlf
LOOP2:
mov ax,[ebx]
call writeint
call crlf
add ebx,2
loop LOOP2
mov ebx,offset num
mov ecx,lengthof num
FindGreatest:
call crlf
mov ebx,offset num
mov ecx,lengthof num
mov ax,[ebx]
movsx eax,ax
FindLoop:
cmp ax,[ebx]
jge FindCont
mov ax,[ebx]
FindCont:
add ebx,2
loop FindLoop
mov edx,offset HiMsg
call writestring
call writedec
call crlf
TestLoop:
mov eax,ebx
cmp [ebx],ax
je IsHighNum
IsHighNum:
mov edx,offset yesMsg
call writestring
movsx eax,count
call writedec
call crlf
ENDITALL:
exit
main endp
end main
I enter 1,2,3,4,5,6,7,8,9,10
out : high value is 10 high is in location 1