flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > ror in FASM?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 03 Mar 2009, 00:04
"db 1234 shr 8" works.

"db 1234 ror 8" says "error: extra characters on line.".

Please help.. I can't figure out which characters are the extra ones.. Confused

I think it's some kind of weird bug.
Post 03 Mar 2009, 00:04
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Mar 2009, 00:08
Quote:

I think it's some kind of weird bug.

But it is not, fasm doesn't support such operation on expressions, it is only allowed as a CPU instruction.
Post 03 Mar 2009, 00:08
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 03 Mar 2009, 00:10
LocoDelAssembly wrote:
Quote:

I think it's some kind of weird bug.

But it is not, fasm doesn't support such operation on expressions, it is only allowed as a CPU instruction.
It does with shr, though.

So is it a bug that it works for shr.. or is it a bug that it doesn't work for ror?

Either way is bug.
Post 03 Mar 2009, 00:10
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Mar 2009, 00:38
The shr and shl, apart of being CPU instructions are also operations allowed on expressions.

TFM brilliantly says wrote:
1.2.4 Numerical expressions


In the above examples all the numerical expressions were the simple numbers,
constants or labels. But they can be more complex, by using the arithmetical
or logical operators for calculations at compile time. All these operators
with their priority values are listed in table 1.4.
The operations with higher priority value will be calculated first, you can
of course change this behavior by putting some parts of expression into
parenthesis. The +, -, * and / are standard arithmetical operations,
mod calculates the remainder from division. The and, or, xor, shl,
shr and not perform the same logical operations as assembly instructions
of those names. The rva performs the conversion of an address into the
relocatable offset and is specific to some of the output formats (see 2.4).

http://flatassembler.net/docs.php?article=manual#1.2.4
Post 03 Mar 2009, 00:38
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 03 Mar 2009, 00:52
LocoDelAssembly wrote:
The shr and shl, apart of being CPU instructions are also operations allowed on expressions.

TFM brilliantly says wrote:
1.2.4 Numerical expressions


In the above examples all the numerical expressions were the simple numbers,
constants or labels. But they can be more complex, by using the arithmetical
or logical operators for calculations at compile time. All these operators
with their priority values are listed in table 1.4.
The operations with higher priority value will be calculated first, you can
of course change this behavior by putting some parts of expression into
parenthesis. The +, -, * and / are standard arithmetical operations,
mod calculates the remainder from division. The and, or, xor, shl,
shr and not perform the same logical operations as assembly instructions
of those names. The rva performs the conversion of an address into the
relocatable offset and is specific to some of the output formats (see 2.4).

http://flatassembler.net/docs.php?article=manual#1.2.4


Thanks.

Can you please tell me where shl and shr are handled (like what file and line number? I can't find them)? I will just add ror/rol support myself. It shouldn't take more then a simple copy/paste and then replacing sh with ro.




Edit: nevermind found it myself. Was easier then I thought.
Post 03 Mar 2009, 00:52
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Mar 2009, 01:14
I'm not an expert on the matter but I'll try to give you some pointers.

First, you will probably have to add the new ops in TABLES.INC below "operators:". Then change on PARSER.INC the proc get_operator. Finally do the appropriate changes on calculate_expression at EXPRESSI.INC.

However, note that ROR and ROL can be build as a series of SHR/SHL, AND and OR, so before going so far consider if it really worth it considering you can replicate functionality with existing features.
Post 03 Mar 2009, 01:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 03 Mar 2009, 02:40
Post 03 Mar 2009, 02:40
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 08 Feb 2013, 10:09
BUMP (4 years later)

Would it be possible to add ROL and ROR into FASM? I miss them.

(10 years old patches are no longer that useful)

Code:
mov ax, $CD SHL 3
; mov ax, $CD ROL 3 ; !!! BUGGED !!!
mov ax, $CD MOD 3
    


> However, note that ROR and ROL can be build
> as a series of SHR/SHL, AND and OR

True, but with same "right" you could delete many other operators too.

#undef MOD
Post 08 Feb 2013, 10:09
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 08 Feb 2013, 11:50
DOS386 wrote:
Would it be possible to add ROL and ROR into FASM? I miss them.
If you'd like to revive the discussion, I suggest to continue from this point: http://board.flatassembler.net/topic.php?p=18841#18841
MCD brought up what the problem is. I never got an idea for a nice solution (though I must confess that I did not put much effort into trying), but maybe you would propose something.
Post 08 Feb 2013, 11:50
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 08 Feb 2013, 12:46
Tomasz Grysztar wrote:
revive the discussion, I suggest to continue from this point


Thanks ... it's the size problem and the infamous "infinite precision". I'd be happy with

ROL8
ROR8
ROL32
ROR32

as I don't have any better idea for now, and so far dealt with 8-bit and 32-bit ROL'ling stuff only.

Same for B.S.WAP: either make it 32-bit only, or make BSWAP32 and BSWAP64. BSWAP16 could be replaced by ROL16 (considering that CPU's don't support BSWAP16 at all Very Happy )
Post 08 Feb 2013, 12:46
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 08 Feb 2013, 12:52
DOS386 wrote:
(considering that CPU's don't support BSWAP16 at all Very Happy )
Sure they do:
Code:
xchg ah,al ;bswap16 ax    
Razz
Post 08 Feb 2013, 12:52
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.