什么是结肠:在x86汇编GAS语法的意思是在DS%(%BX)? [英] What does the colon : mean in x86 assembly GAS syntax as in %ds:(%bx)?

查看:495
本文介绍了什么是结肠:在x86汇编GAS语法的意思是在DS%(%BX)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的x86汇编,我想了解本文档中的code:的 http://www.cs.cmu.edu/~410-s07/p4/p4-boot.pdf 3页:

  MOVW $×1234,斧头%
MOVW%斧,DS%
MOVW $ 0x5678的,BX%
#下面的指令是一样的MOVW $ 0x1337,(BX%)​​。
MOVW $ 0x1337,DS%(%BX)#场所0x1337存储器字0x179b8。
#段基址:%DS<< 4:12340
#偏移:%BX:+ 5678
#-------
#线性地址:179b8

但我不理解的命令:

  MOVW $ 0x1337,DS%(%BX)#场所0x1337存储器字0x179b8。

为什么串联%DS用(%BX)是一样的((%DS<< 4)|%BX)?

由于我在实模式(16位),串联不宜%DS<< 8 ?代替%DS<< 4

为什么括号只是%左右BX?而不是围绕整个结构类似:MOVW $ 0x1337,(%DS:BX%)?


解决方案

在实模式下,段寄存器被用来提供一个20位地址。在这种情况下,数据段寄存器 DS 提供地址的高16位:(0×1234<< 4 = 0x12340),而偏移的段中由下式给出:0x5678的,得到:0x179b8

数据段寄存器的的,所以这是没有必要使用: DS:(BX%)​​。如果你使用其他段寄存器,如 ES ,就需要明确。

我希望我已经明白你的问题。至于的为什么的它不是写成(%DS:%BX),这真的只是你坚持一个语法决定

I am new to x86 assembly and I am trying to understand the code in this document : http://www.cs.cmu.edu/~410-s07/p4/p4-boot.pdf page 3 :

movw $0x1234, %ax
movw %ax, %ds
movw $0x5678, %bx
# The following instruction is the same as "movw $0x1337, (%bx)".
movw $0x1337, %ds:(%bx) # Places 0x1337 into memory word 0x179b8.
# Segment Base: %ds << 4: 12340
# Offset: %bx: + 5678
# -------
# Linear Address: 179b8

But I am not understanding the command :

movw $0x1337, %ds:(%bx) # Places 0x1337 into memory word 0x179b8.

Why concatenating %ds with (%bx) is the same as ((%ds << 4) | %bx) ?

As I am in real mode (16 bits), the concatenation shouldn't be %ds << 8 ? instead of %ds << 4?

And why the parenthesis is just around %bx? And not around the whole structure like : movw $0x1337, (%ds:%bx) ?

解决方案

In real mode, the segment register is used to provide a 20-bit address. In this case, the data segment register ds provides the 'high' 16 bits of the address: (0x1234 << 4 = 0x12340), and the offset in the segment is given by: 0x5678, to yield: 0x179b8.

The data segment register is implicit, so it's not necessary to use: ds:(%bx). If you were using another segment register, like es, it would need to be explicit.

I hope I've understood your question. As to why it's not written as (%ds:%bx), that's really just a syntactic decision that you're stuck with.

这篇关于什么是结肠:在x86汇编GAS语法的意思是在DS%(%BX)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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