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

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

问题描述

我在理解x86 Assembly中的寄存器时遇到麻烦,我知道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

请注意,如下图所示,AH是此处唯一不与低位对齐的怪异"寄存器.其他(64位的ALAXEAXRAX)大小不同,但都在右侧对齐. (例如,图表中标记为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.)

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

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