flat assembler
Message board for the users of flat assembler.

Index > Main > Macros and ROR, ROL

Author
Thread Post new topic Reply to topic
blh42



Joined: 19 Jun 2015
Posts: 2
blh42 19 Jun 2015, 13:54
Hi!

I'm somewhat new to FASM and was mostly intrigued by the powerful macro capabilities. Now my problem is how to use ROR and ROL with "local" variables.

My assumption was that this code world work but it only renders an error

Code:
macro rotr addr {
    local ..addr
    ..addr = addr ror 0xdd
    mov eax, ..addr
}    


Quote:
error: extra characters on line.


How would i solve this?

blh
Post 19 Jun 2015, 13:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20516
Location: In your JS exploiting you and your system
revolution 19 Jun 2015, 14:04
When using "local" in macros they are not declaring variables, instead they are just label names that are local to the macro context.

fasm does not support ror in the expression parser. You would have to simulate it with "shl", "shr" and "or".
Code:
macro rotr addr {
    mov eax,((addr shr 0x1d) and 0xffffffff) or ((addr shl (0x20 - 0x1d)) and 0xffffffff)
}    
The extra are brackets are just for clarity
Post 19 Jun 2015, 14:04
View user's profile Send private message Visit poster's website Reply with quote
blh42



Joined: 19 Jun 2015
Posts: 2
blh42 19 Jun 2015, 15:11
Ah right. So then what am I doing wrong with the rotl?

Code:
macro rotr dst,src,shift {
    mov dst,((src shr shift) and 0xffffffff) or ((src shl (0x20 - shift)) and 0xffffffff)
}

macro rotl dst,src,shift {
    mov dst,((src shl shift) and 0xffffffff) or ((src shr (0x20 - shift)) and 0xffffffff)
}
    


It doesnt seem to produce the result im expecting :S

blh
Post 19 Jun 2015, 15:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20516
Location: In your JS exploiting you and your system
revolution 19 Jun 2015, 17:26
What values and results did you get? I can't see anything obviously wrong.
Post 19 Jun 2015, 17:26
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.