NASM: operation size not specified

前端 未结 1 1408
难免孤独
难免孤独 2020-12-07 06:12

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\",

相关标签:
1条回答
  • 2020-12-07 07:05

    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.

    0 讨论(0)
提交回复
热议问题