Professional Documents
Culture Documents
Computer Architecture II
2022-2023
Lecture 6
Lecturer
Nyan D. Sallman
Basic Logical Instruction
• AND A B T
A T
0 0 0
0 1 0
B 1 0 0
1 1 1
• TEST DL,DH
• TEST CX,BX
• TEST EDX,ECX
• TEST AH,4
• TEST EAX,256
Example :
TEST AL,1 ; test right bit
TEST AL,128 ; test left bit
• BTS CX,9
• BTS CX,10
• BTR CX,0
• BTR CX,1
• BTC CX,12
NOT and NEG
• NOT implement one’s complement
• NEG implement two’s complement(arithmetic sign change)
NOT CH
NEG CH
NEG AX
NOT EBX
NOT BYTE PTR[BX]
SHIFT and ROTATE
• Shift operation
C
SHL 0
C
SAL 0
SHR 0 C
SAR
sign bit
Shift instructions
SHL AX,1
SAR BX,12
SHR ECX,10
SAL DATA1,CL
Note : left shift (multiplication by power 2 each bit shift)
While right shift (division by 2 each bit shift )
EXAMPLE : multiply AX by 10
SHL AX,1 ; AX times 2
MOV BX,AX
SHL AX,2 ; AX times 8
ADD AX,BX ; AX times 10
EXAMPLE : multiply AX by 18
SHL AX,1 ; AX times 2
MOV BX,AX
SHL AX,3 ; AX times 16
ADD AX,BX ; AX times 18
Example : multiply AX by 5
MOV BX,AX
SHL AX,2 ; AX times 4
ADD AX,BX ; AX times 5
Rotate instruction
• Rotate
C
RCL
C
ROL
RCR C
ROR
Rotate instruction
• ROL SI,14
• RCL BL,6
• ROL ECX,18
• RCR AH,CL
• ROR WORD PTR[BP],2