gpt4 book ai didi

linux - 为什么我不能在汇编中打印数字?

转载 作者:太空宇宙 更新时间:2023-11-04 11:46:00 24 4
gpt4 key购买 nike

我的代码是正确的,但 linux 不会打印我指定的 ascii 字符

我没有尝试太多其他方法,因为我的代码是正确的,而且我遵循了教程。

mov rcx, [digitSpacePos]
mov rax, 1
mov rdi, 1
mov rsi, rcx
mov rdx, 1
syscall

它应该打印 123,因为 digitSpace 是 123 但它什么也没打印。

最佳答案

这应该有效:

        global    _start

section .data
message: db "123", 10 ; note the newline at the end

section .text
_start: mov rax, 1 ; system call for write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, message ; address of string to output
mov rdx, 4 ; number of bytes
syscall ; invoke operating system to do the write
mov rax, 60 ; system call for exit
xor rdi, rdi ; exit code 0
syscall ; invoke operating system to exit

关于linux - 为什么我不能在汇编中打印数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57757171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com