1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; UrForth level
1: self
-hosting
32-bit Forth compiler
3 ;; Copyright
(C
) 2020 Ketmar Dark
// Invisible Vector
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 code: STR-HASH-ELF ( addr count -- u32hash )
17 ;; high
= hash
&0xF0000000
37 code: STR-HASH-JOAAT ( addr count -- u32hash )
76 code: STR-HASH-ROT ( addr count -- u32hash )
81 ;; hash
= lrot
(hash
, 4)
86 ;; upcase it
(this also distorts other chars
, but who cares
)
91 ;; this mixing allows using power
-of
-two tables with masking
92 ;; hash ^
= (hash
>>10)^
(hash
>>20)
105 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
108 ;; ;; \
' STR-HASH-DSFORTH disasm-word
109 ;; ;; .( testing hashing functions...\n)
111 ;; ;; : (str-hash-nassert) ( v0 v1 -- )
113 ;; ;; ." assertion failed!\n"
114 ;; ;; ." EXPECTED: $" .hex8 cr
115 ;; ;; ." GOT: $" .hex8 cr
121 ;; ;; s" a" str-hash-dsforth $00000061 (str-hash-nassert)
122 ;; ;; s" ab" str-hash-dsforth $00000024 (str-hash-nassert)
123 ;; ;; s" The quick brown fox jumps over the lazy dog" str-hash-dsforth $00000063 (str-hash-nassert)
125 ;; ;; s" a" str-hash-elf $00000061 (str-hash-nassert)
126 ;; ;; s" ab" str-hash-elf $00000672 (str-hash-nassert)
127 ;; ;; s" The quick brown fox jumps over the lazy dog" str-hash-elf $04280C57 (str-hash-nassert)
129 ;; ;; s" a" str-hash-joaat 0xca2e9442 (str-hash-nassert)
130 ;; ;; s" ab" str-hash-joaat $45E61E58 (str-hash-nassert)
131 ;; ;; s" The quick brown fox jumps over the lazy dog" str-hash-joaat 0x519e91f5 (str-hash-nassert)
133 ;; ;; .( done testing hashing functions...\n)