tIt's bad form to access data *below* the stack pointer. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2f05c0e86db5b0362ce0cc2e4a6d3a8fcd3a5827
 (DIR) parent 2e965b3324b32be00a2193bf304dcb936f02824b
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun,  9 May 2004 16:10:31 +0000
       
       It's bad form to access data *below* the stack pointer.
       
       Diffstat:
         M src/libsec/386/sha1block.spp        |      35 +++++++++++++++++--------------
       
       1 file changed, 19 insertions(+), 16 deletions(-)
       ---
 (DIR) diff --git a/src/libsec/386/sha1block.spp b/src/libsec/386/sha1block.spp
       t@@ -75,9 +75,10 @@ _sha1block:
         * stack offsets
         * void sha1block(uchar *DATA, int LEN, ulong *STATE)
         */
       -#define        DATA        8
       -#define        LEN        12
       -#define        STATE        16
       +#define STACKSIZE (48+80*4)
       +#define        DATA        (STACKSIZE+8)
       +#define        LEN        (STACKSIZE+12)
       +#define        STATE        (STACKSIZE+16)
        
        /*
         * stack offsets for locals
       t@@ -89,20 +90,22 @@ _sha1block:
         * ulong a = eax, b = ebx, c = ecx, d = edx, e = esi
         * ulong tmp = edi
         */
       -#define WARRAY        (-4-(80*4))
       -#define TMP1        (-8-(80*4))
       -#define TMP2        (-12-(80*4))
       -#define W15        (-16-(80*4))
       -#define W40        (-20-(80*4))
       -#define W60        (-24-(80*4))
       -#define W80        (-28-(80*4))
       -#define EDATA        (-32-(80*4))
       -#define OLDEBX        (-36-(80*4))
       -#define OLDESI        (-40-(80*4))
       -#define OLDEDI        (-44-(80*4))
       +#define WARRAY        (STACKSIZE-4-(80*4))
       +#define TMP1        (STACKSIZE-8-(80*4))
       +#define TMP2        (STACKSIZE-12-(80*4))
       +#define W15        (STACKSIZE-16-(80*4))
       +#define W40        (STACKSIZE-20-(80*4))
       +#define W60        (STACKSIZE-24-(80*4))
       +#define W80        (STACKSIZE-28-(80*4))
       +#define EDATA        (STACKSIZE-32-(80*4))
       +#define OLDEBX        (STACKSIZE-36-(80*4))
       +#define OLDESI        (STACKSIZE-40-(80*4))
       +#define OLDEDI        (STACKSIZE-44-(80*4))
        
                /* Prelude */
                pushl %ebp
       +        subl $(STACKSIZE), %esp
       +
                mov %ebx, OLDEBX(%esp)
                mov %esi, OLDESI(%esp)
                mov %edi, OLDEDI(%esp)
       t@@ -209,6 +212,6 @@ loop4:
                mov OLDEBX(%esp), %ebx
                mov OLDESI(%esp), %esi
                mov OLDEDI(%esp), %edi
       -        movl %esp, %ebp
       -        leave
       +        addl $(STACKSIZE), %esp
       +        popl %ebp
                ret