gpt4 book ai didi

c - 在汇编程序 AMD64 中,我调用 fprintf 但它一直无限循环

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

我对 fprintf 有一个问题,我无法理解。也许您可以找到解决此问题的方法。

你看,当我调用 fprintf 时,它无缘无故地开始无限循环。我不知道这里发生了什么,也许你可以帮我一把。

String_int:
db 91; "["
db 37; "%"
db 115;"i"
db 93; "]"
db 0; "end_string"

w_IN_ASCII:
db 119; "w"
db 0; "end_string"

<SOME CODE>

mov rdi, FILE_LOCATION;
mov rsi, w_IN_ASCII;
call fopen;
mov r15, rax;

cmp r15, 0; (with this I can be sure it is not a NULL)
je .endProgram;

mov rdi, r15;
mov rsi, String_int;
mov rdx, TO_PRINT_LOCATION;
call fprintf; this is where my code dies

mov rdi, r15;
call fclose;

.endProgram:
ret

最佳答案

在 System V AMD64 ABI 中,可变参数函数需要 al 中可变参数的实际数量。我没有看到你设置它。

关于c - 在汇编程序 AMD64 中,我调用 fprintf 但它一直无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12377777/

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