• Welcome to Powerbasic Museum 2020-B.
 

ISWIN() compared to API: IsWindow()

Started by Theo Gottwald, August 16, 2008, 01:50:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

We have another case, of two Functions which seem to do the same, but in this case we just get one call into the runtime, the execution has nearly the same speed - even if it may not look like that immediately.

Interesting is, that ISWIN() checks at runtime the number of Parameters, not at compiletime. In both cases it calls the same RUNTIME LIB and then looks how many Parameters were given.

This is our Test-Programm:


! NOP
! NOP
R01=ISWINDOW(999)
! NOP
! NOP
! NOP
! NOP
R01=ISWIN(999)
! NOP
! NOP
! NOP



This is what we get:

Quote
4024D9   NOP
4024DA   NOP ' This is the API Call to IsWindow()
4024DB   PUSH DWORD 000003E7
4024E0   CALL DWORD PTR [0040825C]
4024E6   FLDCW WORD PTR [EBP-10]
4024E9   MOV ESI, EAX
4024EB   NOP
4024EC   NOP
4024ED   NOP
4024EE   NOP ' This is the ISWIN()
4024EF   MOV ECX, DWORD 000003E7
4024F4   MOV EAX, DWORD 80000000
4024F9   CALL L40379E
4024FE   MOV ESI, EAX
402500   NOP
402501   NOP
402502   NOP
402503   JMP L402511
402508   CALL L40250E
40250D   RET NEAR

'****************************************
' This is the RUNTIME-Lib for ISWIN()
40379E   CMP EAX, DWORD 80000000 ' Check how many Parameters we got
4037A3   JZ  SHORT L4037AF ' If only one Parameter do not look for the Handle
4037A5   PUSH EAX
4037A6   PUSH ECX
4037A7   CALL DWORD PTR [00408258]
4037AD   MOV ECX, EAX
4037AF   PUSH ECX ' here the ISWIN() internally also calls the IsWindow() API
4037B0   CALL DWORD PTR [0040825C]
4037B6   TEST EAX, EAX
4037B8   JZ  SHORT L4037BF
4037BA   MOV EAX, DWORD FFFFFFFF
4037BF   RET NEAR

Conclusion: The difference here is very small but to the advantage of the API call to IsWindow(), where it can be used.
If you need to give two Parameters, the API can not be used, you need to use (and you will use best) ISWIN().