Assembly (Intel syntax + NASM) Error: attempt to define a local label before any non-local labels

戏子无情 提交于 2019-12-12 04:13:39

问题


I am quite new regarding the assembly and I am trying to work with a program. So whenever I try to compile it, I get the error for the line, as listed under the comments in the code.

I am wondering if anyone has any ideas why NASM detects this errors when I am defining some things for the rest of the assembly code?

Maybe it has to do something with how the main is defined?

P.S. I listed just the first part of the code, since the program is quite long.

Thank you for the help

.xlist               ;attempt to define a local label before any non-local labels
include  stdlib.a     ;  parser: instruction expected
includelib stdlib.lib    ; parser: instruction expected
.list
.286

dseg            segment para public 'data' 
;  Unknown section attribute 'public' ignored on declaration of section `para'
h               word    ?
i               word    ?

cseg            segment para public 'code'
                assume  cs:cseg, ds:dseg

Main

回答1:


In NASM a label starting with dot is called a local label. It is appended to the last global label, for example,

L:
.l2: ; it is really L.l2

So you cannot have a local label before any global ones




回答2:


That's not NASM code at all. As @Jester says, it's probably TASM or MASM.

NASM doesn't ASSUME, so you can be 100% sure this is not NASM code.


It's definitely not Linux code, either. Note the .286 directive. That means it will be 16-bit code. Even if you convert the syntax to NASM, the resulting binary will not do anything useful on your Linux system.

(This question doesn't mention Linux, but the followup does).



来源:https://stackoverflow.com/questions/41041009/parser-instruction-expected-error-while-compiling-intel-assembly-with-nasm

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