MASM .CODE指令在使用两者时没有关于SEGMENT选项的信息 [英] MASM .CODE directive has no information on SEGMENT options when both are being used

查看:110
本文介绍了MASM .CODE指令在使用两者时没有关于SEGMENT选项的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是在同一列表中使用.CODE和SEGMENT的不同代码片段,在某些情况下,会出现与预期结果不同的结果。所有 列表的名称均为ASSEMBLY1.asm:

The following are different code fragments that are using .CODE and SEGMENT in the same listing and in some cases different results occur than the expected results. The name of all the listings are ASSEMBLY1.asm:

案例1:无错误

.model medium

.model medium

.code;创建的段是PUBLIC,对齐是WORD

.code ;segments created are PUBLIC and alignment is WORD

mov ax,ax

mov ax,ax

ASSEMBLY1_TEXT段;创建的段是PUBLIC和对齐是的。这是因为.code创建了ASSEMBLY1_TEXT段的初始定义为PUBLIC 并且对齐为WORD

ASSEMBLY1_TEXT segment ;segments created are PUBLIC and alignment is WORD. This is because .code created the initial definition for ASSEMBLY1_TEXT segment to be PUBLIC and the alignment to be WORD

ASSEMBLY1_TEXT结束

ASSEMBLY1_TEXT ends

end

案例2:发生错误,因为它应该

Case 2: Error occur, as it should

.model medium

.model medium

.code ASSEMBLY1_TEXT;创建的段是PUBLIC,对齐是WORD。

.code ASSEMBLY1_TEXT ;segments created are PUBLIC and alignment is WORD.

mov ax,ax

mov ax,ax

ASSEMBLY1_TEXT段  PRIVATE;此处发生错误,因为.CODE指令将此段创建为PUBLIC并与WORD对齐,现在您正尝试将组合类型从PUBLIC更改为PRIVATE。

ASSEMBLY1_TEXT segment PRIVATE ;A error occurs here because the .CODE directive created this segment as PUBLIC and a alignment of WORD and now you are attempting to change the combine type from PUBLIC to PRIVATE.

ASSEMBLY1_TEXT结束

ASSEMBLY1_TEXT ends

结束

案例3:没有错误发生BUG ??

CASE 3: NO error occurs BUG??

ASSEMBLY1_TEXT段PRIVATE;创建的段是PRIVATE,对齐是PARA。

ASSEMBLY1_TEXT segment PRIVATE ;segments created are PRIVATE and alignment is PARA.

ASSEMBLY1_TEXT结束

ASSEMBLY1_TEXT ends

.model medium

.model medium

.code;现有细分 命名为ASSEMBLY1_TEXT,即PUBLIC和WORD的对齐方式。没有显示错误。由于组合类型和对齐方式不匹配,因此会出现错误。

.code ;existing segment  named ASSEMBLY1_TEXT that is PUBLIC and alignment of WORD. No error is shown. A error should occur because the combine type and alignments do not match.

mov ax,ax

mov ax,ax

end

案例4:没有错误,BUG ??

Case 4: no error, BUG??

ASSEMBLY1_TEXT段PRIVATE  ;;细分创建的是PRIVATE,对齐是PARA。

ASSEMBLY1_TEXT segment PRIVATE ;segments created are PRIVATE and alignment is PARA.

ASSEMBLY1_TEXT结束

ASSEMBLY1_TEXT ends

.model medium

.model medium

.code;  ;; a 名为ASSEMBLY1_TEXT且具有PARA对齐的PRIVATE段现在更改为PUBLIC并对齐WORD。没有显示错误。由于组合类型和对齐方式不匹配,因此会出现错误。

.code ; ;a segment named ASSEMBLY1_TEXT that was PRIVATE with a alignment of PARA is now changed to PUBLIC and alignment of WORD. No error is shown. A error should occur because the combine type and alignments do not match.

mov bx,bx

mov bx,bx

end

从.CODE和SEGMENT的不同测试中我确定何时遇到.CODE指令由哪个段创建。 CODE具有PUBLIC的组合类型和WORD的对齐方式。如果遇到SEGMENT指令并且没有定义段
选项,那么它会创建一个PRIVATE类型的组合类型和PARA的对齐方式。

From the different testing of .CODE and SEGMENT I have determined when a .CODE directive is encountered ANY segments that are created by .CODE have a combine type of PUBLIC and a alignment of WORD. If a SEGMENT instruction is encountered and has no segment options defined then it creates a combine type of PRIVATE and an alignment of PARA.

我期待一个.CODE指令继承组合类型和对齐,其中最初定义了原始SEGEMENT指令,但情况并非如此。是这样的.CODE可能会起作用或者这是一个错误吗?

I was expecting a .CODE directive to inherit the combine type and alignment where the original SEGEMENT instruction was first defined but that is not the case. Is this the way .CODE is suppose to work or is this a bug?

我希望能够使用长形式的SEGMENT来定义带有选项的段,然后使用.CODE和其他指令。这不起作用吗?

I was hoping to be able to define segments with options  using the long form of SEGMENT and then use the .CODE and other directives. Does this not work?

我还没有尝试过.DATA,.DATA?,。CONST,.FARDATA,.FARDATA?和.STACK。我期待同样的结果。我是否正确?

I have not tried this yet for .DATA,.DATA?,.CONST,.FARDATA,.FARDATA? and .STACK. I expect the same result. Am I correct?

感谢您的帮助,David

Thanks for any help, David

推荐答案

嗯,Visual Studio 2017的masm / ml不喜欢第三种情况。

Well, masm/ml for Visual Studio 2017 doesn't like the third case.

首先你有ASSEMBLY1_TEXT作为段的开头,但ASSEMBLY2_TEXT作为段的结尾,这会导致错误:

First you have ASSEMBLY1_TEXT as the start of the segment, but ASSEMBLY2_TEXT as the end of the segment, this results in the error:

Microsoft(R)宏汇编程序版本14.14.26433.0

Copyright(C)Microsoft Corporation  保留所有权利。
Microsoft (R) Macro Assembler Version 14.14.26433.0
Copyright (C) Microsoft Corporation.  All rights reserved.


这篇关于MASM .CODE指令在使用两者时没有关于SEGMENT选项的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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