简体   繁体   中英

label or instruction expected at start of line YASM

I'm trying to build assembly YASM code that is supposed to calculate the distance between two points (A and B) on 2D plane.

This the command that I'm using to build the code:

yasm -f elf64 -g dwarf2 -l distance.lst distance.asm

distance.asm:2: error: label or instruction expected at start of line distance.asm:4: error: label or instruction expected at start of line

I'm new to assembly and can' figure out how to fix error:

    segment .data
Ax  dq      0       ; x coordinate of A
Ay  dq      0       ; y coordinate of A
Bx  dq      1       ; x coordinate of B
By  dq      1       ; y coordinate of B

    segment .text
    global _start
_start:
mov     rax,    [Ax]    ; Writing values
mov     rbx,    [Ay]    ; of A and B
mov     rcx,    [Bx]    ; coordinates to
mov     rdx,    [By]    ; registers
sub     rax,    rcx     ; Length of the first cathetus
sub     rbx,    rdx     ; Length of the second cathetus
imul    rax,    rbx     ; Suqare of distanse between A and B

My question is: why am I getting error shown above? (I have read similar questions on stackoverflow, but I still couldn't figure out what is wrong with my code)

Instead of labels

Ax, Ay, Bx, By

use others, eg

Mx, My, Nx, Ny

because labels must not be register names as AX , BX , CX , ... ( Ay and By are OK).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM