News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Re: InitCommonControlsEx() test on memory dialog.

Started by dedndave, March 19, 2011, 06:40:55 AM

Previous topic - Next topic

donkey

Hi Jochen,

Yup, no error from InitCommonControlsEx on the half stack operation and it appears to work OK but you're right the PUSHW would probably cause some trouble and the return address would be misaligned. At 15 bytes I guess Dave's POP REG version is the smallest possible then.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

when i first run it, it looks like the image on the left
after i click the Start menu, it looks like the image on the right   :lol


Antariy

Quote from: dedndave on March 20, 2011, 02:47:48 AM
when i first run it, it looks like the image on the left
after i click the Start menu, it looks like the image on the right   :lol



Cool :lol

Take notice, that there is no theming at all, as well as co-ordinates are crazy.

hutch--

 :bg


0040101D 6A00                   push    0
0040101F 6A08                   push    8
00401021 54                     push    esp
00401022 E89B030000             call    jmp_InitCommonControlsEx
00401027 83C408                 add     esp,8


13 bytes. Return value is TRUE.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

very nice Hutch
i knew we'd make a size-monger out of you   :bg

replace the add with pop ecx/pop edx and you have it in 12

hutch--

 :bg

> i knew we'd make a size-monger out of you

Deja Vu, been there, done that 20 years ago.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Antariy


extern _imp__InitCommonControlsEx@4:DWORD

push 3FFh
push 8
push esp
call _imp__InitCommonControlsEx@4
pop edx
pop edx


This will take 16 bytes. BUT, usual PROTOs make call to jump thunk, so, all other versions here actually take for 6 bytes longer space than "seeing" :wink

dedndave

admit it, Hutch - you had fun doing it   :bg

hutch--

 :bg

Nah, I don't like crap code. here is why the standard Microsoft code is more efficient, a lower instruction count.


0040101D 6A00                   push    0
0040101F 6A08                   push    8
00401021 54                     push    esp
00401022 E899030000             call    jmp_InitCommonControlsEx
00401027 58                     pop     eax
00401028 58                     pop     eax

0040101D C745E008000000         mov     dword ptr [ebp-20h],8
00401024 C745E400000000         mov     dword ptr [ebp-1Ch],0
0040102B 8D45E0                 lea     eax,[ebp-20h]
0040102E 50                     push    eax
0040102F E898030000             call    jmp_InitCommonControlsEx


When it comes to performance, instruction scheduling is the action, not code byte counts.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on March 20, 2011, 02:50:35 AM
:bg


0040101D 6A00                   push    0
0040101F 6A08                   push    8
00401021 54                     push    esp
00401022 E89B030000             call    jmp_InitCommonControlsEx
00401027 83C408                 add     esp,8


13 bytes. Return value is TRUE.

Hutch,
You are bloating your code and unnecessarily restricting the user's choice :naughty:

include \masm32\include\masm32rt.inc

.code
start: push ICC_BAR_CLASSES or ICC_HOTKEY_CLASS or ICC_LISTVIEW_CLASSES or ICC_PROGRESS_CLASS or ICC_TAB_CLASSES or ICC_TREEVIEW_CLASSES or ICC_UPDOWN_CLASS
push 8
push esp
call InitCommonControlsEx
pop edx
pop edx
icc_end:
mov ecx, icc_end
sub ecx, start
MsgBox 0, str$(ecx), chr$("That is short:"), MB_OK
exit
end start


12 bytes - test yourself :bg

hutch--

 :bg

Does that mean you read Dave's posting ?


pop edx
pop edx
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

no - i used POP ECX/POP EDX   :bg

it does mean he has carefully selected a group of flags that will yield a small push, though
i suppose we can do without ICC_ANIMATE_CLASS (80h)
but, ICC_COOL_CLASSES (400h) is a likely choice that will force a larger push
#define ICC_LISTVIEW_CLASSES   0x00000001
#define ICC_TREEVIEW_CLASSES   0x00000002
#define ICC_BAR_CLASSES        0x00000004
#define ICC_TAB_CLASSES        0x00000008
#define ICC_UPDOWN_CLASS       0x00000010
#define ICC_PROGRESS_CLASS     0x00000020
#define ICC_HOTKEY_CLASS       0x00000040
#define ICC_ANIMATE_CLASS      0x00000080
#define ICC_WIN95_CLASSES      0x000000FF
#define ICC_DATE_CLASSES       0x00000100
#define ICC_USEREX_CLASSES     0x00000200
#define ICC_COOL_CLASSES       0x00000400

#if (_WIN32_IE >= 0x0400)
#define ICC_INTERNET_CLASSES   0x00000800
#define ICC_PAGESCROLLER_CLASS 0x00001000
#define ICC_NATIVEFNTCTL_CLASS 0x00002000
#endif

#if (_WIN32_WINNT >= 0x501)
#define ICC_STANDARD_CLASSES   0x00004000
#define ICC_LINK_CLASS         0x00008000
#endif

this does not match the windows.inc file, btw

hutch--

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on March 20, 2011, 12:53:03 PM
:P

You guys must be really bored.

What can be more amusing than teasing an Aussie on a lazy Sunday afternoon?
:thumbu