用户操作
[即时聊天] [发私信] [加为好友]
乐山ID:baichinan
1273次访问,排名2万外,好友1人,关注者1人。
baichinan的文章
原创 3 篇
翻译 3 篇
转载 3 篇
评论 0 篇
最近评论
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    翻译 据说是美国最“怪”C程序大赛的获奖程序收藏

     | 旧一篇: 程序自己打印自己

     

    int main()

    {

    printf(&unix["\021%six\012\0"], (unix)["have"] + "fun" - 0x60); 

    }

    gcc -S编译成汇编代码如下:

            .file   "test.c"
            .section        .rodata
    .LC0:
            .string "fun"
    .LC1:
            .string "\021%six\n"
            .string ""
            .text
    .globl main
            .type   main,@function
    main:
            pushl   %ebp
            movl    %esp, %ebp
            subl    $8, %esp
            andl    $-16, %esp
            movl    $0, %eax
            subl    %eax, %esp
            subl    $8, %esp
            movl    $.LC0, %eax
            subl    $96, %eax
            addl    $97, %eax
            pushl   %eax
            pushl   $.LC1+1
            call    printf
            addl    $16, %esp
            leave
            ret
    .Lfe1:
            .size   main,.Lfe1-main
            .section        .note.GNU-stack,"",@progbits
            .ident  "GCC: (GNU) 3.2.3 20030502 (Red Hat Linux 3.2.3-47)"

    关键点:

    1.linux下有宏定义 MACRO unix = 1
    2.对数组的理解1["have"] <==> "have"[1]
      &1["abcd"]就是'b'的地址
    3.C语言对转义的规定 \ddd 为1~3位八进制数所代表的字符 \xhh表示1~2位16进制数所代表的字符,故\021表示ASCII值为十进制17的字符;\012表示换行符;\0就是字符串结束符

    发表于 @ 2007年11月08日 23:08:00|评论(loading...)|编辑

     | 旧一篇: 程序自己打印自己

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © baichinan