简体   繁体   中英

Why can't I print the user input data in NASM assembly?

I am trying to verify the length of user input in this example (NASM):

section .bss
    user_input resb 10

section .text
    push ebp
    mov ebp, esp

    mov eax, 3 ;sys_read
    mov ebx, 0 ;stdin
    mov ecx, user_input
    mov edx, 10
    int 80h

    cmp eax, 10
    jg overflow
    jmp done 
overflow:
    .
    .
    .
done:
    mov eax, 1
    int 80h

Why isn't this working?

Since your buffer is 10 bytes and you put the length into edx, the return can never be greater than 10 and you jump to label done: and exit.

There's nothing in the code you've shown that prints anything out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM