It takes a lot of time for me to comment opt. examples is English. Not the same with optimizations themselves. Usually 10 - 15 mitutes for avaradge 150-300 lines demo. I post it without comments, all of them will come later when I have a little more time. So your work is: 1. Compile these versions. 2. Disassemble the originals (MASM32 examples) 3. Compare disassembled code from old and new virsions meaning: - Size of opcodes to perform tasks in programs versions that are being compared. - Clocks to perform instructions - Main! In your mind or in debugger or with pancel and paper step trough particular parts performing tasks and compare how many steps will take each implementation. Remember - for assembler programmer there is no "black box" - the black box is only things that you decided to be "black boxes". Before going on discussion on "black boxes" of inner Windows jobs, at least do simplest thing - always have clear picture what code HLL masm statements produced. And circle callback procs in your mind processing messages. (For example if you use SendMessage in callback proc sending msg to this very window - MIND that this msg will be processed by THIS VERY PROC - and if there is no code to process this message - it will end to DefWindowProc in this very code. Or ret with eax = true in DlgProc) By no means new versions is optimized to death code - just most unefficient and common places changed. Original MASM32\EXAMPLE1\DLL\CALLDLL new version:

;######################################
.586
.model flat, stdcall
option casemap :none ;case sensitive

;######################################

	include c:\masm32\include\windows.inc
	include C:\masm32\include\user32.inc
	include C:\masm32\include\kernel32.inc

	includelib user32.lib
	includelib kernel32.lib

;#########################################


	;================
	;Local prototypes
	;================

WinMain PROTO

WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY	PROTO :DWORD,:DWORD
PushButton  PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

.data
szDisplayName 	db 'Direct Call DLL',0
lpszClassName	db 1,0
libName 		db 'tstdll.dll',0
FuncName 	db 'TestProc',0
TheMsg		db "Assembler, Pure & Simple",0
Butn1		db  "Call DLL Direct",0
btclass		db "BUTTON",0
bttext		db "Call DLL Direct",0
TheText		db "Please Confirm Exit",0

wc	WNDCLASSEX
.data?
hWnd		dd ?
hInstance	 equ 400000h
msg MSG <>
.code

start:

	invoke WinMain
	call ExitProcess

;###########################################################

WinMain proc 


;==========================================
;Fill WNDCLASSEX structure with required variables
;==========================================

invoke LoadIcon,hInstance,500 ;icon ID
mov wc.hIcon,eax
invoke LoadCursor,0,IDC_ARROW
mov wc.hCursor,eax

xor ebx,ebx

invoke RegisterClassEx,ADDR wc
push eax
;==========================
;Center window at following size
;==========================

invoke GetSystemMetrics,SM_CXSCREEN
mov esi,eax

invoke GetSystemMetrics,SM_CYSCREEN
 shr esi,1
 shr eax,1
 sub eax,350/2
 sub esi,500/2
 pop edx

invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
	edx,
	addr szDisplayName,
	WS_OVERLAPPEDWINDOW or WS_VISIBLE,
	esi,eax,500,350,
	ebx,ebx,hInstance,ebx
mov hWnd,eax

;=============================
;Loop until PostQuitMessage is sent
;=============================
 mov esi,offset msg
StartLoop:

 invoke GetMessage,esi,NULL,ebx,ebx
 or eax,eax
 je ExitLoop
 invoke TranslateMessage,esi
 invoke DispatchMessage,esi
 jmp StartLoop

ExitLoop:

	ret

WinMain endp
;####################################################################

WndProc  proc uses esi edi 	 hWin :DWORD,
		       	uMsg :DWORD,
	        	       	wParam :DWORD,
		       	lParam :DWORD
LOCAL hLib :DWORD
 mov esi,wParam
 mov eax,uMsg
 mov edi,hWin
.IF eax == WM_COMMAND
;==
Posted on 2001-04-19 08:20:00 by The Svin