[英]Assembler - How to pass integer to printf?
I saw two diffrent way to pass integer in assmbler: the one by [eax], the second by eax. 我在assmbler中看到了两种不同的传递整数的方法:一个是[eax],另一个是eax。 I'll give an example:
我举个例子:
section .rodata
print_int_str: "%d"
%macro print_int 1
push %1
push print_int_str
call printf
add esp, 8
%endmacro
as I understood, we can use print_int eax
, and also print_int [eax]
. 据我
print_int eax
,我们可以使用print_int eax
,也可以使用print_int [eax]
。
What is the difrrence between them? 他们之间有什么不同?
print_int eax
will print you the value of eax
将打印出
eax
的值
print_int [eax]
will use the value of eax
as an address and will print the value that is stored at this address 将使用
eax
的值作为地址,并将打印存储在此地址的值
so you can either put the integer into eax
and use (any other reg will work too) 所以你可以将整数放入
eax
并使用(任何其他reg也可以工作)
print_int eax
or if you have a variable you can do 或者,如果你有变量,你可以做
print_int [var]; or
print_int [reg]; with regs value = address of var
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.