Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/fnv1a/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ func main() {
TEXT("Hash64", NOSPLIT, "func(data []byte) uint64")
Doc("Hash64 computes the FNV-1a hash of data.")
ptr := Load(Param("data").Base(), GP64())
n := Load(Param("data").Len(), GP64())
endPtr := Load(Param("data").Len(), GP64())
ADDQ(ptr, endPtr)

h := RAX
MOVQ(Imm(OffsetBasis), h)
p := GP64()
MOVQ(Imm(Prime), p)

Label("loop")
CMPQ(n, Imm(0))
CMPQ(ptr, endPtr)
JE(LabelRef("done"))
b := GP64()
MOVBQZX(Mem{Base: ptr}, b)
XORQ(b, h)
MULQ(p)
INCQ(ptr)
DECQ(n)

JMP(LabelRef("loop"))
Label("done")
Expand Down
6 changes: 3 additions & 3 deletions examples/fnv1a/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ func main() {
TEXT("Hash64", NOSPLIT, "func(data []byte) uint64")
Doc("Hash64 computes the FNV-1a hash of data.")
ptr := Load(Param("data").Base(), GP64())
n := Load(Param("data").Len(), GP64())
endPtr := Load(Param("data").Len(), GP64())
ADDQ(ptr, endPtr)

h := RAX
MOVQ(Imm(OffsetBasis), h)
p := GP64()
MOVQ(Imm(Prime), p)

Label("loop")
CMPQ(n, Imm(0))
CMPQ(ptr, endPtr)
JE(LabelRef("done"))
b := GP64()
MOVBQZX(Mem{Base: ptr}, b)
XORQ(b, h)
MULQ(p)
INCQ(ptr)
DECQ(n)

JMP(LabelRef("loop"))
Label("done")
Expand Down
4 changes: 2 additions & 2 deletions examples/fnv1a/fnv1a.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
TEXT ·Hash64(SB), NOSPLIT, $0-32
MOVQ data_base+0(FP), CX
MOVQ data_len+8(FP), BX
ADDQ CX, BX
MOVQ $0xcbf29ce484222325, AX
MOVQ $0x00000100000001b3, SI

loop:
CMPQ BX, $0x00
CMPQ CX, BX
JE done
MOVBQZX (CX), DX
XORQ DX, AX
MULQ SI
INCQ CX
DECQ BX
JMP loop

done:
Expand Down