从添加常量到注册获取地址

时间:2017-01-29 15:51:42

标签: assembly x86-64

好。我的任务看起来像这样:%edx寄存器的值为0xe000%ecx寄存器的值为0x200。记下从以下计算的地址:

  1. 0x10(%edx)
  2. (%edx, %ecx)
  3. (%edx, %ecx, 4)
  4. 0x8(,%ecx,2)
  5. 我知道在第一个例子中它应该是0x10+0xe000,在第二个地址它应该是0xe000+0x200等。但是当我想用汇编程序测试自己时,它不会工作(抛出Segmentation fault (core dumped)

    .section .rodata
    .LC0:
        .string "%d"
        .text
        .globl main
        .type main, @function
    
    main:
        pushq %rbp
        movq %rsp, %rbp
        movl $0xe000, -4(%rbp)
        movl $0x200, -8(%rbp)
        movl -4(%rbp), %edx
        movl -8(%rbp), %ecx
        movl $.LC0, %edi
        movl 0x10(%edx), %esi
        movl $0, %eax
        call printf
        movl $0, %eax
        leave
        ret
    

    这是例如nr 1.我做错了什么? (Manjaro 64位)

0 个答案:

没有答案