Lab 4: Programming in Assembly Language-Part2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Lab 4: Programming in Assembly Language-Part2

Assalamualaikum, Dear Friends, in this lab 4, we will continue to explore more x86
Instruction Set.

1.0 Logical Instructions

One important group of instructions is Logic Instructions. Logical instructions are used to
perform logic operations such as AND, OR, XOR and NOT.

Their operations can be understandable by simply by comparing manually. For example


AND AX, BX , What this instruction suppose to do ?

In two operand instructions, result will be stored in destination operand except for NOT
logic instruction which is a single operand instruction where source and destination
operand are same, for example NOT BX where each bit in BX will be inverted !!!

Instructions under this group are AND/OR/XOR ( two operand instructions ) NOT D
(Single Operation)

By using AND and OR instructions we can clear a bit ( to 0 ) or set a bit ( to 1)

Exercise : Set bit 3 to 1 ( of register AX ) using OR instruction

1
Lab 4: Programming in Assembly Language-Part2

2.0 SHIFT and ROTATE Instructions

2.1 Shift
Instructions are used to move positions of bits in an operand. For example, move bit 2
right 2 places, or left two places.

Exercise : Find the difference between arithmetic shift and logical shifts

2.2 Rotate instructions

While rotations are closed loop instructions in which data is moved out from one and put
into another end. Example rotate bit number 3 left by 3 units , means bit 3 is moved 3

2
Lab 4: Programming in Assembly Language-Part2

places to left, while the originals bits are also moved left, if they reach the end, then they
are feed back to another end. Following image shows rotation instruction
We options to rotate the bits thru carry flag or copy it to carry flag. Please Google the
difference, there many illustrations online.

3
Lab 4: Programming in Assembly Language-Part2

Lab Exercises

1. If CL=04 and AX=1234, determine the new contents of AX and CF after


execution the following : and draw the movements of the bit to justify your
answer

(a) ROL AX, 1 (b) ROR AX, CL

2. Write and ALP to clear bits 0 to bits 5 and set the bits 6 and bits 7 using AND
instruction

3. If AX =1234, CL=2 , write instruction to implement each of shift instruction (


SAR, SHR, SAL, SHL ) using CL

KBAT Question

Write a program, which finds a largest unsigned 8-bit number in a memory location of
your choise, and store the result in a different memory location 200. Draw a flow chart
and verify your program.

If the program above is to find the largest unsigned 16-bit number, what changes will you
do?

4
Lab 4: Programming in Assembly Language-Part2

Question:

1. Write a program to  2k+1

2. By referring to the block diagram of minimum mode of 8088, explain the functions of
the following signal lines

a. IO/M

b. SSO

c. DT/R

d. RD and WR

e. DEN

3. List 1 key difference between 8088 and 8086 from point of hardware.

4. List 2 key differences between maximum mode and minimum mode of operation of
8088.

You might also like