什么是用方括号阅读NASM值时,默认段寄存器? [英] What's the default segment register when using square brackets to read values in NASM?

查看:844
本文介绍了什么是用方括号阅读NASM值时,默认段寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家都知道,我们可以看到用方括号在NASM,如地址的值:

As we all know, we can read the value of an address using square brackets in NASM, such as that:

mov esi,  [ebp +8]
mov edi, [var]   -->  (var is a variable)

在方括号这些值重新present的偏移地址,但是当我们使用这种格式读取数值,我们绝对需要一个段,我们无论是在真实或保护模式,有啥默认段寄存器NASM用途?我知道,Windows使用平板模式,但如果我设置不同的值不同的段寄存器(CS,SS,DS,ES,FS,GS),将NASM使用哪个段寄存器?我想这是 DS ,对不对?是段在方括号中使用不同的前pressions注册时不同?是默认段寄存器一样无论在实模式和保护模式?谢谢你。

Those values in square brackets represent the offset address, but when we read values using that format, we absolutely need a segment, whether we are in real or protected mode, so what's the default segment register that NASM uses? I know that Windows uses flat mode, but if I set different values to different segment register(cs, ss, ds, es, fs, gs), which segment register will NASM use? I guess it is ds, right? Is the segment register different when using different expressions in square brackets? Is the default segment register the same both in real and protected mode? Thanks.

推荐答案

默认段寄存器是所有'基地寄存器的DS除了

The default segment register is ds for all 'base registers' except

 mov esi, [ebp + 542] ; // uses ss:
 mov esi, [esp + 123] ; // uses ss: too
 mov eax, [eax + esp] ; // uses ds, because eax is the base 
                        // and esp is the scalable register (with scale==1)

 stosb   ;; uses es:

这不是汇编程序的属性,但该处理器。要覆盖它,还有的指令前一个字节段重载preFIX。

It's not the property of assembler, but of the processor. To override it, there's a one byte segment override prefix before the instruction.

这篇关于什么是用方括号阅读NASM值时,默认段寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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