new h2d2b from Alexei Ershov

updated keyascii, scancode, example 1, cpuspeed

git-svn-id: svn://kolibrios.org@317 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron 2007-02-04 01:40:26 +00:00
parent f2647d013c
commit 4256086104
5 changed files with 104 additions and 164 deletions

View File

@ -38,7 +38,7 @@ START: ; start of execution
mov [edi],dl mov [edi],dl
sub edi,1 sub edi,1
loop newnum loop newnum
red:
call draw_window ; at first, draw the window call draw_window ; at first, draw the window
still: still:
@ -55,10 +55,6 @@ still:
jmp still jmp still
red: ; redraw
call draw_window
jmp still
key: ; key key: ; key
mov eax,2 ; just read it and ignore mov eax,2 ; just read it and ignore
int 0x40 int 0x40
@ -70,7 +66,7 @@ still:
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jnz still jnz still
mov eax,-1 ; close this program or eax,-1 ; close this program
int 0x40 int 0x40
@ -96,38 +92,17 @@ draw_window:
mov ebx,100*65536+200 ; [x start] *65536 + [x size] mov ebx,100*65536+200 ; [x start] *65536 + [x size]
mov ecx,100*65536+65 ; [y start] *65536 + [y size] mov ecx,100*65536+65 ; [y start] *65536 + [y size]
mov edx,[sc.work] ; color of work area RRGGBB,8->color glide mov edx,[sc.work] ; color of work area RRGGBB,8->color glide
mov esi,[sc.grab] ; color of grab bar RRGGBB,8->color or edx,0x33000000 ; color of grab bar RRGGBB,8->color
or esi,0x80000000 mov edi,header ; WINDOW LABEL
mov edi,[sc.frame] ; color of frames RRGGBB
int 0x40 int 0x40
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,[sc.grab_text] ; color of text RRGGBB
or ecx,0x10000000
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,(200-17)*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,[sc.grab_button] ; button color RRGGBB
int 0x40
mov ebx,25*65536+35 ; draw info text with function 4 mov ebx,20*65536+14 ; draw info text with function 4
mov ecx,[sc.work_text] mov ecx,[sc.work_text]
mov edx,text mov edx,text
mov esi,40 mov esi,24
newline:
mov eax,4 mov eax,4
int 0x40 int 0x40
add ebx,10
add edx,40
cmp [edx],byte 'x'
jnz newline
mov eax,12 ; function 12:tell os about windowdraw mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw mov ebx,2 ; 2, end of draw
@ -141,11 +116,8 @@ draw_window:
text: text:
db 'CPU RUNNING AT MHZ' db 'CPU RUNNING AT MHZ'
db 'x' ; <- END MARKER, DONT DELETE
labelt: header db 'CPU SPEED',0
db 'CPU SPEED'
labellen:
I_END: I_END:

View File

@ -103,42 +103,23 @@ draw_window:
; ‘Ž‡„€ðŒ ŽŠ<C5BD>Ž ; ‘Ž‡„€ðŒ ŽŠ<C5BD>Ž
; mov eax,0 ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­® ; mov eax,0 ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à] ; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à]
; mov ecx,200*65536+100 ; [y áâ àâ] *65536 + [y à §¬¥à] ; mov ecx,200*65536+50 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,0x02aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl ; mov edx,0x33aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
; mov esi,0x805080d0 ; 梥⠯®«®áë § £®«®¢ª  RRGGBB,8->color gl ; mov edi,header ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ<C5BD>
; mov edi,0x005080d0 ; 梥â à ¬ª¨ RRGGBB
; int 0x40 ; int 0x40
mcall 0, <200,200>, <200,50>, 0x02AABBCC, 0x805080D0, 0x005080D0 mcall 0, <200,200>, <200,50>, 0x33AABBCC,,header
; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ<C5BD>
; mov eax,4 ; äã­ªæ¨ï 4 : ­ ¯¨á âì ¢ ®ª­¥ ⥪áâ
; mov ebx,8*65536+8 ; [x] *65536 + [y]
; mov ecx,0x10ddeeff ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
; mov edx,header ;  ¤à¥á áâப¨
; mov esi,header.size ; ¨ ¥ñ ¤«¨­ 
; int 0x40
mcall 4, <8,8>, 0x10DDEEFF, header, header.size
; mov eax,4 ; mov eax,4
; mov ebx,8 shl 16 + 30 ; mov ebx,3 shl 16 + 8
; mov ecx,0 ; mov ecx,0
; mov edx,message ; mov edx,message
; mov esi,message.size ; mov esi,message.size
; int 0x40 ; int 0x40
mcall 4, <8, 30>, 0, message, message.size mcall 4, <3, 8>, 0, message, message.size
; Š<>Ž<EFBFBD>Š€ ‡€Š<E282AC>ˆŸ ŽŠ<C5BD>
; mov eax,8 ; äã­ªæ¨ï 8 : ®¯à¥¤¥«¨âì ¨ ­ à¨á®¢ âì ª­®¯ªã
; mov ebx,(200-19)*65536+12 ; [x áâ àâ] *65536 + [x à §¬¥à]
; mov ecx,5*65536+12 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,1 ; ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨ - 1
; mov esi,0x6688dd ; 梥⠪­®¯ª¨ RRGGBB
; int 0x40
mcall 8, <200-19, 12>, <5, 12>, 1, 0x6688DD
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­  mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
; 2, § ª®­ç¨«¨ à¨á®¢ âì ; 2, § ª®­ç¨«¨ à¨á®¢ âì

View File

@ -1,3 +1,6 @@
;; hex2dec2bin 0.2 by Alexei Ershov ;;
;; 16.11.2006 ;;
use32 ; включить 32-битный режим ассемблера use32 ; включить 32-битный режим ассемблера
org 0x0 ; адресация с нуля org 0x0 ; адресация с нуля
@ -10,8 +13,7 @@
dd 0x0 ; адрес буфера для параметров (не используется) dd 0x0 ; адрес буфера для параметров (не используется)
dd 0x0 ; зарезервировано dd 0x0 ; зарезервировано
include 'lang.inc' include 'MACROS.INC' ; ìàêðîñû îáëåã÷àþò æèçíü àññåìáëåðùèêîâ!
include 'macros.inc' ; ìàêðîñû îáëåã÷àþò æèçíü àññåìáëåðùèêîâ!
START: START:
@ -109,8 +111,13 @@ next_digit:
jmp next_digit jmp next_digit
.done: .done:
mov [num], eax mov [num], eax ; ñîõðàíÿåì ââåäåííîå ÷èñëî
xor eax, eax
mov al, ' '
mov edi, string1
mov [index], edi
mov ecx, string1_end-string1
rep stosb ; ñòèðàåì ââåäåííóþ ñòðîêó
jmp red jmp red
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@ -118,48 +125,66 @@ next_digit:
button: button:
mcall 17 ; 17 - получить идентификатор нажатой кнопки mcall 17 ; 17 - получить идентификатор нажатой кнопки
cmp ah, 1 ; если НЕ нажата кнопка с номером 1, cmp ah, 1 ; если НЕ нажата кнопка с номером 1,
jne still ; âåðíóòüñÿ jne @f
mcall -1
.exit: @@:
mcall -1 ; èíà÷å êîíåö ïðîãðàììû cmp ah, 2
jne @f
shl [num], 1
jmp red
@@:
cmp ah, 3
jne @f
shr [num], 1
jmp red
@@:
cmp ah, 4
jne still
sar [num], 1
jmp red
;------------------------------------------------
draw_window: draw_window:
;------------------------------------------------
mcall 12, 1 mcall 12, 1
mcall 0, 200*65536+300, 200*65536+120, 0x02AABBCC, 0x805080D0, 0x005080D0 mcall 0, 200*65536+300, 200*65536+175, 0x13AABBCC,,header
mcall 4, 8*65536+8, 0x10DDEEFF, header, header_e - header
mcall , 15*65536+100, 0, numstr, 7 mcall 8, 15 *65536+ 38, 90*65536+ 15, 2, 0x6688DD ; êíîïêà shl
mcall , 15*65536+72, , hexstr, 4 mcall , ,110*65536+ 15, , ; êíîïêà sal
mcall , (300-53)*65536+ 38, 90*65536+ 15, 3, ; êíîïêà shr
mcall , ,110*65536+ 15, 4, ; êíîïêà sar
mcall 4, 15*65536+30, 0x80000000, binstr,
mcall , 15*65536+44, , decstr, mcall , 15*65536+44, , decstr,
mcall , 15*65536+30, , binstr, mcall , 15*65536+58, ,sdecstr,
mcall , 15*65536+58, ,sdecstr, 10 mcall , 15*65536+72, , hexstr,
mcall , 15*65536+150, , numstr,
mcall 8, (300-19)*65536+ 12, 5*65536+ 12, 1, 0x6688DD
mcall , 25*65536+93,0x10000000,shlstr,3
mcall , (300-43)*65536+93, , shrstr,
mcall , 25*65536+113, , salstr,
mcall , (300-43)*65536+113, , sarstr,
mov ecx, [num] mov ecx, [num]
mcall 47, 8*65536+256,,240*65536+72,0 ; 16-ная mcall 47, 8*65536+256,,240*65536+72,0 ; 16-ная
mcall , 10*65536, ,228*65536+44, ; 10-ная mcall , 10*65536, ,228*65536+44, ; 10-ная
mcall , 8*65536+512,,240*65536+30, ; 2-ная mcall , 8*65536+512,,240*65536+30, ; 2-ная
ror ecx, 8 ror ecx, 8
mcall , 8*65536+512,,(240-56)*65536+30, mcall , ,,(240-56)*65536+30,
ror ecx, 8 ror ecx, 8
mcall , 8*65536+512,,(240-56*2)*65536+30, mcall , ,,(240-56*2)*65536+30,
ror ecx, 8 ror ecx, 8
mcall , 8*65536+512,,(240-56*3)*65536+30, mcall , ,,(240-56*3)*65536+30,
ror ecx, 8 ror ecx, 8
mov byte [minus], '+' mov [minus], '+'
jnc @f jnc @f
mov byte [minus], '-' mov [minus], '-'
neg ecx neg ecx
@@: @@:
mcall , 10*65536,,228*65536+58, ; 10-ная со знаком mcall , 10*65536,,228*65536+58, ; 10-ная со знаком
mcall 4, 222*65536+58, 0, minus, 1 mcall 4, 222*65536+58, 0, minus, 1
mcall 38, 15*65536+300-15, 137*65536+137, 0x006688DD
call Draw_String call Draw_String
mcall 12, 2 ; функция 12: сообщить ОС об отрисовке окна mcall 12, 2 ; функция 12: сообщить ОС об отрисовке окна
ret ret
@ -167,18 +192,9 @@ ret
;------------------------------------------------- ;-------------------------------------------------
Draw_String: Draw_String:
;------------------------------------------------- ;-------------------------------------------------
mov eax, 13
mov ebx, 60*65536+ 6*33
mov ecx, 100*65536+ 9
mov edx, 0x02AABBCC
int 0x40
mov eax,4 mcall 4, 60*65536+150, 0x40A40473, \
mov ebx,60*65536+100 string1,string1_end-string1,0x00AABBCC
mov ecx,0xA40473
mov edx,string1
mov esi,33
int 0x40
ret ret
;------------------------------------------------- ;-------------------------------------------------
@ -223,13 +239,16 @@ string1_end:
num dd 0 num dd 0
header db 'hex2dec2bin' header db 'hex2dec2bin 0.2',0
header_e:
minus db '-' minus db '-'
numstr db 'Number:' numstr db 'Number:',0
hexstr db 'hex:' hexstr db 'hex:',0
binstr db 'bin:' binstr db 'bin:',0
decstr db 'dec:' decstr db 'dec:',0
sdecstr db 'signed dec:' sdecstr db 'signed dec:',0
shlstr db 'shl'
salstr db 'sal'
shrstr db 'shr'
sarstr db 'sar'
I_END: ; метка конца программы I_END: ; метка конца программы

View File

@ -18,7 +18,7 @@ include 'lang.inc'
include 'macros.inc' include 'macros.inc'
START: ; start of execution START: ; start of execution
red:
call draw_window call draw_window
still: still:
@ -35,10 +35,6 @@ still:
jmp still jmp still
red: ; redraw
call draw_window
jmp still
key: ; key key: ; key
mov eax,2 ; just read it and ignore mov eax,2 ; just read it and ignore
int 0x40 int 0x40
@ -53,7 +49,7 @@ still:
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jne noclose jne noclose
mov eax,-1 ; close this program or eax,-1 ; close this program
int 0x40 int 0x40
noclose: noclose:
@ -78,20 +74,14 @@ draw_window:
mov eax,0 ; function 0 : define and draw window mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+270 ; [x start] *65536 + [x size] mov ebx,100*65536+270 ; [x start] *65536 + [x size]
mov ecx,100*65536+80 ; [y start] *65536 + [y size] mov ecx,100*65536+80 ; [y start] *65536 + [y size]
mov edx,0x83ffffff ; color of work area RRGGBB,8->color gl mov edx,0x33ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl mov edi,header
mov edi,0x005080d0 ; color of frames RRGGBB
int 0x40 int 0x40
mov eax,4 ; function 4 : write text to window mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start] xor ecx,ecx
mov ecx,0x00ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
xor ecx,0xFFFFFF
mov esi,4 mov esi,4
add ebx,23 mov ebx,8*65536+8
mov edx,tdec mov edx,tdec
int 0x40 int 0x40
add ebx,23 add ebx,23
@ -101,7 +91,7 @@ draw_window:
mov ecx,[keyid] mov ecx,[keyid]
mov eax,47 mov eax,47
mov ebx,3*65536 mov ebx,3*65536
mov edx,40*65536+31 mov edx,40*65536+8
mov esi,0x224466 mov esi,0x224466
int 0x40 int 0x40
add edx,23 add edx,23
@ -119,9 +109,7 @@ draw_window:
tdec: db 'DEC:' tdec: db 'DEC:'
thex: db 'HEX:' thex: db 'HEX:'
labelt: header db 'KEYBOARD ASCIICODES-PRESS ANY KEY',0
db 'KEYBOARD ASCIICODES-PRESS ANY KEY'
labellen:dd 0
keyid: db 0 keyid: db 0
I_END: I_END:

View File

@ -30,7 +30,7 @@ START: ; start of execution
mov ecx,1 ; base keymap mov ecx,1 ; base keymap
mov edx,keymap mov edx,keymap
int 0x40 int 0x40
red:
call draw_window call draw_window
still: still:
@ -48,11 +48,6 @@ still:
jmp still jmp still
red: ; redraw
call draw_window
jmp still
key: ; key key: ; key
mov eax,2 ; just read it and ignore mov eax,2 ; just read it and ignore
int 0x40 int 0x40
@ -167,24 +162,13 @@ draw_window:
mov ebx, 100*65536+200 ; [x start] *65536 + [x size] mov ebx, 100*65536+200 ; [x start] *65536 + [x size]
mov ecx, 100*65536+275 ; [y start] *65536 + [y size] mov ecx, 100*65536+275 ; [y start] *65536 + [y size]
mov edx, [sc.work] ; color of work area RRGGBB,8->color gl mov edx, [sc.work] ; color of work area RRGGBB,8->color gl
or edx, 0x03000000 or edx, 0x33000000
mov esi, [sc.grab] ; color of grab bar RRGGBB,8->color gl mov edi, header ; WINDOW LABEL
or esi, 0x80000000
mov edi, [sc.frame] ; color of frames RRGGBB
int 0x40
; WINDOW LABEL
mov eax, 4 ; function 4 : write text to window
mov ebx, 8*65536+8 ; [x start] *65536 + [y start]
mov ecx, [sc.grab_text] ; font 1 & color ( 0xF0RRGGBB )
or ecx, 0x10000000
mov edx, header ; pointer to text beginning
mov esi, header.len ; text length
int 0x40 int 0x40
mov eax, 4 mov eax, 4
mov ebx, 20*65536+35 mov ebx, 15*65536+10
mov ecx, 0 xor ecx, ecx
mov edx, text mov edx, text
mov esi, text.len mov esi, text.len
int 0x40 int 0x40
@ -202,7 +186,7 @@ draw_codes:
mov eax,47 mov eax,47
mov ebx,6*65536 mov ebx,6*65536
mov edx,20*65536+60 mov edx,15*65536+35
mov edi,0 mov edi,0
mov esi,0 mov esi,0
newscan: newscan:
@ -211,7 +195,7 @@ draw_codes:
shl ecx,16 shl ecx,16
add ecx,10 add ecx,10
mov eax,13 ; filled rectangle mov eax,13 ; filled rectangle
mov ebx,20*65536+160 mov ebx,15*65536+160
mov edx,[sc.work] mov edx,[sc.work]
int 0x40 int 0x40
popa popa
@ -307,17 +291,13 @@ if lang eq ru
db '‘—ˆ’›‚€ž „€<E2809E><E282AC> Šˆ<E28099>' db '‘—ˆ’›‚€ž „€<E2809E><E282AC> Šˆ<E28099>'
.len = $ - text .len = $ - text
header: header db 'Š€<C5A0>ŠŽ„ Šˆ<E28099>',0
db 'Š€<C5A0>ŠŽ„ Šˆ<E28099>'
.len = $ - header
else else
text: text:
db 'READING RAW SCANCODE DATA' db 'READING RAW SCANCODE DATA'
.len = $ - text .len = $ - text
header: header db 'KEYBOARD SCANCODES',0
db 'KEYBOARD SCANCODES'
.len = $ - header
end if end if
ext db 0x0 ext db 0x0