# CSE 322 Spring 2021 Lab 5

Introduction to logical instructions

```//Code
mov ax, 01010101b
mov bx, 10101010b

mov cx, ax
and cx, bx ;Logical AND

mov cx, ax
or cx, bx ;Logical OR

mov cx, ax
xor cx, bx ;Logical XOR

mov cx, ax
not cx ;Logical NOT

mov cx, ax
test cx, bx ;Same as Logical AND. But doesnot change the value of destination register. ONly changes the flag

mov ax, 00001111b
and ax, 00110011b ;ANDing a bit with 0 clears the bit
or ax, 11001100b ;ORing a bit with 1 sets the bit
xor ax, 00110011b ;XORing a bit with 1 flips the bit```

Use TEST instruction to check if the register AX has a value 0 or not. If AX contains 0 print 0 otherwise do nothing.

```//Code
To be done by students```

Use logical instructions to check if an input number is odd or even. If the number is odd print ‘O’ if even print ‘E’.

```//Code
To be done by students```

Use only logical instruction to convert characters from uppercase to lowercase

```//Code
top:
mov ah, 1
int 21h

mov dl, al
OR dl, 00100000b

mov ah, 2
int 21h
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h

jmp top
```

Use only logical instruction to convert characters from lowercase to uppercase.

```//Code
To be done by the students```

Use logical instructions to do a case flip. If the input is uppercase convert to lowescase and if input is lowercase convert to uppercase.

```//Code
To be done by students```