紧急求教:BSD下面的汇编

weixin_38059788 2006-11-21 12:24:36

项目就要到期了,结果,别人的代码还没有看懂,请各位大虾帮帮忙:
下面的代码中,我对汇编部分不懂。请你们指点,在线等:

再 laio_api.c中:
int
laio_syscall(int number, ...)
{
        if (!_setjmp(sched_data.env)) {
                assert(current_thread);
                sched_data.mb.km_curthread = current_thread;
                thread_desc = current_thread;
                //rv = syscall(number, arg_list);
                //the asm code here
                {asm (
                        " \
                                pop %ecx; \
                                pop %eax; \
                                push %ecx; \
                                int $0x80; \
                                push %ecx; \
                                jb 1f; \
                                jmp 2f; \
                        1: \
                                pushl %ebx; \
                                call 1f; \
                        1: \
                                popl %ebx; \
                                addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx; \
                                jmp .cerror@PLT; \
                        2: \
                        ");
                }
                sched_data.mb.km_curthread = NULL;
                thread_desc = (void *) 0;
                asm("ret");
                assert(0);
        }
        else {
                laio_desc_bg = thread_desc;
                errno = EINPROGRESS;
                return (-1);
        }

        /* does not come here */
        assert(0);
        return (0);
}

在 laio_syscall.S中
/* $Id: laio_syscall.S,v 1.4 2004/01/13 00:18:26 anupamc Exp $ */
/*
.LC0:
        .string "env = %p\n"
*/
        .text
        .p2align 2,,3
.globl laio_syscall
        .type   laio_syscall, @function
laio_syscall:
/*
        pushl   $sched_data+96
        pushl   $.LC0
        call    printf
        addl    $8, %esp
*/
        pushl   $sched_data+96
        call    _setjmp
        addl    $4, %esp
        testl   %eax, %eax
        jne     .L2
        movl    current_thread, %eax
        movl    %eax, sched_data+4
        movl    (%esp), %eax
        movl    %eax, foo
        movl    $.L1, (%esp)
        jmp     syscall
.L1:
        movl    $0, sched_data+4
.L3:
        jmp     *foo
.L2:
        call    __error
        movl    $36, (%eax)
        movl    $-1, %eax
        jmp     .L3
        .size   laio_syscall, .-laio_syscall

很着急,多谢了。 [ 本帖最后由 ericazhangjun 于 2006-11-21 13:05 编辑 ]
...全文
13 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧