【发布时间】:2014-10-23 19:23:03
【问题描述】:
我有:
mov ecx, r
.if ecx < 0
mov cl, 0
.elseif ecx > 255
mov cl, 255
.endif
mov [eax + 2], cl
r 是有符号整数。我希望它限制在字节限制内。 但问题是当“r”为负时。它被视为未签名。
Input -> Expected output
r = 300 -> 255
r = 12 -> 12
r = -134 -> 0
What actually happenes:
r = 300 -> 255
r = 12 -> 12
r = -134 -> 255 <--------- Here it gets treated as if -134 is bigger than 255
如何解决?
【问题讨论】:
标签: assembly macros x86 masm masm32