35.3.6.5. INTEGER COMPARES AND CONDITIONAL JUMPS ON POWER PC





0..5	opcode1
6..10	BO
11..15	NI
16..29	BD
30	AA
31	LK



			AA	LK	opcode
bc	BI,BO,target	0	0	16		Branch conditional
bca	BI,BO,target	1	0
bcl	BI,BO,target	0	1
bcla	BI,BO,target	1	1



	if (NOT BO[2])  { CTR <- CTR - 1}
	ctr_ok  = BO[2] OR ((CTR != 0) XOR BO[3])
	cond_ok = BO[0] OR ((NOT (CR[BI])) EQV (NOT BO[1]))	// !!!
	condition_ok = ctr_ok AND cond_ok

	if condition_ok
	{
		if AA { NIA  <- sign_ext(BD * 4);	}
		else  { NIA  <- CIA + sing_ext(BD * 4); }
		if LK { LR   <- CIA + 4			}
	}


Simplifyed Mnemonics:
blt	target			bc	12,0,target
bne	cr2,target		bc	4,10,target
bdnz	target			bc	16,0,target


	// ----------------------------------------------------------


0..5	opcode1
6..10	BO
11..15	BI
16..20	0
21..30	opcode2
31	LK



			LK	opcode
bcctr	BO,BI		0	19.528		Branch Condiional to Count
bcctrl	BO,BI		1			Register


	cond_ok <- BO[0] OR (CR[BI] EQV BO[1])			// !!!
	if (cond_ok)
		NIA <- CTR 
	if (LK)
		LR  <- CIA + 4


Simplyfied Mnemonics:
bltctr			bcctr	12,0
bnectr	cr2		bcctr	4,10



bclr	BO,BI		0	19.16		Branch Conditional to
bclrl	BO,BI		1			Link Register

	
	
	if (NOT BO[2])  { CTR <- CTR - 1}
	ctr_ok  = BO[2] OR ((CTR != 0) XOR BO[3])
	cond_ok = BO[0] OR ((NOT (CR[BI])) EQV (NOT BO[1]))	// !!!
	condition_ok = ctr_ok AND cond_ok

	if condition_ok
		NIA <- LR * 4
	if LK
		LR  <- CIA + 4


Simplyfied Mnemonics:
bltlr			bclr	12,0
bnelr	cr2		bclr	4,10
bdnzrl			bclr	16,0

	// ----------------------------------------------------------


0..5	opcode1			0..5  opcode1
6..8	crfD			6..9	crfD
9	0			9	0
10	L			10	L
11..15	A			11..15	A
16..20	B			16..31	SIMM or UIMM
21..30	opcode2
31	0


			
cmp	crfD,L,rA,rB		31.0		Compare 
cmpi	crfD,L,rA,SIMM		11		Compare Immediate	
cmpl	crfD,L,rA,rB		31.32		Compare Logical
cmpli	crfD,L,rA,UIMM		10		Compare Logical Immediate	
	


	L = 0 32-bit operation
	L = 1 64-bit operation

	if Logical then all compares are Unsigned...
	Else				 Signed...


	a <- rA;
	b <- rB;		// Not Immediate
	b <- sign_ext(SIMM)	// Immediate Signed
	b <- UIMM		// Immediate Unsigned

	if (a < b) then c <- 100b
	else if (a > b) then c <- 010b
	else c <- 001
	CR[4 * crfD] <-   { c, XER[SO] }

		

	// ----------------------------------------------------------


Note:
	Operations below is usefull for calculate superposition of
conditions. 

0..5	opcode1
6..10	crbD
11..15	crbA
16..20	crbB
21..30	opcode2
31	0


			 opcode	
crand	crbD,crbA,crbB	   19.257	Conditional Register AND
crandc	crbD,crbA,crbB	   19.129	Conditional Register AND-NOT
creqv	crbD,crbA,crbB	   19.289	Conditional Register Equivalent
crnand	crbD,crbA,crbB	   19.225	Conditional Register NAND
crnor	crbD,crbA,crbB	   19.33	Conditional Register NOR
cror	crbD,crbA,crbB	   19.449	Conditional Register OR
crorc	crbD,crbA,crbB	   19.417	Conditional Register OR-NOT
crxor	crbD,crbA,crbB	   19.193	Conditional Register XOR
	

0..5	opcode1
6..8	crfD
9..20	0s
21..30	opcode2
31	0


mcrxr	crfD		19.512		Move to Conditional Register from XER

	CR[4*crfD+3] <- XER[0..3]
	XER[0..3]    <- 0

Use this instruction for move from XER into conditional registers.




0..5	opcode1
6..10	D
11..20	0s
21..30	opcode2
31	0


mfcr	rD		31.19		Move from Conditional Register

	rD <- CR


0..5	opcode1
6..10	S
11	0
12..19	CRM
20	0
21..30	opcode2
31	0


mtcrf	CRM,rS		31.144		Move to Conditional Register Fields

		mask <- {100h CRM[0]}.... {100h CRM[7]}
		CR   <-  (rS[32-63] & mask) | (CR & ~ mask)

// ----------------------------------------------------------------------




Index Prev Next