Subversion Repositories Kolibri OS

Rev

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

  1. format PE console 0.8
  2. include 'proc32.inc'
  3. include '../../../../import.inc'
  4.  
  5. start:
  6.         invoke  con_set_title, caption
  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]
  39.         test    eax, eax
  40.         jz      done
  41.         push    eax
  42.         push    eax
  43.         push    string_extended
  44.         jmp     @b
  45. done:
  46.         push    1
  47.         call    [con_exit]
  48. exit:
  49.         xor     eax, eax
  50.         ret
  51.  
  52. align 4
  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
  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
  66.