【发布时间】: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 上阅读过类似的问题,但我仍然无法弄清楚我的代码有什么问题)
【问题讨论】:
-
ax和bx是寄存器名称,所以不能用作标签。