• Intel汇编-使用命令行参数


    area.s

    # The area function. (函数使用堆栈传递数据)
    #
    # 计算给定半径的圆的面积
    #  
     
        .section .text
       
    .type area, @function
    .globl area
    area:
        push %ebp
        movl %esp, %ebp
        subl $4, %esp
        fldpi
        filds 8(%ebp)
        fmul %st(0), %st(0)
        fmulp %st(0), %st(1)
        fstps -4(%ebp)
        movl -4(%ebp), %eax
        movl %ebp, %esp
        pop %ebp
        ret
     
    # as -gstabs -o area.o area.s
     

    main.s

    # An example of using external functions. (使用外部函数)
    #
    # 计算给定半径的圆的面积
    #  
     
        .section .data
    precision:
        .byte 0x7f, 0x00
     
        .section .bss
    .lcomm result, 4
     
        .section .text
        .globl _start
    _start:
        nop
        finit
        fldcw precision
     
        push $10
        call area
        addl $4, %esp
        movl %eax, result
     
        push $2
        call area
        addl $4, %esp
        movl %eax, result
     
        push $120
        call area
        addl $4, %esp
        movl %eax, result
     
        movl $1, %eax
        movl $0, %ebx
     
    # as -gstabs -o main.o main.s
    # ld -o main main.o area.o

    #if 0
     
    (gdb) b *_start+1

    Breakpoint 1 at 0x8048075: file main.s, line 17.
    (gdb) run 10
    Starting program: /home/area/main 10
     
    Breakpoint 1, _start () at main.s:17
    17        finit
    (gdb) p $esp
    $1 = (void *) 0xbffff130
    (gdb) x/20x 0xbffff130
    0xbffff130:    0x00000002    0xbffff2c8    0xbffff31e    0x00000000
    0xbffff140:    0xbffff321    0xbffff32c    0xbffff33d    0xbffff34c
    0xbffff150:    0xbffff36d    0xbffff3a2    0xbffff3b9    0xbffff3c9
    0xbffff160:    0xbffff3dd    0xbffff3ee    0xbffff3fc    0xbffff414
    0xbffff170:    0xbffff426    0xbffff45a    0xbffff47b    0xbffff497
    (gdb) x/s 0xbffff2c8
    0xbffff2c8:    "/home/area/main"
    (gdb) x/s 0xbffff31e
    0xbffff31e:    "10"
    (gdb) x/s 0xbffff321
    0xbffff321:    "XDG_VTNR=1"
    (gdb) x/s 0xbffff32c
    0xbffff32c:    "XDG_SESSION_ID=1"
    (gdb) x/s 0xbffff32b9
    0xffff32b9:    
    (gdb) x/s 0xbffff329
    0xbffff329:    "=1"
    (gdb) x/s 0xbffff33d
    0xbffff33d:    "HOSTNAME=linux"
    (gdb) x/s 0xbffff34c
    0xbffff34c:    "IMSETTINGS_INTEGRATE_DESKTOP=yes"
    (gdb) x/s 0xbffff36d
    0xbffff36d:    "GPG_AGENT_INFO=/run/user/1000/keyring-uLOeGm/gpg:0:1"
     
    #endif

  • 相关阅读:
    linux:2.3.4 查找/搜索命令(find+grep)+压缩/解压缩命令(gzipbzip2+tar+mv+mkdir)
    598. 范围求和 II (脑筋急转弯)
    供应链高效管理供应商
    Linux权限认识
    KeyError: ‘mmrotate.RotLocalVisualizer is not in the visualizer registry.
    问题杂编 ━━ windows2016安装php8.1及mysql8出现的问题汇总(简直就是*#*o#)
    网络编程之epoll源码深度剖析
    WebGL 与 WebGPU比对[6] - 纹理
    区分dom对象和jQuery对象、jQuery对象的本质、jQuery对象和dom对象使用的区别和相互转换
    本着什么原则,才能写出优秀的代码?
  • 原文地址:https://blog.csdn.net/xiaozhiwise/article/details/127418595