清风

导航

NASM:未指定操作大小(NASM: operation size not specified)

NASM:未指定操作大小 - IT屋-程序员软件开发技术分享社区 (it1352.com)

2020-05-16  IT屋
 

I wrote this code in emu8086 and it goes well in the emulator but when I'm trying to compile it with NASM it's throwing me up the error: "operation size not specified", help someone?

add bx,[3565]
sub bx,0xcc
mov [bx],0CCh
解决方案

NASM can't figure out what you meant by a line like mov [bx],0CCh. Clearly, this sets something to 0CCh. But do you want to have bx pointing to a single byte , short, long, ...? This will manifest itself as the fairly self-explanatory error: operation size not specified in NASM. You could avoid the error specifying the type, as shown below:

SECTION .text
    global start

start:
    add bx,[3565]
    sub bx,0xcc
    mov byte [bx],0CCh

That'd assemble it ok... of course, don't try to run it as it is, it'll produce EXCEPTION_ACCESS_VIOLATION. Just open it with a debugger and you'll understand why.

 

我在emu8086中编写了这段代码,并且在模拟器中运行得很好,但是当我尝试使用NASM进行编译时,它抛出了错误消息:"未指定操作大小",请帮助某人?



 添加bx,[3565] 
sub bx,0xcc
mov [bx],0CCh

解决方案
 

NASM无法弄清这样的行是什么意思mov [bx],0CCh 。显然,
会将值设置为0CCh。但是,是否要让bx指向单个字节
,short,long,...?这将表现为非常明显的
错误:未在NASM中指定操作大小。您可以避免指定类型的错误,如下所示:



  SECTION .text 
全局开始

开始:
加bx,[3565]
子bx,0xcc
移动字节[bx],0CCh


可以正常组装了……当然,不要尝试按原样运行它,它会产生 EXCEPTION_ACCESS_VIOLATION 。只需使用调试器打开它,您就会明白为什么。

posted on 2020-11-21 16:49  清风2009  阅读(1752)  评论(0编辑  收藏  举报