News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Quick question about... this question

Started by LordAdef, December 11, 2020, 08:03:09 AM

Previous topic - Next topic

LordAdef

Hey guys!
Is there any gain if I've got many bitblt invokes and I move an address to a register?
Say, this is one:
inv  BitBlt, hBufferDC, 0, 0, CHAR_LINE_COUNT * CHAR_WIDTH, CHAR_HEIGHT, \   
               assets.terrain.hdc, trn.frmx[edi], eax, SRCCOPY

Now I use esi to hold assets.terrain.hdc:

push esi
mov esi, assets.terrain.hdc
inv  BitBlt, hBufferDC, 0, 0, CHAR_LINE_COUNT * CHAR_WIDTH, CHAR_HEIGHT, \   
            esi, trn.frmx[edi], eax, SRCCOPY
pop esi

Just consider there is more than one call to bitblt
Cheers

hutch--

Alex,

With an API call, the total overhead is so high that loading a register does not give you a speed advantage. Use a memory operand as they don't change and get passed to the system DLL as memory in any case. Always try and find a way to use less registers in ordinary code so you have them when you need them.

LordAdef

Quote from: hutch-- on December 11, 2020, 08:28:13 AM
Alex,

With an API call, the total overhead is so high that loading a register does not give you a speed advantage. Use a memory operand as they don't change and get passed to the system DLL as memory in any case. Always try and find a way to use less registers in ordinary code so you have them when you need them.
Cheers Hutch!

jj2007

Quote from: LordAdef on December 11, 2020, 08:03:09 AMIs there any gain if I've got many bitblt invokes and I move an address to a register?

Speedwise, as Hutch rightly notes, it will not make any difference. Sizewise, if assets.terrain.hdc is a global variable, then you need two invoke xxx, ..., esi to gain one byte less executable size.

include \masm32\MasmBasic\MasmBasic.inc
.data?
rc RECT <>

  Init
  Cls
  repeats=1
rcglobal_s:
  REPEAT repeats
invoke GetWindowRect, rv(GetConsoleWindow), addr rc 
  ENDM
rcglobal_endp:
  deb 4, "Rect", rc.left, rc.top, rc.right, rc.bottom

rcreg_s:
  push esi
  mov esi, offset rc
  REPEAT repeats
invoke GetWindowRect, rv(GetConsoleWindow), esi
  ENDM
  pop esi
rcreg_endp:
  deb 4, "Rect", rc.left, rc.top, rc.right, rc.bottom
  CodeSize rcglobal
  CodeSize rcreg
EndOfCode

repeats=1:
16      bytes for rcglobal
19      bytes for rcreg
repeats=2:
32      bytes for rcglobal
31      bytes for rcreg
repeats=3:
48      bytes for rcglobal
43      bytes for rcreg
... etc ...

daydreamer

now I got curious about related question,which is best?
when calling a PROC that has loop with GDI invokes,calling from WM_PAINT when to structure up lots drawing code,I tried use two ways of make draw PROC's
1:hdc's and other handles are global variables?
2:hdc's are WM_PAINT's local variables and with invoke draw,hdc,handle2,handle3,handle4,its transferred to draw PROC?


my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

daydreamer

would be interesting to time a loop with imageblt'ing on different cpu/gpu's,because its probably gpu depending ,would be good to know
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

LordAdef