AL = 10101111b BL = 00001010b TEST AL, BL; Status of FLAGS =?
Example: Determine whether a character is uppercase or lowercase.
Example: Checking a sign or value:
Example: Determine whether a number is even or odd.
The TEST instruction works same as the AND operation, but unlike AND instruction, it does not change the first operand.
; test bl.
; even or odd
mov al, 10101111b
mov bl, 00001010b ; value
test al,bl ; cf=0, zf=0, sf=0, of=0, pf=1, af=0
; pf = 1 => bl even
Determine whether a character is uppercase or lowercase
bl= 00001010b = ASCII code of LF
character is uppercase: 010x xxxxb
character is lowercase: 011x xxxxb
;test bl
; uppercase or lowercase
mov al, 00100000b
mov bl, 01001010b ; bl = ASCII code of char ('J')
test al,bl ; zf = 1 => bl upper ; else character is lowercase
; test sigh
mov al, 10000000b
mov bl, 00001010b
test al, bl ; zf = 0 => bl positive number
Comments
Leave a comment