将间接寻址的值移入 AL 有效,但将其移入 8 位 rXb 寄存器在 yasm 中不起作用 [英] Moving indirect-addressed value into AL works, but moving it into an 8-bit rXb register doesn't in yasm

查看:59
本文介绍了将间接寻址的值移入 AL 有效,但将其移入 8 位 rXb 寄存器在 yasm 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 .data 中声明了一个字节数组

I have a byte-array of characters declared in .data

chars db 'spipopd'

并且我已将 rdi 设置为指向此数组的基本索引

and I have set rdi to point to the base index of this array

mov rdi, chars

在某些时候,我想将数组中的一个字符放入一个 8 位寄存器中.下面的第一个语句产生一个有效值,但第二个语句在输入 gdb 命令 print $r9b 时导致 r9b 包含 void.

At some point, I want to put a character from the array into an 8-bit register. The first statement below produces a valid value, but the second one causes r9b to contain void upon entering the gdb command print $r9b.

mov al, [rdi]   ; produces valid value in gdb
mov r9b, [rdi]  ; r9b = void, according to gdb

寄存器 r8b 到 r15b 中的任何一个都具有相同的效果.据我了解,alr9b 都是 8 位的,那么为什么一个有效,另一个无效?我的预感是,虽然它们都是 8 位大小,但它们有一些细微的差异,我无法理解.

Any of the register r8b to r15b has the same effect. As I understand, both al and r9b are 8-bit, so why does one work, and the other doesn't? My hunch is that, although they are both 8-bit in size, they have some subtle differences that elude me.

英特尔文档指出:

"REX 前缀用于生成 64 位操作数大小或引用寄存器 R8-R15."

"REX prefixes are used to generate 64-bit operand sizes or reference registers R8-R15."

这与我的问题有关吗?

推荐答案

"void" 并不是一个寄存器可以拥有的值,所以看起来 gdb 只是没有将 r9b 识别为寄存器名称.

"void" isn't really a value that a register can have, so that looks like gdb is just not recognizing r9b as a register name.

请注意,低字节寄存器有两种不同的表示法,r9br9l,不同的来源使用不同的名称.

Note that there are two different notations for the low-byte registers, r9b and r9l, and different sources use different names.

在 main 中打破一个随机程序并自己尝试,我得到这个输出:

Breaking a random program in main and trying it myself, I get this output:

(gdb) print $r9b
$1 = void
(gdb) print $r9l
$2 = 16

显然 gdb 只识别 $r9l 符号.

Apparently gdb only recognizes the $r9l notation.

这篇关于将间接寻址的值移入 AL 有效,但将其移入 8 位 rXb 寄存器在 yasm 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆