Re: [fpc-pascal] rotating bits

2006-05-28 Thread Jonas Maebe
On 27 May 2006, at 11:01, Bisma Jayadi wrote: I agree with Michael. And I think the line is clearly drawn. The FPC (and more importantly the language syntax itself) design goal, as I understand it, is to be, as much as possible, platform and architecture independent and I believe the

Re: [fpc-pascal] rotating bits

2006-05-28 Thread Jonas Maebe
On 28 May 2006, at 15:45, Florian Klaempfl wrote: It is possible to implement a peephole optimization to change the shift/or into the native variant of rol/ror if it exists. The code currently generated is rather lengthy. Of course, but it's going to be a pretty consistent pattern which

Re: [fpc-pascal] rotating bits

2006-05-28 Thread Jonas Maebe
On 28 May 2006, at 15:51, Jonas Maebe wrote: But it can be done on ppc with two rlw* instructions which is also ok, no? I think it needs three: to to rotate left/right, one to insert the overflow at the end/start, and one to mask the overfow at the end/ start. No, two is actually

Re: [fpc-pascal] rotating bits

2006-05-27 Thread Bisma Jayadi
I agree with Michael. And I think the line is clearly drawn. The FPC (and more importantly the language syntax itself) design goal, as I understand it, is to be, as much as possible, platform and architecture independent and I believe the bit rotation support can be made platform and

Re: [fpc-pascal] rotating bits

2006-05-26 Thread Bisma Jayadi
That's the point why I want to include compiler support: rol/ror is very important for several cryptographic algorithms. Agree! Since these are very important and relatively commonly used, I think it'd be better if they're implemented as new operators (ror and rol) rather than as functions.

Re: [fpc-pascal] rotating bits

2006-05-26 Thread Jonas Maebe
On 26 May 2006, at 16:36, Bisma Jayadi wrote: Agree! Since these are very important and relatively commonly used, I think it'd be better if they're implemented as new operators (ror and rol) rather than as functions. Say we'll able to code like this: a := b ror c; x := y rol z; Just

Re: [fpc-pascal] rotating bits

2006-05-26 Thread Bisma Jayadi
Adding new operators is much more work and error prone than Agree. I never made a compiler, and I hope I won't, nor interested. :D I did make a simple SQL engine, though. AFAIK, adding a new operator, especially when a similar operator has existed before, wouldn't be too difficult. But, I

Re: [fpc-pascal] rotating bits

2006-05-26 Thread Bisma Jayadi
a := b ror c; x := y rol z; It would wreck havoc with typing. What should the result be of 1 ror 1? $80? $8000? $8000? $8000? $8000 on 32 bit and $8000 on 64 bit cpus? I believe the compiler knows the datatype and make an appropriate rotate action based on

Re: [fpc-pascal] rotating bits

2006-05-25 Thread Tomas Hajny
Florian Klaempfl wrote: Tomas Hajny wrote: On 25 May 06, at 0:10, ϸňđ Ęîńŕđĺâńęčé ń mail.ru wrote: First parameter is in eax, second in edx (third one is ecx) TH Yes, of course, sorry for confusion... :-( Anyway, loading of the first TH parameter can be still skipped (and the stack frame

Re: [fpc-pascal] rotating bits

2006-05-25 Thread Florian Klaempfl
Michael Van Canneyt wrote: On Thu, 25 May 2006, Florian Klaempfl wrote: Tomas Hajny wrote: On 25 May 06, at 0:10, ϸňđ Ęîńŕđĺâńęčé ń mail.ru wrote: First parameter is in eax, second in edx (third one is ecx) TH Yes, of course, sorry for confusion... :-( Anyway, loading of the first TH

Re: [fpc-pascal] rotating bits

2006-05-25 Thread Marco van de Voort
1) Are they useful in general, so that it would make sense to include them either in FPC itself (as opposed to some standalone unit)? - they must be available for all cpu platforms, so we need at least a generic implementation - for an efficient implementation, this needs a

Re: [fpc-pascal] rotating bits

2006-05-25 Thread Florian Klaempfl
Marco van de Voort wrote: 1) Are they useful in general, so that it would make sense to include them either in FPC itself (as opposed to some standalone unit)? - they must be available for all cpu platforms, so we need at least a generic implementation - for an efficient implementation,

Re[2]: [fpc-pascal] rotating bits

2006-05-25 Thread Пётр Косаревский
But the problem with ROR/ROL is that any real use over shr/shl uses a hard to model carry flag? Ugh, I don't understand well, but the talk is about rotating bits, no low level features like CF are requested (it doesn't mean very much if you rotate by several bits). Who talked about CF? I

Re: [fpc-pascal] rotating bits

2006-05-25 Thread Michael Van Canneyt
On Thu, 25 May 2006, Florian Klaempfl wrote: Michael Van Canneyt wrote: On Thu, 25 May 2006, Florian Klaempfl wrote: Tomas Hajny wrote: On 25 May 06, at 0:10, ϸňđ Ęîńŕđĺâńęčé ń mail.ru wrote: First parameter is in eax, second in edx (third one is ecx) TH Yes, of course,

Re: [fpc-pascal] rotating bits

2006-05-25 Thread Florian Klaempfl
Michael Van Canneyt wrote: On Thu, 25 May 2006, Florian Klaempfl wrote: Michael Van Canneyt wrote: On Thu, 25 May 2006, Florian Klaempfl wrote: Tomas Hajny wrote: On 25 May 06, at 0:10, ϸňđ Ęîńŕđĺâńęčé ń mail.ru wrote: First parameter is in eax, second in edx (third one is ecx) TH

Re[2]: [fpc-pascal] rotating bits

2006-05-25 Thread Пётр Косаревский
Well, if we're going in that direction anyway: Why not include all possible assembler instructions then ? Because some of them are not designed for calculations. But ror/rol are. Let's be serious. You must draw the line somewhere. I think these instructions are so exotic, they are pollution

[fpc-pascal] rotating bits

2006-05-24 Thread Пётр Косаревский
Is there high level operator/(inline)function for rotating bits? Am I supposed to implement rotating bits (like ror/rol in i386 asm) by inline assembler or some ugly workarounds (shifts and or-s)? ___ fpc-pascal maillist -

Re: [fpc-pascal] rotating bits

2006-05-24 Thread Jonas Maebe
On 24 mei 2006, at 10:56, Пётр Косаревский wrote: Is there high level operator/(inline)function for rotating bits? No. Am I supposed to implement rotating bits (like ror/rol in i386 asm) by inline assembler or some ugly workarounds (shifts and or-s)? Yes. I think there's already a

Re[2]: [fpc-pascal] rotating bits

2006-05-24 Thread Пётр Косаревский
On 24 mei 2006, at 10:56, Пётр Косаревский wrote: Is there high level operator/(inline)function for rotating bits? No. Am I supposed to implement rotating bits (like ror/rol in i386 asm) by inline assembler or some ugly workarounds (shifts and or-s)? Yes. I think there's already a

Re[3]: [fpc-pascal] rotating bits

2006-05-24 Thread Пётр Косаревский
I don't know how to use ret to achieve the same goal with fewer commands. Well, if I get it right (and it works on my system), the last lines: movb %al,result etc. (6 times) should be commented out. ___ fpc-pascal maillist -

Re: Re[2]: [fpc-pascal] rotating bits

2006-05-24 Thread Tomas Hajny
đŁÔŇ ëĎÓÁŇĹ×ÓËÉĘ wrote: On 24 mei 2006, at 10:56, đŁÔŇ ëĎÓÁŇĹ×ÓËÉĘ wrote: Is there high level operator/(inline)function for rotating bits? No. Am I supposed to implement rotating bits (like ror/rol in i386 asm) by inline assembler or some ugly workarounds (shifts and or-s)? Yes. I think

Re[4]: [fpc-pascal] rotating bits

2006-05-24 Thread Пётр Косаревский
With register calling convention (which is the default calling convention in FPC 2.x), it can be reduced just to: function brol(b: byte; c: byte): byte; assembler; inline; asm rolb %cl,%al end; (and similarly for all the other functions). The first parameter goes to eax, the second to

Re: Re[4]: [fpc-pascal] rotating bits

2006-05-24 Thread Jonas Maebe
On 24 mei 2006, at 16:11, Пётр Косаревский wrote: function brol(b: byte; c: byte): byte; assembler; inline; asm rolb %cl,%al end; (and similarly for all the other functions). The first parameter goes to eax, the second to ecx, and the result is supposed to be in eax again. Tomas

Re[4]: [fpc-pascal] rotating bits

2006-05-24 Thread Пётр Косаревский
With register calling convention (which is the default calling convention in FPC 2.x), it can be reduced just to: function brol(b: byte; c: byte): byte; assembler; inline; asm rolb %cl,%al end; (and similarly for all the other functions). The first parameter goes to eax, the second to

Re: Re[4]: [fpc-pascal] rotating bits

2006-05-24 Thread Jonas Maebe
On 24 mei 2006, at 17:09, Пётр Косаревский wrote: function brol(b: byte; c: byte): byte; assembler; inline; asm rolb %cl,%al end; (and similarly for all the other functions). The first parameter goes to eax, the second to ecx, and the result is supposed to be in eax again. Tomas Did

Re: [fpc-pascal] rotating bits

2006-05-24 Thread Florian Klaempfl
Пётр Косаревский wrote: On 24 mei 2006, at 10:56, Пётр Косаревский wrote: Is there high level operator/(inline)function for rotating bits? No. Am I supposed to implement rotating bits (like ror/rol in i386 asm) by inline assembler or some ugly workarounds (shifts and or-s)? Yes. I think

Re: Re[4]: [fpc-pascal] rotating bits

2006-05-24 Thread Tomas Hajny
Jonas Maebe wrote: On 24 mei 2006, at 17:09, Đ#65533;Ń#65533;Ń#65533;Ń#65533; Đ#65533;ĐžŃ#65533;Đ°Ń#65533;овŃ#65533;киК wrote: function brol(b: byte; c: byte): byte; assembler; inline; asm rolb %cl,%al end; (and similarly for all the other functions). The first parameter goes to

Re: Re[2]: [fpc-pascal] rotating bits

2006-05-24 Thread L505
There is this page which might help some http://www.merlyn.demon.co.uk/del-bits.htm ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re[6]: [fpc-pascal] rotating bits

2006-05-24 Thread ϸ�� ����������� � mail.ru
First parameter is in eax, second in edx (third one is ecx) TH Yes, of course, sorry for confusion... :-( Anyway, loading of the first TH parameter can be still skipped (and the stack frame is probably not useful TH in this case either). So you'd get: TH function brol(b: byte; c: byte): byte;

Re[4]: [fpc-pascal] rotating bits

2006-05-24 Thread ���� ����������� � mail.ru
L There is this page which might help some L http://www.merlyn.demon.co.uk/del-bits.htm Thank you, it was interesting. But it was not very helpful. It's interesting, that they don't seem to care much about rotating bytes or words. (Asm rotating 64-bits was fascinating!)

Re: Re[6]: [fpc-pascal] rotating bits

2006-05-24 Thread Tomas Hajny
On 25 May 06, at 0:10, ϸňđ Ęîńŕđĺâńęčé ń mail.ru wrote: First parameter is in eax, second in edx (third one is ecx) TH Yes, of course, sorry for confusion... :-( Anyway, loading of the first TH parameter can be still skipped (and the stack frame is probably not useful TH in this case