Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;    Stack Status Monitor
3
;
4
;    Compile with FASM for Menuet
5
;
6
 
7
use32
485 heavyiron 8
 org	0x0
9
 db	'MENUET01'    ; header
10
 dd	0x01	      ; header version
11
 dd	START	      ; entry point
12
 dd	I_END	      ; image size
13
 dd	I_END+0x10000 ; required memory
14
 dd	I_END+0x10000 ; esp
15
 dd	0x0 , 0x0     ; I_Param , I_Path
31 halyavin 16
 
17
include 'lang.inc'
485 heavyiron 18
include '..\..\..\macros.inc'
31 halyavin 19
 
20
START:                          ; start of execution
485 heavyiron 21
 
31 halyavin 22
    call draw_window            ; at first, draw the window
23
 
24
still:
25
    mov  eax,23                 ; wait here for event
26
    mov  ebx,200    ; Time out after 2s
485 heavyiron 27
    mcall
31 halyavin 28
 
29
    cmp  eax,1                  ; redraw request ?
30
    jz   red
31
    cmp  eax,2                  ; key in buffer ?
32
    jz   key
33
    cmp  eax,3                  ; button in buffer ?
34
    jz   button
35
 
36
 ; read the stack status data, and write it to the screen buffer
37
 
38
 mov  eax, 53
39
 mov  ebx, 255
40
 mov  ecx, 6
485 heavyiron 41
 mcall
31 halyavin 42
 
43
 mov  ebx, text + 24
44
 call printhex
45
 
46
 mov  eax, 53
47
 mov  ebx, 255
48
 mov  ecx, 2
485 heavyiron 49
 mcall
31 halyavin 50
 
51
 mov  ebx, text + 107
52
 call printhex
53
 
54
 mov  eax, 53
55
 mov  ebx, 255
56
 mov  ecx, 5
485 heavyiron 57
 mcall
31 halyavin 58
 
59
 mov  ebx, text + 107 + 40
60
 call printhex
61
 
62
 mov  eax, 53
63
 mov  ebx, 255
64
 mov  ecx, 4
485 heavyiron 65
 mcall
31 halyavin 66
 
67
 mov  ebx, text + 107 + 80
68
 call printhex
69
 
70
 mov  eax, 53
71
 mov  ebx, 255
72
 mov  ecx, 100
485 heavyiron 73
 mcall
31 halyavin 74
 
75
 mov  ebx, text + 258
76
 call printhex
77
 
78
 mov  eax, 53
79
 mov  ebx, 255
80
 mov  ecx, 101
485 heavyiron 81
 mcall
31 halyavin 82
 
83
 mov  ebx, text + 258 + 40
84
 call printhex
85
 
86
 mov  eax, 53
87
 mov  ebx, 255
88
 mov  ecx, 102
485 heavyiron 89
 mcall
31 halyavin 90
 
91
 mov  ebx, text + 258 + 80
92
 call printhex
93
 
94
 mov  eax, 53
95
 mov  ebx, 255
96
 mov  ecx, 103
485 heavyiron 97
 mcall
31 halyavin 98
 
99
 mov  ebx, text + 258 + 120
100
 call printhex
101
 
102
red:                           ; redraw
103
    call draw_window
104
    jmp  still
105
 
106
key:                           ; Keys are not valid at this part of the
107
    mov  eax,2                  ; loop. Just read it and ignore
485 heavyiron 108
    mcall
31 halyavin 109
    jmp  still
110
 
111
button:                        ; button
112
    mov  eax,17                 ; get id
485 heavyiron 113
    mcall
31 halyavin 114
 
115
    cmp  ah,1                   ; button id=1 ?
116
    jnz  still
117
 
485 heavyiron 118
    or  eax,-1                 ; close this program
119
    mcall
31 halyavin 120
 
121
    jmp  still
122
 
123
 
124
 
125
 
126
;   *********************************************
127
;   *******  WINDOW DEFINITIONS AND DRAW ********
128
;   *********************************************
129
 
130
 
131
draw_window:
132
 
133
    mov  eax,12                    ; function 12:tell os about windowdraw
134
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 135
    mcall
31 halyavin 136
 
137
                                   ; DRAW WINDOW
485 heavyiron 138
    xor  eax,eax                   ; function 0 : define and draw window
31 halyavin 139
    mov  ebx,100*65536+260         ; [x start] *65536 + [x size]
140
    mov  ecx,100*65536+205         ; [y start] *65536 + [y size]
551 spraid 141
    mov  edx,0x14224466            ; color of work area RRGGBB
485 heavyiron 142
    mov  edi,title                 ; WINDOW LABEL
143
    mcall
31 halyavin 144
 
485 heavyiron 145
 
31 halyavin 146
    ; Re-draw the screen text
147
    cld
485 heavyiron 148
    mov  eax,4
31 halyavin 149
    mov  ebx,25*65536+35           ; draw info text with function 4
150
    mov  ecx,0xffffff
151
    mov  edx,text
152
    mov  esi,40
153
  newline:
485 heavyiron 154
    mcall
31 halyavin 155
    add  ebx,16
156
    add  edx,40
157
    cmp  [edx],byte 'x'
158
    jnz  newline
159
 
160
 
161
    mov  eax,12                    ; function 12:tell os about windowdraw
162
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 163
    mcall
31 halyavin 164
 
165
    ret
166
 
167
; Taken from PS.ASM
168
printhex:
169
; number in eax
170
; print to ebx
171
; xlat from hextable
172
 pusha
173
 mov esi, ebx
174
 add esi, 8
175
 mov ebx, hextable
176
 mov ecx, 8
177
phex_loop:
178
 mov edx, eax
179
 and eax, 15
180
 xlatb
181
 mov [esi], al
182
 mov eax, edx
183
 shr eax, 4
184
 dec esi
185
 loop phex_loop
186
 popa
187
 ret
188
 
189
 
190
; DATA AREA
191
 
192
text:
193
    db ' Ethernet card status : xxxxxxxx        '
194
    db '                                        '
195
    db ' IP packets received :     xxxxxxxx     '
196
    db ' ARP packets received :    xxxxxxxx     '
197
    db ' Dumped received packets : xxxxxxxx     '
198
    db '                                        '
199
    db ' EMPTY QUEUE    : xxxxxxxx              '
200
    db ' IPOUT QUEUE    : xxxxxxxx              '
201
    db ' IPIN  QUEUE    : xxxxxxxx              '
202
    db ' NET1OUT QUEUE  : xxxxxxxx              '
203
    db 'x <- END MARKER, DONT DELETE            '
204
 
205
 
485 heavyiron 206
title    db   'Stack Status',0
31 halyavin 207
 
208
hextable db '0123456789ABCDEF'
209
 
210
 
211
I_END:
212