October 30, 2025, 05:23:45 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Assembler

Started by Brian, August 14, 2011, 05:55:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Hi,

While looking through my code, I was tempted to put in a bit of assembler to try and speed things up. Is:

_asm
   inc dword [$variable]
_endasm

any faster than just stating: variable++ ?

(Or, indeed, using dec dword to decrement a variable)

If it is faster, are there any other useful (and simple) assembler instructions we could use?

Brian

Ficko

Hi Brian,

One or two assembler instruction makes no perceivable difference.
You can only be aware of any such improvement using precision timer to make it visible Homosapien have no such clock build in. :D
Only exception is if this part of your program is running for a long time so you can gain couple hours or even days if you running it for a year. ;D

However you can get sometimes significant improvement by coding whole section of critical code in assembler especially using SIMD instructions if appropriate but they are generally not “simple” assembler instructions.

But there is an easy way to get hold of them.
Program the critical portion of your program in C by taking careful consideration the guidelines of parallelization of Intel â€" both thread and vectorisation â€"
use Intel C++ and appropriate switches to generate highly optimized SIMD instructions and to generate assembly.

Extract the assembly code and integrate into your IWB application.
You may even find something can be hand edited â€" not likely â€"to optimize even more.