如何忽略回车键 NASM win32
How to ignore enter-key NASM win32
我需要忽略输入上的回车,以进一步将输入字符串与其他字符串进行比较。
代码输入和输出的波纹管片段
;get output handle
push dword STD_OUTPUT_HANDLE
call GetStdHandle
mov [hstdout],eax
mov eax, 1000h
;get input handle
push dword STD_INPUT_HANDLE
call GetStdHandle
mov [hstdin],eax
;Read
push 0
push actlen2 ;Pointer to a DWORD for number of characters read to be returned
push 11
push string
push dword [hstdin]
call ReadConsoleA
;Write
push 0
push actlen
push 11
push string
push dword [hstdout]
call WriteFile
字符串有换行符
Image
我想通了
我刚刚编写了从字符串
中删除 0x0d 和 0x0a 的代码
mov ecx,11; str len(and num of loop iterations)
mov eax,string
jmp ignore_enter
change_byte:
mov bl,0
mov byte[eax+ecx],bl;change byte to 0
ignore_enter:
cmp byte[eax+ecx], 0x0a; compare ecx byte of string with 0x0a
je change_byte; if equal change_byte
cmp byte[eax+ecx], 0x0D; compare ecx byte of string with 0x0d
je change_byte; if equal change_byte
loop ignore_enter
我需要忽略输入上的回车,以进一步将输入字符串与其他字符串进行比较。
代码输入和输出的波纹管片段
;get output handle
push dword STD_OUTPUT_HANDLE
call GetStdHandle
mov [hstdout],eax
mov eax, 1000h
;get input handle
push dword STD_INPUT_HANDLE
call GetStdHandle
mov [hstdin],eax
;Read
push 0
push actlen2 ;Pointer to a DWORD for number of characters read to be returned
push 11
push string
push dword [hstdin]
call ReadConsoleA
;Write
push 0
push actlen
push 11
push string
push dword [hstdout]
call WriteFile
字符串有换行符
Image
我想通了
我刚刚编写了从字符串
mov ecx,11; str len(and num of loop iterations)
mov eax,string
jmp ignore_enter
change_byte:
mov bl,0
mov byte[eax+ecx],bl;change byte to 0
ignore_enter:
cmp byte[eax+ecx], 0x0a; compare ecx byte of string with 0x0a
je change_byte; if equal change_byte
cmp byte[eax+ecx], 0x0D; compare ecx byte of string with 0x0d
je change_byte; if equal change_byte
loop ignore_enter