Skip navigation
Currently Being Moderated

Assembler in C-code for Alchemy

Nov 16, 2010 7:01 PM

Hello all!


I aspire to reach high performance my left unfinished 3D-renderer for Flash-player. Soon enough I have understood that my ActionScript-code is doomed. Then I have started to learn Alchemy. And thanks to the help Bernd Paradies could transfer any data in the C-code and take away the ready image in the form of ByteArray. And it was essential faster. The same calculations occupying 10-15 seconds, now were measured by milliseconds.


Wishing to move ahead further, I want to add still productivity in my code.


I saw some topics about assembler and Alchemy.

Also I understand what to use "x86-asm-code" in Alchemy it is impossible.

But I want to ask. I can use "FlashPlayer-llvm-asm-code" in my C-code and in what type?


Especially I am interested in operations of data transfer and floating point operations between registers (without using variables in memory) interest.

  • Currently Being Moderated
    Nov 17, 2010 10:05 AM   in reply to svolatch123

    Hello svolatch123,


    in this forum you'll find some posts about optimizations involving inline assembly code, i.e.:


         optimizing abc-code


         inline functions in C, gcc optimization and floating point arithmetic issues


    But in general I would avoid optimizations at the inline assembler level. Instead I would use profile your app and use the results to zoom in on specific areas that your optimizations will benefit from. You may have already done that and identified floating point calculations as one of those areas. If floating point calculations are your problem then you might be able to get better performance by using integer math internally (if that's possible). This technique is used by programs like Donald Knuth's TeX. The idea is that you do your math in integer units of floats (i.e. 1.234cm = 1 unit, 2 * 3 = 6 units = 6 * 1.234cm = 7.404cm).


    Another performance hog that will probably show up in your profiling results will probably point you to the fact that crossing the border between AS3 and C world (calling from AS3 code into Alchemy-C code and vice versa) is very expensive. You'll get good performance improvements by reducing calls that cross that boundary.


    If there is a piece of code in particular that you need to optimize I would post it here in this forum.

    I am sure you'll find help here.


    Best wishes,


    - Bernd

    Mark as:
  • Currently Being Moderated
    Nov 17, 2010 2:49 PM   in reply to svolatch123

    If you use floats for your floating point operations take double instead of float. Double performs much more better cause it is the native as3 Number type without some internal roundings

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points