use strtol() for hex conversion (original gensimcode must have inlined it)