打开在Watcom内联汇编SEG和OFFSET运营商 [英] Open Watcom Inline assembly SEG and OFFSET operators

查看:261
本文介绍了打开在Watcom内联汇编SEG和OFFSET运营商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我已经了解到,在MASM赛格运营商默认返回该组的地址,而不是问题的前pression的段的地址,并有选择和方法来覆盖。

Today, I have learned that the SEG operator in MASM by default returns the address of the GROUP and not the address of the SEGMENT of the expression in question, and that there are options and methods to override that.

由于我目前在做一个复杂的项目中打开在Watcom 1.9 / 16位DOS C和汇编(内联和独立)混合(实际上,DOS只需要启动,然后我自己的MINI-OS取得控制权)因为我知道,WASM有些MASM兼容,我有以下问题:

Since I am currently doing a complex project in Open Watcom 1.9 / 16 bit DOS where C and assembly (inline and standalone) are mixed (actually, DOS is only needed for startup, then my own MINI-OS takes control), and since I know that WASM is somewhat MASM compatible, I have the following question:

在做内联汇编,并采取一个可变的段,并赛格运算符将返回基或者变量是在段?

When doing inline assembly and taking the segment of a variable, does the SEG operator return the GROUP or the SEGMENT which the variable is in?

假设有一个名为MY_GROUP基,名为MY_SEG段属于MY_GROUP,和名为MY_VAR变量/标签被放置在MY_SEG

Suppose there is a GROUP named MY_GROUP, a SEGMENT named MY_SEG which belongs to MY_GROUP, and a variable / label named MY_VAR which is placed in MY_SEG.

然后,如果我这样做

_asm {
MOV AX, SEG MY_VAR
}

该值被装入AX?它是MY_GROUP或MY_SEG的地址的地址(因为它们是不同的)?

which value is loaded into AX? Is it the address of MY_GROUP or the address of MY_SEG (given that they are different)?

我没有找到任何命令行开关,它涉及问题的内联的组装。然后,我尝试了MASM语法:

I did not find any command line switch which relates to that problem in inline assembly. I then tried the MASM syntax:

_asm {
MOV AX, SEG MY_GROUP:MY_VAR
MOV AX, SEG MY_SEG:MY_VAR
}

以上都导致以下错误行:只有段或组标签允许

Both of the lines above lead to the following error: "Only segment or group label is allowed".

请注意,我的问题只涉及到内联汇编。其实,我使用JWASM为独立的组装模块,以上语法运作良好,并与那里的预期结果。

Please note that my problem only relates to inline assembly. Actually, I am using JWASM for the standalone assembly modules, and the syntax above works well and with the expected results there.

有谁告诉我,内联汇编确实在这种情况下什么,如果有办法,我怎么能控制其各自的行为?

Could anybody tell me what the inline assembler does in this situation, and if there are means how I could control its respective behavior?

非常感谢你!

推荐答案

我不认为有什么办法说服OpenWatcom编译器生成一个基于组段搬迁。问题的部分原因是,有没有办法来声明或定义的组,这样你可以参考它的内联汇编。

I don't think there's any way to convince the OpenWatcom compiler to emit a group based segment relocation. Part of the problem is that there's no way to declare or define the group so that you can refer to it in the inline assembly.

然而,它出现在OpenWatcom链接器将忽略一个事实,即重定位基础段,而使用的段属于为基的组。因此,假如你正在使用万联科然后在第一个例子AX将加载指向MY_GROUP的开始段值。在另一方面,如果你使用微软的分段连接它,然后将AX包含指向MY_SEG段值。

However, it appears the OpenWatcom linker will ignore the fact that the relocations are segment based and instead use the group the segment belongs to as the base. So assuming you are using wlink then in your first example AX would be loaded with a segment value that points to the start of MY_GROUP. On the other hand, if you use Microsoft's segmented linker it then AX will contain a segment value that points to MY_SEG.

这篇关于打开在Watcom内联汇编SEG和OFFSET运营商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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