[MASM]另一个“无法使用具有32位地址的16位寄存器"错误 [英] [MASM]Another 'cannot use 16-bit register with a 32-bit address' error

查看:585
本文介绍了[MASM]另一个“无法使用具有32位地址的16位寄存器"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MASM汇编器学习汇编语言,当我尝试使用此命令来汇编简单文件时,我被卡住了:ml /c test.asm test.asm文件看起来像:

I'm learning assembly language with MASM assembler and I get stuck when I tried to assemble a simple file using this command :ml /c test.asm and the test.asm file looks like :

.386
.model flat
.code
MOV BP,WORD PTR[BP+4]
END

然后问题来了:

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

Microsoft (R) Macro Assembler Version 6.14.8444

版权所有(C)Microsoft Corp 1981-1997.保留所有权利.

Copyright (C) Microsoft Corp 1981-1997. All rights reserved.

组装:test.asm

Assembling: test.asm

test.asm(4):错误A2155:无法使用具有32位地址的16位寄存器

test.asm(4) : error A2155: cannot use 16-bit register with a 32-bit address

问题是,

32位地址?我没有告诉汇编程序使用32位地址.

32-bit address?I didn't tell the assembler to use a 32-bit address.

以及如何通过我的代码?

and How can I get my code passed?

推荐答案

我已经做了一些研究,这是我所学到的

I've done some researches and here is what I've learned

.MODEL指令

  • 启用简化的细分受众群
  • 控制代码段的名称
  • 控制过程的默认距离.
  • enables use of simplified segments
  • controls the name of the code segment
  • controls the default distance for procedures.

语法是:.MODEL memorymodel, options-optional

和memorymodel可以是TINY, SMALL, COMPACT, MEDIUM, LARGE, HUGE,or FLAT

and memorymodel can be TINY, SMALL, COMPACT, MEDIUM, LARGE, HUGE,or FLAT

平面模型与微小模型相似,因为所有代码和数据都放在一个 单个32位可寻址内存块.

Flat model is similar to tiny model in that all code and data go in a single 32-bit -addressable block of memory.

要编写平面模型程序,请指定.386或.486指令 以前.

To write a flat model program, specify the .386 or .486 directive before.

因此,如果我不想使用平面模型,则指令.386是可选的(请参阅

so the directive .386is optional if I don't want to use flat model (look here)

这里有一些参考资料

1 .MODEL

2个逻辑段和内存模型指令

这篇关于[MASM]另一个“无法使用具有32位地址的16位寄存器"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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