CSE 322 Fall 2018 Lab 5

      No Comments on CSE 322 Fall 2018 Lab 5

Problem #1 (Chapter 7 examples)

Introduction to logical instructions

//Solution
mov ax, 01010101b
mov bx, 10101010b 
;And Instruction: Logical AND and the result is stored in the first register
mov cx, ax
and cx, bx 

;OR Instruction: Logical OR and the result is stored in the first register
mov cx, ax
or cx, bx 

;XOR instruction: Logical XOR and the result is stored in the first register
mov cx, ax
xor cx, bx

;NOT instruction: Logical NOT and the result is stored in the same register
mov cx, ax
not cx 

;Test instruction: Does Logical AND instructions but does not stores the result. Changes the flags
test ax, bx

Problem #2

Use test instruction to check if the content in the register
AX is 0

//Solution
To be done by the students

Problem #3 (Odd even checker)

Use logical instructions to check if the value stored in ax is odd or even. If the number is odd print ‘O’ and if it is even print ‘E’

//Solution
To be done by students

Problem #4

Masking and testing bits

//Solution
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

Problem #5 (Case conversion)

Use only logical instruction to convert characters from uppercase to lowercase

//Solution
top:
mov ah, 1
int 21h

or al, 00100000b

mov ah, 2
mov dl, al
int 21h
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h 
jmp top

Problem #6 (Case conversion)

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

//Solution
To be done by the students

Problem #7 (Case conversion)

Use only logical instruction to convert characters from uppercase to lowercase and from lowercase to uppercase. i.e. flipping the case

//Solution
To be done by students

Problem #8

Rotate and shift instructions

//Solution
Marut example 7.1-7.13

Homework
Marut example 7.1-7.13
Section 7.4 Binary and HEX I/O [Total 4 codes]
Chapter 7 Exercise 8

Submit your homework through this link

Leave a Reply

Your email address will not be published. Required fields are marked *