Recent

Author Topic: How to use html colors in lazarus  (Read 5439 times)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9286
  • FPC developer.
Re: How to use html colors in lazarus
« Reply #15 on: April 18, 2021, 11:25:11 pm »
I use

Code: Pascal  [Select][+][-]
  1. result:=(swapendian(dword(x)) shr 8) or (x and $FF000000)

The generated code size seems about the same if I remove the redundant CONST from flipcolor, and the type of used instructions too.

(added later:)

Hmm,
Code: Pascal  [Select][+][-]
  1.   result:=rordword(swapendian(dword(x)),8);

looks shorter on x86 :-)

Quote
        movl   %eax,%edx
# Var x located in register edx
   shll   $8,%eax
   andl   $-16711936,%eax
   shrl   $8,%edx
   andl   $16711935,%edx
   orl   %edx,%eax
   roll   $16,%eax
   rorl   $8,%eax

Note that the compiler can't seem to peephole a roll  16,x with a rorl 8,x  into one rol 8,x ?
« Last Edit: April 18, 2021, 11:38:41 pm by marcov »

voltag

  • Newbie
  • Posts: 3
Re: How to use html colors in lazarus
« Reply #16 on: April 19, 2021, 12:32:27 am »
@marcov , @jamie
Thank you for discovering the wonderful bits manipulation functions.

 

TinyPortal © 2005-2018