flat assembler
Message board for the users of flat assembler.

Index > Main > ror/rol in macros

Author
Thread Post new topic Reply to topic
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 27 Apr 2013, 16:38
i need to use ror/rol in a macro but it doesnt seem to be supported

then i found this

ror = x * 2^y + x / 2^(32-y)
rol = x / 2^y + x / 2^(32-y)

but ^ is also not supported Shocked

is there any workaround?
Post 27 Apr 2013, 16:38
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3892
Location: vpcmipstrm
bitRAKE 27 Apr 2013, 16:48
Code:
struc _ROR val {
 . = ((. shr val) + (. shl (32-val))) and $FFFFFFFF
}
struc _ROL val {
 . = ((. shl val) + (. shr (32-val))) and $FFFFFFFF
}

happy = $19730905
joyjoy = $CAFEBABE
happy _ROR 14
joyjoy _ROL 10
dd happy,joyjoy    
...maybe you can use?

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 27 Apr 2013, 16:48
View user's profile Send private message Visit poster's website Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 27 Apr 2013, 17:46
thanks bitRAKE, but it doesnt seem to do the same than ror/rol

i cant use those strucs in my macro (error extra characters on line) so i did this:
_char = ((_char shr 3) + (_char shl (32-3))) and 0xFF

but the result is different than using ror/rol :S
Post 27 Apr 2013, 17:46
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3892
Location: vpcmipstrm
bitRAKE 27 Apr 2013, 18:01
Need to add more masking to clamp values? I didn't test it, but the general idea is sound. If you are only working with characters then it would be:

_char = ((_char shr 3) + (_char shl (8-3))) and 0xFF

The size of the values being operated on is important.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 27 Apr 2013, 18:01
View user's profile Send private message Visit poster's website Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 27 Apr 2013, 18:28
thanks a lot! works great =)
Post 27 Apr 2013, 18:28
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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.