
%if 0

Hashing macros
 by E. C. Masloch, 2019

Usage of the works is permitted provided that this
instrument is retained with the works, so that any entity
that uses the works is notified of this instrument.

DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

%endif

%ifndef __NASMHASH_MAC__
%assign __NASMHASH_MAC__ 1


	%macro hashdef 2+.nolist
%ifempty %2
 %assign _%1 1
%else
%ifstr %2
 %define %%string %2
%elifid %2
 %defstr %%string %2
%elifnum %2
 %defstr %%string %2
%eliftok %2
 %defstr %%string %2
%else
 %error Unknown input
%endif
%strlen %%length %%string
%assign %%hash 1
%assign %%index 1
%rep %%length
 %substr %%char %%string %%index
 %assign %%hash (%%hash * 31 + %%char) & 0FFFFh
 %assign %%index %%index + 1
%endrep
%assign _%1 %%hash
%endif
	%endmacro


%endif
