【发布时间】:2015-04-28 08:42:28
【问题描述】:
我想在 Assembly 中进行系统调用(在 linux 上)。 我有系统调用访问的问题。我用 C 代码编写:
int r= syscall(SYS_access,"file", R_OK);
if(r==0){
printf("Can read\n");
}
这在 C 中工作,但我不知道如何处理标志和检查返回。这是我的代码:
mov eax, 33 ;system call for access
mov ebx, namefile
mov ecx, 0 ;here is int - flag?
int 80h
cmp eax,0 ;cmp return?
je .YES
.YES:
mov eax,4 ;write
mov ebx,1 ;terminal
mov ecx,yes ;what I write
mov edx,9 ;4
int 0x80 ;call kernel
如何修复标志并比较返回值?
【问题讨论】:
-
这只是使用搜索引擎的问题。如果你用谷歌搜索“man access”,你会发现
access在成功的情况下返回什么,如果你用谷歌搜索“#define R_OK”,你会发现R_OK对应的值。 -
如果你知道如何用 C 编写它,那么只需编译 C 代码并查看生成的机器码!
标签: assembly system-calls