assembly - 关于汇编中的命令行参数
问题描述
这是我的代码
segment .data
; initialized data is put in the data segment here
;
segment .text
global main
main:
enter 0,0 ; setup stack frame
pusha
call func
;
;
;
;
popa
mov eax, 0 ;
leave ;
ret
func:
push ebp
mov ebp,esp
sub esp,4 ;this is for local variable
mov eax,dword [ebp+12]
call print_int
call print_nl
mov eax,dword [ebp+8]
call print_int
call print_nl
mov esp,ebp
pop ebp
ret
如果我键入命令$./test 1 2 3
,则在堆栈中
---------------
pointer to argv-------->ebp+12
---------------
argc -------->ebp+8
---------------
return address -------->ebp+4
---------------
saved ebp -------->ebp
---------------
它应该打印出 3(参数的数量),但控制台中只有 0。
怎么了?
解决方案
推荐阅读
- servlets - 如何将 web.xml 中的上下文参数值外部化
- javascript - 如何处理具有优先级的事件委托?
- jsf - Primefaces 从支持 bean 开始 progressBar
- python - 如何修复 Python TypeError 和 AttributeError
- python - 如何将流文件传递给执行 Python 脚本并使用属性和 Nifi 变量来存储该文件?
- javascript - 如何根据传递的值从对象中查找键值
- vue.js - 无法使用 Vue 和 Vuetify 将模板文本添加到 v-textarea
- php - 压缩问题 Excel 使用 Maatwebsite
- c++ - 为什么 C++ 中的这个函数有效,但只有在打印到标准输出时才有效?
- html - 如何计算我的代码中的盒子大小?