首页 > 解决方案 > 从内存移动到注册并在 gdb 中读取它

问题描述

section .data
    price dd 49,98,29
section .text
    global  _start
_start:
    nop
; Put your experiments between the two nops...
    mov eax,price
    mov ebx,[price]
    mov ecx,[price+4]
    mov edx, [price+8]
; Put your experiments between the two nops...
    nop

我知道 49,98,29 是一个字节。当引用价格时,它只会打印出 49。我必须将价格移动 1 个字节才能得到 98,移动 2 个字节才能得到 29。

在 gdb 中,我可以看到寄存器 edx 具有十进制 29、ecx 98 和 ebx 49。但是当我检查寄存器时,x/3dw $edx我得到

Cannot access memory at address 0x1d

为什么不显示29?

更新:

我正在尝试查看以下代码的输出

section .data
    price db 49,98,29
section .text
    global  _start
_start:
    nop
; Put your experiments between the two nops...
    mov eax, price          
    mov ebx,[price]
    mov ecx,[price+1]
    mov edx, [price+2]
; Put your experiments between the two nops...
    nop

x/db $ebx

0x1d6231:       Cannot access memory at address 0x1d6231

(gdb) p $ebx
$5 = 1925681

为什么要这样做?

标签: linuxassemblyx86nasm

解决方案


推荐阅读