From 2945b2faa635c8c7534e6b4f73cea836c8b88cf5 Mon Sep 17 00:00:00 2001 From: "Andrey Halyavin (halyavin)" Date: Thu, 16 Feb 2006 06:44:47 +0000 Subject: [PATCH] optimized by size version from diamond git-svn-id: svn://kolibrios.org@47 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/end/trunk/end.asm | 184 +++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 99 deletions(-) diff --git a/programs/end/trunk/end.asm b/programs/end/trunk/end.asm index a230998439..61fd6f51e5 100644 --- a/programs/end/trunk/end.asm +++ b/programs/end/trunk/end.asm @@ -1,86 +1,16 @@ ; ; END ; +; note that 'mov al,xx' is shorter than 'mov eax,xx' +; and if we know that high 24 bits of eax are zero, we can use 1st form +; the same about ebx,ecx,edx -include "lang.inc" include "macros.inc" meos_app_start code - mov eax,40 - mov ebx,0111b - int 0x40 - - call draw_window - -still: - - mov eax,10 ; wait here for event -; mov ebx,100 - int 0x40 - - cmp eax,1 - jz red - cmp eax,2 - jz key - cmp eax,3 - jz button - - jmp still - - red: - call draw_window - jmp still - - key: - mcall 2 - cmp ah,13 - jz restart - cmp ah,27 - jz close_1 - cmp ah,180 - jz restart_kernel - cmp ah,181 - jz power_off - jmp red - - button: - mov eax,17 - int 0x40 - - cmp ah,1 - jne no_1 - power_off: - mcall 18,9,2 - jmp close_1 - -no_1: - cmp ah,3 - jne no_2 - restart: - mcall 18,9,3 - jmp close_1 - -no_2: - cmp ah,2 - jne no_4 - - restart_kernel: - mcall 18,9,4 - -no_4: - cmp ah,4 - jne still - - close_1: - or eax,-1 ; close this program - int 0x40 - - -draw_window: - - pusha +do_draw: mov eax,48 mov ebx,3 @@ -88,26 +18,27 @@ draw_window: mov edx,sizeof.system_colors int 0x40 - mov eax,12 ; tell os about redraw start - mov ebx,1 + mov al,12 ; eax=12 - tell os about redraw start + mov bl,1 int 0x40 - mov eax,14 ; get screen max x & max y + mov al,14 ; eax=14 - get screen max x & max y int 0x40 - xor ecx,ecx - mov cx,ax + movzx ecx,ax shr eax,17 - sub eax,110 +; sub eax,110 shl eax,16 - mov ebx,eax - add ebx,220 +; mov ebx,eax +; add ebx,220 + lea ebx,[eax-110*10000h+220] shr ecx,1 - sub ecx,50 +; sub ecx,50 shl ecx,16 - add ecx,100 +; add ecx,100 + sub ecx,50*10000h - 100 mov eax,0 ; define and draw window mov edx,[sc.work_button] @@ -116,20 +47,26 @@ draw_window: int 0x40 xor edx,edx - mcall 13,14 shl 16+90,25 shl 16+27 - mcall 13,117 shl 16+90, - mcall 13,14 shl 16+90,59 shl 16+27 - mcall 13,117 shl 16+90, + mov al,13 + mcall ,14 shl 16+90,25 shl 16+27 + push ebx + mcall ,117 shl 16+90, + xchg ebx,[esp] + mcall ,,59 shl 16+27 + pop ebx + mcall - mcall 8,15 shl 16+87,26 shl 16+24,1,0xdd7700 - inc dl - mcall 8,118 shl 16+87,,,0xbbbb ;cccc - inc dl - mcall 8,15 shl 16+87,60 shl 16+24,,0xbb00 - inc dl - mcall 8,118 shl 16+87,,,0xbbbbbb ;cccccc + mov al,8 + inc edx + mcall ,15 shl 16+87,26 shl 16+24,,0xdd7700 + inc edx + mcall ,118 shl 16+87,,,0xbbbb ;cccc + inc edx + mcall ,15 shl 16+87,60 shl 16+24,,0xbb00 + inc edx + mcall ,118 shl 16+87,,,0xbbbbbb ;cccccc - mov eax,4 ; 0x00000004 = write text + mov al,4 ; 0x00000004 = write text mov ebx,75*65536+10 mov ecx,[sc.work_button_text] ; 8b window nro - RR GG BB color or ecx,0x10000000 @@ -159,15 +96,64 @@ draw_window: mov esi,label5_len ; text length int 0x40 - mov eax,12 ; tell os about redraw end + mov al,12 ; tell os about redraw end mov ebx,2 int 0x40 - popa +still: - ret + mov eax,10 ; wait here for event + int 0x40 + dec eax + jz do_draw + dec eax + jnz button + key: + mov al,2 ; now eax=2 - get key code + int 40h + mov al,ah + cmp al,13 + jz restart + cmp al,27 + jz close_1 + cmp al,180 + jz restart_kernel + cmp al,181 + jz power_off + jmp still + button: + mov al,17 ; now eax=17 - get pressed button id + int 0x40 + xchg al,ah + dec eax + jz power_off + dec eax + jz restart_kernel + dec eax + jz restart +; we have only one button left, this is close button +; dec eax +; jnz still +close_1: + or eax,-1 + int 40h + + power_off: + push 2 + jmp mcall_and_close + + restart: + push 3 + jmp mcall_and_close + + restart_kernel: + push 4 +mcall_and_close: + pop ecx + mcall 18,9 + jmp close_1 data