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. ; for (;;)
  10. ; {
  11. ;   con_write_asciiz("Enter string (empty for exit): ");
  12. ;   if (!con_gets(s,256)) break;
  13. ;   if (s[0] == '\n') break;
  14. ;   con_write_asciiz("You entered: ");
  15. ;   con_write_asciiz(s);
  16. ; }
  17. mainloop:
  18.         push    str1
  19.         call    [con_write_asciiz]
  20.         push    256
  21.         push    s
  22.         call    [con_gets]
  23.         test    eax, eax
  24.         jz      done
  25.         cmp     [s], 10
  26.         jz      done
  27.         push    str2
  28.         call    [con_write_asciiz]
  29.         push    s
  30.         call    [con_write_asciiz]
  31.         jmp     mainloop
  32. done:
  33.         push    1
  34.         call    [con_exit]
  35. exit:
  36.         xor     eax, eax
  37.         ret
  38.  
  39.  
  40. align 4
  41. data import
  42. library console, 'console.dll'
  43. import console, \
  44.         con_set_title, 'con_set_title', \
  45.         con_write_asciiz, 'con_write_asciiz', \
  46.         con_exit, 'con_exit', \
  47.         con_gets, 'con_gets'
  48. end data
  49.  
  50. caption            db 'Console test - gets()',0
  51. str1               db 'Enter string (empty for exit): ',0
  52. str2               db 'You entered: ',0
  53.  
  54. s rb 256
  55.