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
sub edi,1
loop newnum
red:
call draw_window ; at first, draw the window
still:
@ -55,10 +55,6 @@ still:
jmp still
red: ; redraw
call draw_window
jmp still
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
@ -70,7 +66,7 @@ still:
cmp ah,1 ; button id=1 ?
jnz still
mov eax,-1 ; close this program
or eax,-1 ; close this program
int 0x40
@ -96,38 +92,17 @@ draw_window:
mov ebx,100*65536+200 ; [x start] *65536 + [x size]
mov ecx,100*65536+65 ; [y start] *65536 + [y size]
mov edx,[sc.work] ; color of work area RRGGBB,8->color glide
mov esi,[sc.grab] ; color of grab bar RRGGBB,8->color
or esi,0x80000000
mov edi,[sc.frame] ; color of frames RRGGBB
or edx,0x33000000 ; color of grab bar RRGGBB,8->color
mov edi,header ; WINDOW LABEL
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 edx,text
mov esi,40
newline:
mov esi,24
mov eax,4
int 0x40
add ebx,10
add edx,40
cmp [edx],byte 'x'
jnz newline
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
@ -140,12 +115,9 @@ draw_window:
text:
db 'CPU RUNNING AT MHZ '
db 'x' ; <- END MARKER, DONT DELETE
db 'CPU RUNNING AT MHZ'
labelt:
db 'CPU SPEED'
labellen:
header db 'CPU SPEED',0
I_END:

View File

@ -103,42 +103,23 @@ draw_window:
; ‘Ž‡„€ðŒ ŽŠ<C5BD>Ž
; mov eax,0 ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à]
; mov ecx,200*65536+100 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,0x02aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
; mov esi,0x805080d0 ; 梥⠯®«®áë § £®«®¢ª  RRGGBB,8->color gl
; mov edi,0x005080d0 ; 梥â à ¬ª¨ RRGGBB
; mov ecx,200*65536+50 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,0x33aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
; mov edi,header ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ<C5BD>
; 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 ebx,8 shl 16 + 30
; mov ebx,3 shl 16 + 8
; mov ecx,0
; mov edx,message
; mov esi,message.size
; int 0x40
mcall 4, <8, 30>, 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 4, <3, 8>, 0, message, message.size
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
; 2, § ª®­ç¨«¨ à¨á®¢ âì

View File

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

View File

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

View File

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