Warning label alone on a line without a colon might be in error

Вопрос: Я следую учебному пособию и изучаю x64 сборку синтаксиса Intel, и у меня есть этот образец кода, который, как предполагается, компилируется без проблем, но я получаю ошибки, поэтому я не могу начать. Пример кода: .code ASM_Debug proc mov rax, 55 ret ASM_Debug endp end Я использую компилятор сборки NASM, используя компилятор кода MinGW (G++),

Вопрос:

Я следую учебному пособию и изучаю x64 сборку синтаксиса Intel, и у меня есть этот образец кода, который, как предполагается, компилируется без проблем, но я получаю ошибки, поэтому я не могу начать.

Пример кода:

.code
ASM_Debug proc
mov rax, 55
ret
ASM_Debug endp
end

Я использую компилятор сборки NASM, используя компилятор кода MinGW (G++), если я компилирую с помощью встроенной сборки с использованием x64 Intel Syntax MASM. Я не получаю никаких ошибок.

Может ли кто-нибудь сказать мне, что мне нужно сделать?, правильная командная строка NASM для компиляции этого кода, чтобы я мог начать учиться. Спасибо

Моя текущая командная строка: nasm.exe -f elf64 Foo.asm -o Foo.o

PS: Я НЕ использую Visual Studio IDE для разработки, я не хочу ничего об этом слышать.

PS2: Я разрабатываю/работаю/для ОС Windows, а не для Linux.

Ошибки компиляции:

CoreASM.asm:1: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
CoreASM.asm:1: error: attempt to define a local label before any non-local labels
CoreASM.asm:2: error: parser: instruction expected
CoreASM.asm:5: error: symbol 'ASM_Debug' redefined
CoreASM.asm:5: error: parser: instruction expected
CoreASM.asm:6: warning: label alone on a line without a colon might be in error [-w+orphan-labels]

Лучший ответ:

Код, который вы написали, находится в синтаксисе MASM, который NASM не поддерживает. Вы можете сказать из-за ключевых слов PROC/ENDP, которые находятся только в MASM (и TASM, который в основном синтаксически совместим с MASM).

Итак, это синтаксис MASM:

.code
ASM_Debug proc
    mov rax, 55
    ret
ASM_Debug endp
end

И это тот же самый код, переведенный в синтаксис NASM:

SECTION .text

ASM_Debug:
    mov rax, 55
    ret

Обратите внимание, в частности, что:

  • Директива .code была заменена SECTION.text.
  • Ключевые слова PROC/ENDP были устранены, и для обозначения процедуры используется простая метка. Процедуры не повторяют их имена в конце.
  • В конце файла кода нет директивы END.

Вы можете найти несколько руководств по синтаксическим различиям между MASM и NASM в Интернете. Вот сообщение в блоге Dara Hazeghi, которое выглядит довольно всеобъемлющим.

Ваша командная строка для запуска NASM также неверна, поскольку она пытается создать двоичный elf64 формате Linux (формат elf64). (Вы можете их построить в NASM в Windows, конечно, но вы не сможете их запускать.) Для 64-битной Windows вы хотите win64. Таким образом, это будет:

nasm.exe -f win64 Foo.asm -o Foo.obj

(Обратите внимание, что .obj является обычным для объектных файлов в Windows, а не .o, хотя вы можете использовать любой. -o переключатель фактически является необязательным: если вы его опустите, NASM автоматически укажет объектный файл со стандартным расширением и то же имя, что и наш исходный файл.)

Но, если вы пытаетесь научиться программировать в сборке, вам действительно нужно найти учебник, который использует синтаксис, идентичный тому, что ожидает ваш ассемблер. Если вы хотите использовать NASM в качестве своего ассемблера, найдите учебник, в котором также используется NASM. Или, если вы хотите использовать учебник MASM, используйте MASM как ваш ассемблер. Версия 8 MASM можно скачать здесь для некоммерческого использования; это не новейшая версия, но она отлично подходит для обучения. Однако это 32-битная версия. Если вы хотите собрать 64-битный код, вам понадобится версия x86-64 с именем файла ml64.exe. Я не знаю, где вы можете скачать это отдельно, но оно включено в Windows SDK. По крайней мере, я знаю, что он был включен в Windows 7 SDK; Я не уверен, что он все еще присутствует в последних версиях Windows 10 SDK, но я так думаю.

Topic: I think there’s a missing opcode in NASM  (Read 7386 times)

The x86 opcodes CLZ (clear zero status flag) and CLV (clear overflow status flag) are not recognized by NASM. It thinks it is the name of a label that I’m trying to give to a line of code, and reminds me to put a colon after the label. The exact error is:
«warning: label alone on a line without a colon might be in error»

PLEASE fix this.

« Last Edit: March 10, 2016, 07:43:03 AM by ben321 »


Logged


I think you have your instruction sets mixed up. CLZ and CLV are AVR instructions, they are not valid Intel instructions.

3.4.3.1 Status flags

The status flags (bits 0, 2, 4, 6, 7, and 11) of the EFLAGS register indicate the results of arithmetic instructions, such as the ADD, SUB, MUL, and DIV instructions. The status flag functions are:

CF (bit 0) Carry flag — Set if an arithmetic operation generates a carry or a borrow out of the most-significant bit of the result; cleared otherwise. This flag indicates an overflow condition for unsigned-integer arithmetic. It is also used in multiple-precision arithmetic.
PF (bit 2) Parity flag — Set if the least-significant byte of the result contains an even number of 1 bits; cleared otherwise.
AF (bit 4) Axillary Carry flag — Set if an arithmetic operation generates a carry or borrow out of bit 3 of the result; cleared otherwise. This flag is used in binary-coded decimal (BCD) arithmetic.
ZF (bit 6) Zero flag — Set if the result is zero; cleared otherwise.
SF (bit 7) Sign flag — Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value.)
OF (bit 11)            Overflow flag — Set if the integer result is too large a positive number or too small a negative number (excluding the sign-bit) to fit in the destination operand; cleared otherwise. This flag indicates an overflow condition for signed-integer (two’s complement) arithmetic.

Of these status flags, only the CF flag can be modified directly, using the STC, CLC, CMC instructions. Also bit instructions (BT, BTS, BTR, and BTC) copy a specified bit into the CF flag.

« Last Edit: March 10, 2016, 11:36:28 AM by Bryant Keller »


Logged


I think you have your instruction sets mixed up. CLZ and CLV are AVR instructions, they are not valid Intel instructions.

3.4.3.1 Status flags

The status flags (bits 0, 2, 4, 6, 7, and 11) of the EFLAGS register indicate the results of arithmetic instructions, such as the ADD, SUB, MUL, and DIV instructions. The status flag functions are:

CF (bit 0) Carry flag — Set if an arithmetic operation generates a carry or a borrow out of the most-significant bit of the result; cleared otherwise. This flag indicates an overflow condition for unsigned-integer arithmetic. It is also used in multiple-precision arithmetic.
PF (bit 2) Parity flag — Set if the least-significant byte of the result contains an even number of 1 bits; cleared otherwise.
AF (bit 4) Axillary Carry flag — Set if an arithmetic operation generates a carry or borrow out of bit 3 of the result; cleared otherwise. This flag is used in binary-coded decimal (BCD) arithmetic.
ZF (bit 6) Zero flag — Set if the result is zero; cleared otherwise.
SF (bit 7) Sign flag — Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value.)
OF (bit 11)            Overflow flag — Set if the integer result is too large a positive number or too small a negative number (excluding the sign-bit) to fit in the destination operand; cleared otherwise. This flag indicates an overflow condition for signed-integer (two’s complement) arithmetic.

Of these status flags, only the CF flag can be modified directly, using the STC, CLC, CMC instructions. Also bit instructions (BT, BTS, BTR, and BTC) copy a specified bit into the CF flag.

What do you mean by an AVR instruction?


Logged


An instruction for an Atmel AVR chip. Not covered by Nasm. Seriously Ben, I think you should consider another assembler. Nasm does not seem to be suiting your needs.

Best,
Frank


Logged


An instruction for an Atmel AVR chip. Not covered by Nasm. Seriously Ben, I think you should consider another assembler. Nasm does not seem to be suiting your needs.

Best,
Frank

Actually, I just assumed that things like CLZ would have existed in the Intel x86 instruction set. I never imagined that such a simple thing would not have been included by Intel in their chips.


Logged


warning: label alone on a line without a colon might be in error

Questions : warning: label alone on a line without a colon might be in error

2023-02-07T05:30:18+00:00 2023-02-07T05:30:18+00:00

859

I’ve got this simple assembly program help uvdos nasm asm1.asm, but I get an error when trying to help uvdos nasm compile it. This is the code

;--- constant variables ---
SECTION .data

    msg: db "Hello World!", 10, 0; 10: carriage return, 0: NULL end of msg (stop)

;--- dynamic variables ---
; SECTION .bss

;--- assembler code ---
SECTION .text

extern _printf
global _main                    ;
_main:                          ; void main() {
    push ebp ;basepointer       ;   /* creation of the stack */
    mov ebp, esp ;stackpointer  ;

    push msg                    ;   /* pushing memory address */
    call _printf                    ;   /* call printf */

    mov esp, ebp                ;   /* function body */
    pop ebp                     ;
    return;                     ; }

I get this error

C:UsersDavidDesktop>nasm -f elf asm1.asm
asm1.asm:23: warning: label alone on a line without a colon might be in error

I’m new to assembly so I guess it’s just help uvdos nasm something minor but could someone please help uvdos nasm tell me what is causing the warning?

Total Answers 1

29

Answers 1 : of warning: label alone on a line without a colon might be in error

What’s with the return; line? That’s solved uvdos nasm not an x86 instruction name, so the solved uvdos nasm assembler treats it as equivalent to solved uvdos nasm return: and warns you about it in case solved uvdos nasm that’s not what you meant.

x86’s return instruction is called ret.

In NASM syntax, a label without a : is solved uvdos nasm allowed as a way to define a symbol, but solved uvdos nasm it’s deprecated because of the ambiguity solved uvdos nasm with typoed instructions / directives, solved uvdos nasm or new instruction mnemonics that this solved uvdos nasm version of NASM doesn’t recognize yet. solved uvdos nasm (With a :, you can even use instruction solved uvdos nasm names as labels, like loop:) solved uvdos nasm -w+orphan-labels is on by default.

https://nasm.us/doc/nasmdoc3.html#section-3.1 solved uvdos nasm Layout of a NASM Source Line documents solved uvdos nasm this.

0

2023-02-07T05:30:18+00:00 2023-02-07T05:30:18+00:00Answer Link

mRahman

Понравилась статья? Поделить с друзьями:
  • Warning ignoring large textdraw size как исправить самп
  • Watch dogs 2 ошибка запуска forbidden windows kernel modification detected как исправить
  • Warning fatal error 824 occurred
  • Watch dogs 2 ошибка dbghelp dll
  • Warning fan error асик