Subversion Repositories Kolibri OS

Rev

Rev 1145 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6699 clevermous 1
format PE console 0.8
836 diamond 2
include 'proc32.inc'
6699 clevermous 3
include '../../../../import.inc'
836 diamond 4
 
5
start:
6699 clevermous 6
        invoke  con_set_title, caption
836 diamond 7
 
8
; C-equivalent of the following code:
9
; con_printf(start_string);
10
; int c;
11
; while ((c=con_getch())!=27) // Esc=exit
12
; {
13
;   if (c)
14
;     con_printf("normal character with code %d=0x%02X\n",c,c);
15
;   else
16
;   {
17
;     c=con_getch();
18
;     con_printf("extended character with code %d=0x%02X\n",c,c);
19
;   }
20
; }
21
        push    start_string
22
        call    [con_printf]
23
        pop     ecx
24
mainloop:
25
        call    [con_getch]
26
        cmp     al, 27
27
        jz      done
28
        test    eax, eax
29
        jz      extended
30
        push    eax
31
        push    eax
32
        push    string_normal
33
@@:
34
        call    [con_printf]
35
        add     esp, 12
36
        jmp     mainloop
37
extended:
38
        call    [con_getch]
1145 diamond 39
        test    eax, eax
40
        jz      done
836 diamond 41
        push    eax
42
        push    eax
43
        push    string_extended
44
        jmp     @b
45
done:
46
        push    1
47
        call    [con_exit]
48
exit:
6699 clevermous 49
	xor	eax, eax
50
	ret
836 diamond 51
 
52
align 4
6699 clevermous 53
data import
54
library console, 'console.dll'
55
import console, \
56
        con_set_title, 'con_set_title', \
57
        con_printf, 'con_printf', \
58
        con_exit, 'con_exit', \
59
        con_getch, 'con_getch'
60
end data
836 diamond 61
 
62
caption            db 'Console test - getch()',0
63
start_string       db 'Press any key to see its code, or Esc to exit',10,0
64
string_normal      db 'normal character with code %d=0x%02X',10,0
65
string_extended    db 'extended character with code %d=0x%02X',10,0