Task #1
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
Task #2
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
Task #3
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
Task #4
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
Task #5
Use only logical instruction to convert characters from lowercase to uppercase.
//Code To be done by the students
Task #6
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
Task #7
Rotate and shift instructions
Homework
- Section 6.5: Programming with High-Level Structures
- Chapter 6 Exercise 8
- Marut example 7.1-7.13
- Marut Section 7.4: Binary and HEx input output [Total 4 codes]
- Marut Chapter 7 Exercise 8