NASM: operation size not specified

只谈情不闲聊 提交于 2019-12-17 17:18:01

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/40704765/nasm-operation-size-not-specified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!