linux-mips-fnet
[Top] [All Lists]

Re: DECstation boot code

To: marius@prilnari.com, linux-mips@fnet.fr
Subject: Re: DECstation boot code
From: Ralf Baechle <ralf@waldorf-gmbh.de>
Date: Wed, 11 Oct 1995 15:44:37 +0100 (MET)
Hi Matt, hi all,

I changed Matt's crt0.o startup code for the DECstation a little bit and
hope this fixes his problems.  Since this is a nasty and sometimes difficult
to track bug that sometimes even catches wannabe-gurus like me ;-) I'm
posting the fix to the mailinglist, too.

Old:
        .globl  start
start:
        .set    noreorder

        jal     main                            # main(argc, argv)
        nop

-------------------------------------------------------------------

New:
        .globl  start
start:
        .set    noreorder

        jal     main                            # main(argc, argv)
        subu    $sp,$sp,16                      # create 16 bytes for
                                                # argument save space

You forgot to subtract 16 bytes from the stackpointer.  These 16 bytes
are the argument save space that need to be reserved for each call to
a subroutine.  In your case the main routine will try to save the
passed parameters onto the stack and by that overwriting something
else or writing to unmapped space ...  For more information about the
MIPS calling sequence please see the appendix in the often mentioned
MIPS bible from Kane.  Or ask me ...

   Ralf

<Prev in Thread] Current Thread [Next in Thread>