x86 在给定 AH 和 AL 的情况下计算 AX? [英] x86 Calculating AX given AH and AL?

查看:33
本文介绍了x86 在给定 AH 和 AL 的情况下计算 AX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解 x86 汇编中的寄存器,我知道 EAX 是完整的 32 位,AX 是低 16 位,然后是 AH 和 AL 是 AX 的高 8 位和低 8 位,但我正在做一个问题.

I'm having trouble understanding registers in x86 Assembly, I know that EAX is the full 32 bits, AX is the lower 16 bits, and then AH and AL the higher and lower 8 bits of AX, But I'm doing a question.

如果 AL=10 且 AH=10,AX 中的值是多少?

If AL=10 and AH=10 what is the value in AX?

我对此的想法是将 10 转换为二进制 (1010),然后将其作为 AX 的高位和低位 (0000 1010 0000 1010),然后将其转换为十进制 (2570) 我是否靠近右侧在这里回答,还是离开?

My thinking on this is to convert 10 into binary (1010) and then take that as the higher and lower bits of AX (0000 1010 0000 1010) and then converting this to decimal (2570) am I anywhere close to the right answer here, or way off?

推荐答案

根据 Peter Cordes 的建议,我会将数据想象为十六进制值:

As suggested by Peter Cordes, I would imagine the data as hexadecimal values:

RR RR RR RR EE EE HH LL
|           |     || ||
|           |     || AL
|           |     AH  |
|           |     |___|
|           |     AX  |
|           |_________|
|           EAX       |
|_____________________|
RAX

...其中 RAXx86-64 中存在的 64 位寄存器.

...where RAX is the 64-bit register which exists in x86-64.

所以如果你有 AH = 0x12AL = 0x34,就像这样:

So if you had AH = 0x12 and AL = 0x34, like this:

00 00 00 00 00 00 12 34
|           |     || ||
|           |     || AL
|           |     AH  |
|           |     |___|
|           |     AX  |
|           |_________|
|           EAX       |
|_____________________|
RAX

...然后你有 AX = 0x1234EAX = 0x00001234 等等

...then you had AX = 0x1234 and EAX = 0x00001234 etc.

请注意,如该图表所示,AH 是唯一奇怪"的代码.在此处注册与低位不对齐的寄存器.其他(ALAXEAXRAX 用于 64 位)只是大小不同但都对齐在右侧.(例如图表中标记为EE EE的两个字节本身没有寄存器名称.)

Note that, as shown in this chart, AH is the only "weird" register here which is not aligned with the lower bits. The others (AL, AX, EAX, RAX for 64-bit) are just different sizes but all aligned on the right. (For example, the two bytes marked EE EE in the chart don't have a register name on their own.)

将 AL、AH 或 AX 写入完整的 RAX,由于历史原因保留其他字节未修改.(如果您不特别想要这种合并,最好使用 movzx eax, byte [mem]movzx eax, word [mem] 加载:为什么GCC不使用部分寄存器?)

Writing AL, AH, or AX merge into the full RAX, leaving other bytes unmodified for historical reasons. (Prefer a movzx eax, byte [mem] or movzx eax, word [mem] load if you don't specifically want this merging: Why doesn't GCC use partial registers?)

将 EAX 零扩展写入 RAX.(为什么 32 位寄存器上的 x86-64 指令将整个 64 位寄存器的上半部分归零?)

Writing EAX zero-extends into RAX. (Why do x86-64 instructions on 32-bit registers zero the upper part of the full 64-bit register?)

这篇关于x86 在给定 AH 和 AL 的情况下计算 AX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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