Hack Forums
[Assembly] with calling recursive/iterative function that findsminValue of type Int - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Assembly] with calling recursive/iterative function that findsminValue of type Int (/showthread.php?tid=5262610)



with calling recursive/iterative function that findsminValue of type Int - gamg7 - May 7, 2016

Hello,

I've currently got an assignment utilizing the m68000 processor. To objective of the assignment is to call a recursive function that finds the minimum value and sort it using one of two methods.

The basic idea is that the minimum value is either the first element of the list, or it is the minimum value from the rest of list. You should correctly implement the above psuedocode in your findmin.s file.
Here is the high level abstraction I am using for pseudocode:
Code
int findmin(int* vals, int count)
{
    if(count == 1)
    {
        return vals[0];
    }
    else
    {
        int minrest = findmin(vals+1,count-1);
        if (minrest < vals[0])
        {
            return minrest
        }
        else
        {
            return vals[0]
        }
    }
}

Here is my current code, as you can see I've just started and I've currently got an error:
Code
start:      initIO                  * Initialize (required for I/O)
            setEVT            * Error handling routines
*        initF            * For floating point macros only    

    *move hardcoded values into d0 and d1
    
    move.l #0,D0
    move.l #1,D1
    cmp.l D0,D1
    bgt less
    lineout greater
less:    
    lineout less
    

            break                   * Terminate execution
*
*----------------------------------------------------------------------
*       Storage declarations

greater: dc.b 'greater'
less: dc.b 'less'

            end
ppasm template.s
Macro preprocessing complete.
ERROR in line 157: Symbol value differs between first and second pass
1 error detected
No warnings generated
68000 Assembler by PGM


Please help when possible, thank you.


* - brownclown - May 17, 2016

the error is because you are using the symbol "less" in 2 x places

less:
lineout less

and a second time

less: dc.b 'less'

call the second one "lessmsg" or something