0

I need to ignore the enter on input to further compare the input string with other strings.

Bellow fragment of code input and output

;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

String has newline
Image

  • 1
    You have the length of the input, so check if the last character is a newline. If it is, overwrite it with a `0`. (Or just do that unconditionally, assuming that it is a newline. Or CR LF if this environment gives you a 2-byte newline sequence on input.) Like in [How do I ignore line breaks in input using NASM Assembly?](https://stackoverflow.com/q/18780927) which uses Linux system calls; same idea for your WinAPI calls. – Peter Cordes May 06 '21 at 16:59
  • Thanks for help, I figured out – Данил Ивахин May 06 '21 at 18:36

1 Answers1

0

I figured out
I just wrote the code that removes 0x0d and 0x0a from the string

    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