Commit c11dadc5 authored by Russ Cox's avatar Russ Cox

[dev.cc] crypto/md5, crypto/sha1: restore a few SP references

Applying my post-submit comments from CL 5120.
The rewrite there changed the code from writing to the stack
frame to writing below the stack frame.

Change-Id: Ie7e0563c0c1731fede2bcefeaf3c9d88a0cf4063
Reviewed-on: https://go-review.googlesource.com/5470Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
parent 9c0c0507
......@@ -29,31 +29,31 @@
//12(FP) is p.cap
//
// Stack frame
#define p_end -4 // -4(R13==SP) pointer to the end of data
#define p_data -8 // -8(R13) current data pointer
#define buf (-8-4*16) //-72(R13) 16 words temporary buffer
#define p_end end-4(SP) // pointer to the end of data
#define p_data data-8(SP) // current data pointer
#define buf buffer-(8+4*16)(SP) //16 words temporary buffer
// 3 words at 4..12(R13) for called routine parameters
TEXT ·block(SB), NOSPLIT, $84-16
MOVW p+4(FP), Rdata // pointer to the data
MOVW p_len+8(FP), Rt0 // number of bytes
ADD Rdata, Rt0
MOVW Rt0, p_end(R13) // pointer to end of data
MOVW Rt0, p_end // pointer to end of data
loop:
MOVW Rdata, p_data(R13) // Save Rdata
MOVW Rdata, p_data // Save Rdata
AND.S $3, Rdata, Rt0 // TST $3, Rdata not working see issue 5921
BEQ aligned // aligned detected - skip copy
// Copy the unaligned source data into the aligned temporary buffer
// memove(to=4(R13), from=8(R13), n=12(R13)) - Corrupts all registers
MOVW $buf(R13), Rtable // to
MOVW $buf, Rtable // to
MOVW $64, Rc0 // n
MOVM.IB [Rtable,Rdata,Rc0], (R13)
BL runtime·memmove(SB)
// Point to the local aligned copy of the data
MOVW $buf(R13), Rdata
MOVW $buf, Rdata
aligned:
// Point to the table of constants
......@@ -217,8 +217,8 @@ aligned:
MOVM.IA [Ra,Rb,Rc,Rd], (Rt0)
MOVW p_data(R13), Rdata
MOVW p_end(R13), Rt0
MOVW p_data, Rdata
MOVW p_end, Rt0
ADD $64, Rdata
CMP Rt0, Rdata
BLO loop
......
......@@ -45,10 +45,10 @@
//12(FP) is p.cap
//
// Stack frame
#define p_end -4 // -4(SP) pointer to the end of data
#define p_data (p_end - 4) // -8(SP) current data pointer
#define w_buf (p_data - 4*80) // -328(SP) 80 words temporary buffer w uint32[80]
#define saved (w_buf - 4*5) // -348(SP) saved sha1 registers a,b,c,d,e - these must be last
#define p_end end-4(SP) // pointer to the end of data
#define p_data data-8(SP) // current data pointer (unused?)
#define w_buf buf-(8+4*80)(SP) //80 words temporary buffer w uint32[80]
#define saved abcde-(8+4*80+4*5)(SP) // saved sha1 registers a,b,c,d,e - these must be last (unused?)
// Total size +4 for saved LR is 352
// w[i] = p[j]<<24 | p[j+1]<<16 | p[j+2]<<8 | p[j+3]
......@@ -141,7 +141,7 @@ TEXT ·block(SB), 0, $352-16
MOVW p+4(FP), Rdata // pointer to the data
MOVW p_len+8(FP), Rt0 // number of bytes
ADD Rdata, Rt0
MOVW Rt0, p_end(R13) // pointer to end of data
MOVW Rt0, p_end // pointer to end of data
// Load up initial SHA1 accumulator
MOVW dig+0(FP), Rt0
......@@ -151,7 +151,7 @@ loop:
// Save registers at SP+4 onwards
MOVM.IB [Ra,Rb,Rc,Rd,Re], (R13)
MOVW $w_buf(R13), Rw
MOVW $w_buf, Rw
MOVW $0x5A827999, Rconst
MOVW $3, Rctr
loop1: ROUND1(Ra, Rb, Rc, Rd, Re)
......@@ -206,7 +206,7 @@ loop4: ROUND4(Ra, Rb, Rc, Rd, Re)
ADD Rctr, Rd
ADD Rw, Re
MOVW p_end(R13), Rt0
MOVW p_end, Rt0
CMP Rt0, Rdata
BLO loop
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment