Reputation: 2612
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.
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?
Upvotes: 1
Views: 395
Reputation: 812
Instead of creating spaghetti code with all those conditional branches, consider using Scc
command, where cc is a condition. This command sets destination byte to $FF if condition is true and to zero otherwise. 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
Upvotes: 2