从86 ASM访问在Linux命令行参数的问题 [英] Problems with accessing command line arguments in linux from x86 asm

查看:157
本文介绍了从86 ASM访问在Linux命令行参数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来检查,如果一个字符串是一个数字一个基本的汇编程序。我在加入code命令行arguements读,把它保持赛格断层。

如果我已阅读是正确的,这应该得到的参数传递给程序,而应存放在0(%EBP)的量。我究竟做错了什么?

在code的条款内容可以在这里找到: http://pastebin.com/kGV2Mxx4
问题是第一个3-5行的_start。

在看着lscpu的输出,我有一个i868的CPU。虽然,它说,它可以在32位和64位进行操作。我运行32位Linux(Arch Linux的x86)的

我固定的问题。我做了2流行的,一个绕过程序名称,下拿到的第一个参数。更新code可以在这里找到: http://pastebin.com/xewyeHYf

有人能告诉我为什么我不能只是做到以下几点:

  pushl 8(EBP%)

  MOVL 8(EBP%),%EAX


解决方案

下面是一个小教程中,我对这个问题写道:
NASM - 获取Linux的命令行参数

I have a basic asm program that checks if a string is a digit. I was adding in code to read from command line arguements, put it keeps seg faulting.

if what I have read is right, this should get the amount of arguments passed to the program, which should be stored in 0(%ebp). What am i doing wrong?

The entirity of the code can be found here: http://pastebin.com/kGV2Mxx4 The problem is the first 3-5 lines of _start.

upon Looking at lscpu's output, I have an i868 cpu. Although, it says it can operate in 32-bit and 64-bit. I am running 32 bit linux (Arch linux x86)

I fixed the issue. I did 2 pop's, one to bypass the programs name, the next to get the first argument. the updated code can be found here: http://pastebin.com/xewyeHYf

Can someone please tell me why I could not just do the following:

pushl 8(%ebp)

or

movl 8(%ebp), %eax

解决方案

Here is a little tutorial I wrote on the subject: NASM - Linux Getting command line parameters

这篇关于从86 ASM访问在Linux命令行参数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆