Wednesday, 18 January 2017

Conditional branching (a)


Comparing registers

The cmp instruction is used to compare registers with other registers or immediate operands, and set the appropriate status bits in the condition register. By default, fixed-point compare instructions use cr0 to store the result, but the field can also be specified as an optional first operand. Compare instructions are written as in Listing 3:
Listing 3. Examples of compare instructions
#Compare register 3 and register 4 as doublewords (64 bits)
cmpd 3, 4

#Compare register 5 and register 10 as unsigned doublewords (64 bits)
cmpld 5, 10

#Compare register 6 with the number 12 as words (32 bits)
cmpwi 6, 12

#Compare register 30 and register 31 as doublewords (64 bits)
#and store the result in cr4
cmpd cr4, 30, 31

No comments:

Post a Comment