[英]Using AND and OR in 68k language
I need something like this: 我需要这样的东西:
if((ch > 'g' && ch < 'm') || (A >= 0 && A <= 100)) {
// Do some stuff
} else {
// Do some other stuff
}
ch
is an 8-bit char, while A
is a 32 bit integer. ch
是8位字符,而A
是32位整数。
I suspect I will need this code: 我怀疑我将需要以下代码:
CMPI.B #$67, ch
BLT SOMELABEL
CMPI.B #$6D, ch
BGT SOMELABEL
and 和
CMPI.W #0, A
BLE SOMELABEL
CMPI.W #100, A
BGE SOMELABEL
How do I combine these using the OR and AND operators? 如何使用OR和AND运算符将它们组合在一起?
Instead of creating spaghetti code with all those conditional branches, consider using Scc
command, where cc is a condition. 与其使用所有这些条件分支创建意大利面条代码,
Scc
考虑使用cc是条件的Scc
命令。 This command sets destination byte to $FF if condition is true and to zero otherwise. 如果条件为真,此命令将目标字节设置为$ FF,否则设置为零。 So you can have code like this:
因此,您可以拥有如下代码:
cmpi.b #'g',ch
shi.b d0
cmpi.b #'m',ch
slo.b d1
and.b d1,d0 ;now d0 is nonzero if all conditions for 'ch' are true
... same for A with result in d1
or.b d1,d0
beq else_branch
... here is 'if' branch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.