This is just a toy program, but i want to share it here so i can receive (if any get bother) any kind of feedback... :biggrin:
What i found funny is that the program will respond only to a carriage return (even ignores ctrl+c).
Sorry if i didn't commented the code, but it's too late here and i got to sleep now. But it's a toy program so of course, you don't need such thing :biggrin:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data?
hConsoleOutput dd ?
hConsoleInput dd ?
NumberOfCharsWritten dd ?
NumberOfCharsRead dd ?
.data
BufferOut db "Hello Masm32 sdk forum!",0dh,0ah
BufferIn db " "
.code
start:
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov hConsoleOutput,eax
invoke WriteConsole,hConsoleOutput,offset BufferOut,sizeof BufferOut,offset NumberOfCharsWritten,NULL
invoke GetStdHandle,STD_INPUT_HANDLE
mov hConsoleInput,eax
invoke SetConsoleMode,hConsoleInput,ENABLE_LINE_INPUT
invoke ReadConsole,hConsoleInput,offset BufferIn,sizeof BufferIn,offset NumberOfCharsRead,NULL
invoke ExitProcess,0
end start
Quote from: felipe on June 07, 2017, 02:47:20 PMWhat i found funny is that the program will respond only to a carriage return (even ignores ctrl+c).
Why is that funny? You explicitly asked for it, see ENABLE_LINE_INPUT :P
P.S.: In contrast, C getchar() is really a misnomer:
#include <conio.h>
#pragma comment(linker, "/subsystem:console" )
int main(int argc, char* argv[]) {
printf("Hit any char:");
getchar(); // not 'any char' - it works with exactly one key...
}
Quote from: jj2007 on June 07, 2017, 06:42:48 PM
Quote from: felipe on June 07, 2017, 02:47:20 PMWhat i found funny is that the program will respond only to a carriage return (even ignores ctrl+c).
Why is that funny? You explicitly asked for it, see ENABLE_LINE_INPUT :P
I know that. I thought was fun because it reminds me an old DOS function that do the same, but makes a beep when you type a key that is not the carriage return key. :biggrin:
Btw, thanks for your reply JJ. :icon14: