Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 纳斯姆。使用scanf和printf读取和打印整数_Assembly_Io_X86_Nasm - Fatal编程技术网

Assembly 纳斯姆。使用scanf和printf读取和打印整数

Assembly 纳斯姆。使用scanf和printf读取和打印整数,assembly,io,x86,nasm,Assembly,Io,X86,Nasm,下面是我编写的使用scanf和printf读取和打印整数的代码。但是,打印结果不正确 Section .data formatint: db "%d",0 formatintout: db "%d",10,0 section .bss i: resd 1 j: resd 1 n: resd 1 section .text extern printf extern scanf global main main: push n push formatint call scanf add

下面是我编写的使用scanf和printf读取和打印整数的代码。但是,打印结果不正确

Section .data

formatint: db "%d",0
formatintout: db "%d",10,0

section .bss

i: resd 1
j: resd 1
n: resd 1

section .text
extern printf
extern scanf
global main

main:

push n
push formatint
call scanf
add esp,8 

push n
push formatintout
call printf
add esp,6

exit:
mov eax,1
mov ebx,0
int 80h
请记住,对于scanf,您需要传递地址,但是对于printf,您需要传递值。在这两种情况下,您都在传递地址。您应该为printf推送dword[n]

添加esp,6当然应该是添加esp,8。我想那只是个打字错误

还请注意,不建议使用exit syscall。您应该直接从main返回,或者如果您真的想使用callexit