flat assembler
Message board for the users of flat assembler.

Index > Main > hash calculating

Author
Thread Post new topic Reply to topic
Abyx



Joined: 17 Apr 2008
Posts: 9
Abyx
Code:
macro h name {
      virtual at 1
          db `name
          hash= 0
          repeat $-$$
              load C byte from %
              display C,13,10    ;debug
              hash= hash*5+C  ;<<<error here
          end repeat
      end virtual
      dd hash }

h 0123456789abcdefghijklmnopqrstuvxyz_______________________     

This code generates compile-time error "value out of range".
If unroll cycle, all the same.

What's wrong?
Post 26 Oct 2008, 09:20
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Abyx,

hash value grows too big to fit in 64 bits used by fasm for constants.
Code:
h 0123456789abcdefghijklmno    
fails on dd hash for the same reason.
Post 26 Oct 2008, 10:39
View user's profile Send private message Reply with quote
Abyx



Joined: 17 Apr 2008
Posts: 9
Abyx
So "hash= (hash*5+C)and 0xFFFFFFFF"...
thanks, baldr
Post 26 Oct 2008, 10:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.