35.2.1.2. ЛОГИЧЕСКИЕ КОММАНДЫ




Всего как мы помним есть
	4 однооперандных
и	16 двухоперандных логических функций
некоторые из которых вырождены.

Но основной набор, который поддерживают все
включает:
	AND,OR,XOR

Остальные могут не реализовываться

CISC процессоры как правило еще обязательно
имеют NOT.


	            		Alpha	MIPS	HPPA	PPC	SPARC	IA-64
Register with value 0		r31	r0	r0	r0	r0



Bitwize AND

Побитовый AND

	destination  = source1 AND source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	0
	0	1	|	0
	1	0	|	0
	1	1	|	1
	------------------------------
----------------------------------------------------------------------------- o Bitwize Logical AND x86 AND 8 RR RI 16 RR RI 32 RR RI --------------------------------------------- Alpha AND 32/64 RRR --------------------------------------------- PPC AND max RRR ANDI. max RRI (low) ANDIS. max RRI (high) --------------------------------------------- MIPS AND 32/64 RRR ANDI 32/64 RRR --------------------------------------------- SPARC AND max RRR RRI --------------------------------------------- 68K AND 8 RR (D-regs) 16 RR 32 RR ANDI 8 RI (D-,A- regs) 16 RI 32 RI --------------------------------------------- z80 AND 8 AR AI --------------------------------------------- HPPA ANDcc 32 RRR --------------------------------------------- VAX-11 (*) via XORs/MCOMs --------------------------------------------- IA-64 AND 64 R,R,R R,R,I8 --------------------------------------------- MCS51 ANL 8 A,R A,M A,I --------------------------------------------- JVM IAND 32 LAND 64 --------------------------------------------- ARM ANDcc 32 RRR RRI --------------------------------------------- SH4 AND RR


Bitwize NOT



	destination = NOT source
	----------------------
	source	| destination	
	--------+-------------
	0	|	1
	1	|	0
	----------------------
В CISC процессорах реализуется как отдельная команда В RISC процессорах как последовательность если RISC процессор поддерживает NAND или NOR nand destination, source, source nand destination, source, immediate(-1) nor destination, source, R0 nor destination, source, immediate(0) или как XOR c непосредственным операндом равным -1 xor destination, source, -1 Например SPARC:
	not	%r5,%r6	  =>	xnor	%r5,%g0,%r6
	not	%r5	  =>	xnor	%r5,%g0,%r6
----------------------------------------------------------------------------- o Bitwize NOT x86 NOT 8 R 16 R 32 R ---------------------------------------------- Alpha (*) ORNOT with R31 (zero) ---------------------------------------------- PPC (*) XORI/XORIS with FF...FF ---------------------------------------------- MIPS (*) XORI with FF....FF ---------------------------------------------- SPARC (*) XNOR RRR %g0 register ---------------------------------------------- 68K NOT 8 R (D-,A- regs) 16 R 32 R ----------------------------------------------- z80 CPL 8 A ----------------------------------------------- HPPA (*) XORc RRR with r0 ----------------------------------------------- VAX-11 MCOMB 8 RR (R <= ~ R) MCOMW 16 RR MCOML 32 RR ----------------------------------------------- MCS51 CPL 8 A (A = ~ A) ------------------------------------------------ JVM (*) Complex via XOR ------------------------------------------------ ARM (*) Complex via EOR ------------------------------------------------ SH4 NOT RR


Bitwize OR



	destination  = source1 OR source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	0
	0	1	|	1
	1	0	|	1
	1	1	|	1
	------------------------------
----------------------------------------------------------------------------- o Bitwize Logical OR x86 OR 8 RR RI 16 RR RI 32 RR RI --------------------------------------------- Alpha BIS 32/64 RRR --------------------------------------------- PPC OR max RRR ORI max RRI (low) ORIS max RRI (high) --------------------------------------------- MIPS OR 32/64 RRR ORI 32/64 RRR --------------------------------------------- SPARC OR max RRR RRI --------------------------------------------- 68K OR 8 RR (D-regs) 16 RR 32 RR ORI 8 RI (D-,A-regs) 16 RI 32 RI --------------------------------------------- z80 OR 8 AR AI --------------------------------------------- HPPA ORc 32 RRR --------------------------------------------- VAX-11 (*) via XORs/MCOMs --------------------------------------------- IA-64 OR 64 R1=R2,R3 R1=I8,R3 --------------------------------------------- MCS51 ORL 8 A,R A,M A,I --------------------------------------------- JVM IOR 32 LOR 64 --------------------------------------------- ARM ORRcc 32 RRR RRI --------------------------------------------- SH4 OR RR


Bitwize XOR



	destination  = source1 XOR source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	0
	0	1	|	1
	1	0	|	1
	1	1	|	0
	------------------------------
-------------------------------------------------------------------------- o Bitwize Logical XOR x86 XOR 8 RR RI 16 RR RI 32 RR RI --------------------------------------------- Alpha XOR 32/64 RRR --------------------------------------------- PPC XOR max RRR XORI max RRI (low) XORIS max RRI (high) --------------------------------------------- MIPS XOR 32/64 RRR XORI 32/64 RRR --------------------------------------------- SPARC XOR max RRR RRI --------------------------------------------- 68K EOR 8 RR (D-regs) 16 RR 32 RR EORI 8 RI (A-,D- regs) 16 RI 32 RI --------------------------------------------- z80 XOR 8 AR AI --------------------------------------------- HPPA XORc 32 RRR (Generate Logical cond) UXORc 32 RRR (Generate Unit cond.) --------------------------------------------- VAX-11 XORB2 8 RR XORB3 8 RRR XORW2 16 RR XORW3 16 RRR XORL2 32 RR XORL3 32 RRR --------------------------------------------- IA-64 XOR 64 R1=R2,R3 R1=I8,R3 --------------------------------------------- MCS51 XRL 8 A,R A,M A,I ---------------------------------------------- JVM IXOR 32 LXOR 64 ---------------------------------------------- ARM EORcc 32 RRR RRI ---------------------------------------------- SH4 XOR RR


Logical NOR



	destination = source1 NOR source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	0
	0	1	|	0
	1	0	|	0
	1	1	|	1
	------------------------------
В архитектурах не поддерживающих NOR можно добиться аналогичного результат используя формулу:
	NOR(x,y) = NOT(OR(x,y))
----------------------------------------------------------------------------- o Bitwize Logical OR-NOT x86 (*) Complex sequence ----------------------------------------------- Alpha ORNOT 32/64 RRR ----------------------------------------------- PPC NOR max RRR ----------------------------------------------- MIPS NOR 32/64 RRR ----------------------------------------------- SPARC ORN max RRR RRI ----------------------------------------------- 68K (*) Complex sequence ----------------------------------------------- z80 (*) Complex sequence --------------------------------------------- VAX-11 (*) via XORs/MCOMs


Logical Equivalence



	destination = source1 EQV source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	1
	0	1	|	0
	1	0	|	0
	1	1	|	1
	------------------------------
------------------------------------------------------------------------------ o Bitwize Equvalence x86 (*) Complex sequence ----------------------------------------------- Alpha EQV 32/64 RRR ----------------------------------------------- PPC EQV max RRR EQV. max RRR ----------------------------------------------- MIPS (*) Complex sequence ----------------------------------------------- SPARC (*) Complex sequence ----------------------------------------------- 68K (*) Complex sequence ----------------------------------------------- z80 (*) Complex sequence ----------------------------------------------- HPPA (*) Complex sequence --------------------------------------------- VAX-11 (*) via XORs/MCOMs


Logical NAND



	destination = source1 NAND source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	1
	0	1	|	1
	1	0	|	1
	1	1	|	0
	------------------------------
В архитектурах не поддерживающих NAND можно добиться аналогичного результат используя формулу:
	NAND(x,y) = NOT(AND(x,y))
------------------------------------------------------------------------------ o Bitwize AND-NOT x86 (*) Complex sequence ----------------------------------------------- Alpha BIC 32/64 RRR ----------------------------------------------- PPC NAND max RRR ----------------------------------------------- MIPS (*) Complex sequence ----------------------------------------------- SPARC ANDN max RRR RRI ----------------------------------------------- 68K (*) Complex sequence ----------------------------------------------- z80 (*) Complex sequence ----------------------------------------------- HPPA ANDCMc 32 RRR ----------------------------------------------- IA-64 ANDCM 64 R,R,R R,I8,R ----------------------------------------------- ARM BICcc 32 RRR RRI


Bitwize XNOR



	destination = source1 XNOR source2
Экивалентность
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	1
	0	1	|	0
	1	0	|	0
	1	1	|	1
	------------------------------
------------------------------------------------------------------------------ o Bitwize logical XNOR x86 (*) Complex sequence ---------------------------------------------- Alpha (*) Complex sequence ---------------------------------------------- PPC (*) Complex sequence ---------------------------------------------- MIPS (*) Complex sequence ---------------------------------------------- SPARC XNOR max RRR RRRI ---------------------------------------------- 68K (*) Complex sequence ----------------------------------------------- z80 (*) Complex sequence ----------------------------------------------- HPPA (*) Complex sequence


Bitwize AND with complement of one operand



Вычисляет логическую функцию - запрет
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	0
	0	1	|	0
	1	0	|	1
	1	1	|	0
	------------------------------
	destination = source1 AND (NOT source2)
В архитектурах не поддерживающих операцию запрет можно добиться аналогичного результат используя формулу:
	ANDC(x,y) = AND(x, NOT(y))
------------------------------------------------------------------------------ o AND with complement one operand x86 (*) Complex sequence ---------------------------------------------- Alpha (*) Complex sequence ---------------------------------------------- PPC ANDC max RRR ---------------------------------------------- MIPS (*) Complex sequence ---------------------------------------------- SPARC (*) Complex sequence ---------------------------------------------- 68K (*) Complex sequence ----------------------------------------------- z80 (*) Complex sequence ----------------------------------------------- HPPA (*) Complex sequence


Bitwize OR with complement of one operand



Вычисляет логическую функцию - импликация
	destination = source1 IMP source2
	------------------------------
	source1	source2	| destination	
	----------------+-------------
	0	0	|	1
	0	1	|	0
	1	0	|	1
	1	1	|	1
	------------------------------
В архитектурах не поддерживающих операцию импликации можно добиться аналогичного результат используя формулу: ORC(x,y) = OR(x, NOT(y)) ------------------------------------------------------------------------------ o OR with complement one operand x86 (*) Complex sequence ---------------------------------------------- Alpha (*) Complex sequence ---------------------------------------------- PPC ORC max RRR ---------------------------------------------- MIPS (*) Complex sequence ---------------------------------------------- SPARC (*) Complex sequence ---------------------------------------------- 68K (*) Complex sequence ----------------------------------------------- z80 (*) Complex sequence ----------------------------------------------- HPPA (*) Complex sequence ------------------------------------------------------------------------------

Index Prev Next