Assembly Language For Intel - Based Computers, 4 Edition
Assembly Language For Intel - Based Computers, 4 Edition
00111011
AND 0 0 0 0 1 1 1 1
00111011
OR 0 0 0 0 1 1 1 1
00111011
XOR 0 0 0 0 1 1 1 1
NOT 00111011
11000100 inverted
mov ax,wordVal
and ax,1 ; low bit set?
jz EvenValue ; jump if Zero flag set
or al,al
jnz IsNotZero ; jump if not zero
ORing any number with itself does not change its value.
test al,00000011b
jnz ValueFound
test al,00000011b
jz ValueNotFound
mov al,5
cmp al,5 ; Zero flag set
mov al,4
cmp al,5 ; Carry flag set
• Jumps Based On . . .
• Specific flags
• Equality
• Unsigned comparisons
• Signed Comparisons
• Applications
• Encrypting a String
• Bit Test (BT) Instruction
• Examples:
• JB, JC jump to a label if the Carry flag is set
• JE, JZ jump to a label if the Zero flag is set
• JS jumps to a label if the Sign flag is set
• JNE, JNZ jump to a label if the Zero flag is clear
• JECXZ jumps to a label if ECX equals 0
cmp eax,ebx
ja Larger
cmp eax,ebx
jg Greater
cmp eax,Val1
jbe L1 ; below or equal
cmp eax,Val1
jle L1
KEY = 239
.data
buffer BYTE BUFMAX DUP(0)
bufSize DWORD ?
.code
mov ecx,bufSize ; loop counter
mov esi,0 ; index 0 in buffer
L1:
xor buffer[esi],KEY ; translate a byte
inc esi ; point to next byte
loop L1
bt AX,9 ; CF = bit 9
jc L1 ; jump if Carry