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\LOADDLL new version:

.586
.model flat,stdcall
option casemap:none
include C:\masm32\include\windows.inc
include C:\masm32\include\user32.inc
include C:\masm32\include\kernel32.inc
includelib C:\masm32\lib\kernel32.lib
includelib C:\masm32\lib\user32.lib
includelib tstdll.lib

;---------------------------------------------------------------------------------
;this lib was created when tstdll.dll was assembled
;----------------------------------------------------------------------------------

TestProc PROTO ;the test function prototype


;=============
;Local prototypes
;=============
WinMain PROTO
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
TheMsg db "Assembler, Pure & Simple",0
Butn1 db "Call DLL Function",0
szDisplayName db "Load DLL at Startup",0
btnClass db 'button',0
ClassName db 1,0

wc WNDCLASSEX 
.data?

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

start:

	invoke WinMain
	call ExitProcess

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

WinMain proc uses ebx esi edi  	
mov edi, offset msg
xor ebx,ebx
;==========================================
;Fill WNDCLASSEX structure with requered variables
;==========================================
invoke LoadIcon,hInstance,500 ;icon ID
mov wc.hIcon,eax
invoke LoadCursor,ebx,IDC_ARROW
mov wc.hCursor,eax


invoke RegisterClassEx, ADDR wc

;===========================
;Center window at following size
;===========================

Wwd equ 500
Wht equ 350


invoke GetSystemMetrics,SM_CXSCREEN
mov esi,eax

invoke GetSystemMetrics,SM_CYSCREEN
shr esi,1
shr eax,1
sub esi,Wwd /2
sub eax,Wht /2

invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
	addr ClassName,
	addr szDisplayName,
	WS_OVERLAPPEDWINDOW or WS_VISIBLE,
	esi,eax,Wwd,Wht,
	ebx,ebx,hInstance,ebx

;mov hWnd,eax


;=================================
;Loop until PostQuiteMessage is sent
;=================================

StartLoop:

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

ExitLoop:

	ret
WinMain endp

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

WndProc proc uses ebx	hWin :DWORD,
		uMsg :DWORD,
		wParam :DWORD,
		lParam :DWORD
	mov eax,uMsg
	mov ebx,hWin
.IF eax == WM_COMMAND
;======== menu commands =============

	mov eax,wParam
	or al,al
	jz cmdExit
	jp cmdAbout

	invoke TestProc
	
 ;======= end menu com
Posted on 2001-04-19 08:24:00 by The Svin