汇编win32控制台如何清屏
刚学汇编,用汇编在控制台下写个电话薄,但是在控制台不知道怎么清屏,每次都输出好多。。。
include \masm32\include\masm32rt.inc ClearScreen proto :Dword .stack 500h .data .code start: print "first string",10,13 print "first string",10,13 print "first string",10,13 print "first string",10,13 inkey " " invoke GetStdHandle,STD_OUTPUT_HANDLE ;取得控制台标准输出句柄 invoke ClearScreen,eax ;呼叫清屏子程序 print "second string after clear screen" inkey " " invoke ExitProcess, 0 ;--------------------------------------------------- ClearScreen PROC hConsole:HANDLE ;清屏子程序 push ebx push edi mov ebx,hConsole ;EBX = hConsole xor edi,edi sub esp,(sizeof CONSOLE_SCREEN_BUFFER_INFO+3) and -4 INVOKE GetConsoleScreenBufferInfo,ebx,esp movzx eax,word ptr [esp].CONSOLE_SCREEN_BUFFER_INFO.dwSize.x movzx edx,word ptr [esp].CONSOLE_SCREEN_BUFFER_INFO.dwSize.y mul edx push edx INVOKE FillConsoleOutputCharacter,ebx,32,eax,edi,esp pop eax movzx edx,word ptr [esp].CONSOLE_SCREEN_BUFFER_INFO.wAttributes push edx push eax INVOKE FillConsoleOutputAttribute,ebx,edx,eax,edi,esp INVOKE SetConsoleCursorPosition,ebx,edi pop ecx pop edx xchg eax,edi add esp,(sizeof CONSOLE_SCREEN_BUFFER_INFO+3) and -4 pop edi pop ebx ret 4 ClearScreen ENDP end start
[此贴子已经被作者于2016-7-14 22:25编辑过]