凡在系统codeS从X86-64大会来吗? [英] Where are the system codes coming from in x86-64 Assembly?

查看:161
本文介绍了凡在系统codeS从X86-64大会来吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待通过装配的一些演示(在Mac上使用NASM,我是新来组装),看到这样的事情:

I am looking through some demos of assembly (using NASM on a Mac, I am new to assembly) and seeing things like this:

; read a byte from stdin
mov eax, 3     ; 3 is recognized by the system as meaning "read"
mov ebx, 0     ; read from standard input
mov ecx, variable    ; address to pass to
mov edx, 1     ; input length (one byte)
int 0x80             ; call the kernel

我开始明白, EAX EBX 等都是通用寄存器,这是在哪里您存储常用的东西。还有更多的学习有,但我得到了它的要点。

I am beginning to understand that eax, ebx, etc. are "general registers", which is where you store common things. Still have more to learn there but I get the gist of it.

不过,我很困惑,其中类似 3 值(被系统识别为意思是读的)和 0 从标准输入读取的)的来源。你怎么知道 0 表示标准输入?有没有这样的整数值的清单,或者一些书籍或标准的参考?

But I am confused as to where the values like 3 (recognized by the system as meaning "read") and 0 (read from standard input) are coming from. How do you know that 0 means "standard input"? Is there a list of such integer values, or some book or standard reference?

推荐答案

您正在混为一谈系统调用号与系统调用的参数。

You're conflating system call numbers with the system call arguments.

系统呼叫号码(例如,3 =读)是特定于操作系统(当然,内核专用),有时版本特定的。例如,看到在x86 用于Linux的系统调用号在这里,并在x86_64 这里。如何参数传递,系统调用是如何调用的,哪些系统调用数字的含义都是建筑 - 和具体的内核。

The system call numbers (e.g. "3 = read") are OS-specific (well, kernel-specific), and sometimes version-specific. For example, see the system call numbers for Linux on x86 here and on x86_64 here. How the arguments are passed, how the system call is invoked, and what the system call numbers mean are all architecture- and kernel-specific.

有关,另一方面标准输入是一个UNIX规范值, STDIN_FILENO

The number "0" for "standard input" on the other hand is a UNIX standardized value, STDIN_FILENO.

这篇关于凡在系统codeS从X86-64大会来吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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