[英]Single char not printing. x86-32 intel assembly
我試圖從我的緩沖區打印一個字節到標准輸出,但我沒有得到任何輸出,我已經查找了如何打印一個字節,它實際上按預期存儲/移動(使用 gdb 進行調試) . 該字節最后甚至被保存到ecx
,但沒有任何輸出。 可能是什么問題? 我是組裝新手,現在已經敲了好幾個小時的頭了。 感謝您的幫助。
`
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
` 作為幫助,如果我輸入“12345”,字節“2”(或 0x32)被正確推送/彈出/移動,它只是不打印謝謝
mov ecx, edi; Here's the issue
mov ecx, edi; Here's the issue
。 函數sys_write
期望ecx
指向字符串,但您加載的ecx=0x00000032
沒有指向任何地方。
將mov ecx, edi
替換為mov ecx, buffer+1
並將mov edx, 15
替換為mov edx,1
以僅打印一個字符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.