2016-11-10 20:26:46 +01:00
|
|
|
format PE console 0.8
|
2008-07-27 16:25:33 +02:00
|
|
|
include 'proc32.inc'
|
2016-11-10 20:26:46 +01:00
|
|
|
include '../../../../import.inc'
|
2008-07-27 16:25:33 +02:00
|
|
|
|
|
|
|
start:
|
2016-11-10 20:26:46 +01:00
|
|
|
invoke con_set_title, caption
|
2008-07-27 16:25:33 +02:00
|
|
|
|
|
|
|
; C-equivalent of the following code:
|
|
|
|
; for (;;)
|
|
|
|
; {
|
|
|
|
; con_write_asciiz("Enter string (empty for exit): ");
|
2009-08-27 18:05:05 +02:00
|
|
|
; if (!con_gets(s,256)) break;
|
2008-07-27 16:25:33 +02:00
|
|
|
; if (s[0] == '\n') break;
|
|
|
|
; con_write_asciiz("You entered: ");
|
|
|
|
; con_write_asciiz(s);
|
|
|
|
; }
|
|
|
|
mainloop:
|
|
|
|
push str1
|
|
|
|
call [con_write_asciiz]
|
|
|
|
push 256
|
|
|
|
push s
|
|
|
|
call [con_gets]
|
2009-08-27 18:05:05 +02:00
|
|
|
test eax, eax
|
|
|
|
jz done
|
2008-07-27 16:25:33 +02:00
|
|
|
cmp [s], 10
|
|
|
|
jz done
|
|
|
|
push str2
|
|
|
|
call [con_write_asciiz]
|
|
|
|
push s
|
|
|
|
call [con_write_asciiz]
|
|
|
|
jmp mainloop
|
|
|
|
done:
|
|
|
|
push 1
|
|
|
|
call [con_exit]
|
|
|
|
exit:
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-11-10 20:26:46 +01:00
|
|
|
align 4
|
|
|
|
data import
|
|
|
|
library console, 'console.dll'
|
|
|
|
import console, \
|
|
|
|
con_set_title, 'con_set_title', \
|
|
|
|
con_write_asciiz, 'con_write_asciiz', \
|
|
|
|
con_exit, 'con_exit', \
|
|
|
|
con_gets, 'con_gets'
|
|
|
|
end data
|
2008-07-27 16:25:33 +02:00
|
|
|
|
|
|
|
caption db 'Console test - gets()',0
|
|
|
|
str1 db 'Enter string (empty for exit): ',0
|
|
|
|
str2 db 'You entered: ',0
|
|
|
|
|
|
|
|
s rb 256
|