NASM:未指定操作大小 - IT屋-程序員軟件開發技術分享社區 (it1352.com)
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 。只需使用調試器打開它,您就會明白為什么。
