-
rbrunnerFor a story I write I want to give a rough sketch how RandomX works. There I stumbled over a question that I tried to answer looking at the source code but couldn't:
-
rbrunnerGiven a value between 0 and 255, how to find out which RandomX instruction is that?
-
rbrunnerOr, in reverse, if I want to know which byte value(s) lead to e.g. NOP, how to look that up?
-
rbrunnerI saw that block explorers like xmrchain.com can give you the RandomX programs used for a particular block, but it seems not the raw bytes
-
rbrunnerIf it's too difficult to look up or too tiresome to describe maybe just draw some examples of byte value, RandomX instruction out of some hat that I could mention in my story
-
rbrunnerThanks!
-
sech1rbrunner each instruction has a defined frequency: github.com/tevador/RandomX/blob/master/src/configuration.h#L84
-
sech1all frequencies add up to 256
-
sech1so RANDOMX_FREQ_IADD_RS is used when the random byte is between 0 and 15, RANDOMX_FREQ_IADD_M when it's between 16 and 22 and so on
-
rbrunnerI see, clear now. Thanks sech1!
-
hycit's a direct mapping of byte value [0-255] to instruction. the mapping can be completely arbitrary, and the values associated to an instruction need not be contiguous
-
hycthe current arrangement of contiguous ranges is most convenient. making it highly discontiguous would increase the complexity of hardware circuitry required to decode it, if we wanted to go that route