Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;    Stack Status Monitor
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6.    
  7. use32
  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
  16.    
  17. include 'lang.inc'
  18. include '..\..\..\macros.inc'
  19.    
  20. START:                          ; start of execution
  21.  
  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
  27.     mcall
  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
  41.  mcall
  42.    
  43.  mov  ebx, text + 24
  44.  call printhex
  45.    
  46.  mov  eax, 53
  47.  mov  ebx, 255
  48.  mov  ecx, 2
  49.  mcall
  50.    
  51.  mov  ebx, text + 107
  52.  call printhex
  53.    
  54.  mov  eax, 53
  55.  mov  ebx, 255
  56.  mov  ecx, 5
  57.  mcall
  58.    
  59.  mov  ebx, text + 107 + 40
  60.  call printhex
  61.    
  62.  mov  eax, 53
  63.  mov  ebx, 255
  64.  mov  ecx, 4
  65.  mcall
  66.    
  67.  mov  ebx, text + 107 + 80
  68.  call printhex
  69.    
  70.  mov  eax, 53
  71.  mov  ebx, 255
  72.  mov  ecx, 100
  73.  mcall
  74.    
  75.  mov  ebx, text + 258
  76.  call printhex
  77.    
  78.  mov  eax, 53
  79.  mov  ebx, 255
  80.  mov  ecx, 101
  81.  mcall
  82.    
  83.  mov  ebx, text + 258 + 40
  84.  call printhex
  85.    
  86.  mov  eax, 53
  87.  mov  ebx, 255
  88.  mov  ecx, 102
  89.  mcall
  90.    
  91.  mov  ebx, text + 258 + 80
  92.  call printhex
  93.    
  94.  mov  eax, 53
  95.  mov  ebx, 255
  96.  mov  ecx, 103
  97.  mcall
  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
  108.     mcall
  109.     jmp  still
  110.    
  111. button:                        ; button
  112.     mov  eax,17                 ; get id
  113.     mcall
  114.    
  115.     cmp  ah,1                   ; button id=1 ?
  116.     jnz  still
  117.    
  118.     or  eax,-1                 ; close this program
  119.     mcall
  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
  135.     mcall
  136.    
  137.                                    ; DRAW WINDOW
  138.     xor  eax,eax                   ; function 0 : define and draw window
  139.     mov  ebx,100*65536+260         ; [x start] *65536 + [x size]
  140.     mov  ecx,100*65536+205         ; [y start] *65536 + [y size]
  141.     mov  edx,0x13224466            ; color of work area RRGGBB
  142.     mov  edi,title                 ; WINDOW LABEL
  143.     mcall
  144.    
  145.                                  
  146.     ; Re-draw the screen text
  147.     cld
  148.     mov  eax,4
  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:
  154.     mcall
  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
  163.     mcall
  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.    
  206. title    db   'Stack Status',0
  207.    
  208. hextable db '0123456789ABCDEF'
  209.    
  210.    
  211. I_END:
  212.    
  213.    
  214.    
  215.    
  216.    
  217.    
  218.    
  219.