Assembly Code to find a minimum of a set of 5 signed 32 bit integers?

I am new to assembly coding. I am trying to write an assembly code that will find the minumum of set of 5 signed 32 bit integers.
The data is - 1,-7,6,8,9

Can someone please help me out.
smartriderAsked:
Who is Participating?
 
mblais1Connect With a Mentor Commented:
That page does not say what language ARC simulator uses, so I could not tell you if it is compatible with 80x86 code.
0
 
mblais1Commented:

values  sdword  - 1,-7,6,8,9  ; signed 32-bit numbers

       mov    ebx, offset values ; EBX points to the array of 5 ints.
       mov    ecx, 5                 ; how many numbers in the array
       mov    eax, 07FFFFFFFh ; Holds current minimum value found
L1:  mov    edx, [ebx+ecx*4] ; get next number in list
       cmp    eax, edx
       jle      L2
       mov    eax, edx             ; found new minimum value
L2:  loop    L1

; Minimum value from array is now in EAX
0
 
KavarCommented:
you need to decrement ecx and check your zero flag
so that you don't stay in the loop for ever
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
smartriderAuthor Commented:
thanks for the reply mblias1. Can you please explain me something :

don't we need to add "len= 20" since there are 5 values in the array ?. According to my task - it states that save the minimum value into memory name "Northwest" and the "Greg" is the location name for the first array element.

Please assist.

I appreciate your help!
0
 
mblais1Commented:
@Kavar: the LOOP instruction means "decrement ECX and branch if nonzero."

@smartrider: substitute 'Greg' for 'values' in the code above,  and add the following instruction at the end:
      mov   [Northwest], eax

you'll also need to define Northwest somewhere, maybe like this at the top:

Northwest  sdword  0
0
 
KavarCommented:
sorry, is loop an assembly command?  I have never seen it in machine ops
0
 
mblais1Commented:
Yes, LOOP is an 80x86 opcode.  Also LOOPE, LOOPNE, etc.
0
 
smartriderAuthor Commented:
Can this code be used in ARC program ?
0
 
mblais1Commented:
This is 80x86 assembly language, which can be used with any 80x86 assembler (e.g., MASM, or MSVC).

What is 'ARC program' ?
0
 
NovaDenizenCommented:
Sorry, this is kind of a smart-alecky answer, but how about this:

    mov eax, -7

No loops, no fuss, no muss!
0
 
smartriderAuthor Commented:
It is a tool called the ARC simulator . Check out this website :

http://paul.rutgers.edu/~weiz/cs211spring03/archelp.html

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.