简体   繁体   English

单个字符不打印。 x86-32 英特尔汇编

[英]Single char not printing. x86-32 intel assembly

I am trying to print a single byte from my buffer into stdout, but I am not getting any output, I have looked up how to print a single byte, and it IS in fact getting stored/moved as expected (Used gdb to debug).我试图从我的缓冲区打印一个字节到标准输出,但我没有得到任何输出,我已经查找了如何打印一个字节,它实际上按预期存储/移动(使用 gdb 进行调试) . the byte even gets saved to ecx at the end but there isn't any output.该字节最后甚至被保存到ecx ,但没有任何输出。 What could be the issue?可能是什么问题? I am new to assembly and have been banging my head for several hours now.我是组装新手,现在已经敲了好几个小时的头了。 Thank you for the help.感谢您的帮助。

` `

global _start

section .data
    buffer: times 100 db 0

section .start
_start:
    mov eax, 3
    mov ebx, 0
    mov ecx, buffer                ; Enter input, example: 12345
    mov edx, 10
    int 80h

    movzx esi, byte [buffer+1]     ; Extract one byte from the input buffer: Successful
    push esi                       ; Byte is successfully pushed

print:
    pop edi                        ; Byte gets successfully popped

    mov eax, 4
    mov ebx, 1
    mov ecx, edi                   ; Here's the issue, it gets saved to ecx but no output
    mov edx, 15
    int 80h

exit:
    mov eax, 1
    mov ebx, 0
    int 80h

` As is aid, if i input "12345" the byte "2" (or 0x32) IS getting pushed/popped/moved correctly, it's just not printing Thank you ` 作为帮助,如果我输入“12345”,字节“2”(或 0x32)被正确推送/弹出/移动,它只是不打印谢谢

mov ecx, edi; Here's the issue mov ecx, edi; Here's the issue Exactly. mov ecx, edi; Here's the issue Function sys_write expects ecx to point at the string but you loaded ecx=0x00000032 which doesn't point anywhere.函数sys_write期望ecx指向字符串,但您加载的ecx=0x00000032没有指向任何地方。

Replace mov ecx, edi with mov ecx, buffer+1 and mov edx, 15 with mov edx,1 to print just one character.mov ecx, edi替换为mov ecx, buffer+1并将mov edx, 15替换为mov edx,1以仅打印一个字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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