【发布时间】:2016-09-19 04:51:35
【问题描述】:
请原谅我提出了一个愚蠢的语法问题,但我有两个变量(squares 和 horizCharsPerSquare),我正在尝试将 ecx 设置为 squares/horizCharsPerSquare。我试过了:
mov ecx, squares/horizCharsPerSquare
和
mov ecx squares
div horizCharsPerSquare
和
mov ecx, squares
shr ecx, horizCharsPerSquare ;//(I know there are other issues with this, I was just giving it a shot
无论如何,我得到一个错误?我得到的构建错误是“预期为常数”的一切。关于我应该如何做到这一点的任何建议?
【问题讨论】:
-
youtube.com/… 7:15
-
如果它们都是汇编时常量,
mov ecx, squares/horizCharsPerSquare将起作用。如果horizCharsPerSquare是2 的幂,则右移是正确的选择。mov ecx squares会组合,但那是not howdivworks。另请参阅x86 tag wiki。
标签: assembly x86 divide arithmetic-expressions