【问题标题】:label or instruction expected at start of line YASMYASM 行开头的标签或指令
【发布时间】:2018-04-16 11:10:53
【问题描述】:

我正在尝试构建组件 YASM 代码,该代码应该计算二维平面上两点(A 和 B)之间的距离。

这是我用来构建代码的命令:

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

distance.asm:2:错误:行首需要标签或指令 distance.asm:4:错误:行首需要标签或指令

我是组装新手,不知道如何修复错误:

    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

我的问题是:为什么会出现上面显示的错误? (我在 stackoverflow 上阅读过类似的问题,但我仍然无法弄清楚我的代码有什么问题)

【问题讨论】:

  • axbx 是寄存器名称,所以不能用作标签。

标签: assembly yasm


【解决方案1】:

代替标签

Ax, Ay, Bx, By

使用其他人,例如。 g.

Mx, My, Nx, Ny

因为标签不能是AXBXCX、...等寄存器名称(AyBy 都可以)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    相关资源
    最近更新 更多