【问题标题】:Assembly syntax Error: in instruction汇编语法错误:在指令中
【发布时间】:2015-03-16 23:58:32
【问题描述】:

这就是我的代码的样子。你觉得它有什么问题吗?

compare macro nr1,nr2 ; title of macro
local et1,et2  ; etiquetes
mov eax,nr1
mov ebx nr2
push eax
push ebx

; here I compare the 2 number nr1, nr2 to see whether is bigger

cmp eax,ebx      ; comparing the 2 numbers
ja et1
jb et2
et1:
sub eax,ebx        ; if the first one is bigger, we substract from it

; here we subtract from the bigger one

push eax
push offset format3
call printf
add esp,8

 et2:

sub ebx,eax         ; if the second one is bigger we substract like this
push ebx
push offset format3
call printf
add esp,8
add esp, 8
endm 

【问题讨论】:

  • 您是否收到任何错误消息?如果有,在哪一行?
  • 这行mov ebx nr2 好像少了一个逗号。
  • 你的汇编器肯定发现了它的问题,并告诉你。为什么不关注它?这肯定比在 Stack Overflow 上提问要快!
  • 嗯,实际上,逗号是问题所在。问题是汇编器显示错误的另一行。

标签: assembly x86


【解决方案1】:
mov ebx nr2

显然这一行需要一个逗号。实际上,逗号可以合法地包含在这个宏的调用序列中!这就是汇编程序在另一行显示错误的原因。

还有:
et1 块被执行时,你不应该跳过 et2 块吗?
EAX 和 EBX 之后不弹出来,有什么意义? (虽然堆栈是平衡的)

【讨论】:

  • 是的,我也会努力的。我将发布我的整个代码。因为我有一个棘手的问题。我必须从 2 个文件中读取并打印其中的单词数。它适用于每个文件,但是当我放置两个文件时,它失败了
猜你喜欢
  • 2020-09-22
  • 2014-06-19
  • 1970-01-01
  • 1970-01-01
  • 2013-06-12
  • 2021-01-19
  • 1970-01-01
  • 2011-01-17
  • 2011-09-21
相关资源
最近更新 更多