CSE-232 LAB Manual
CSE-232 LAB Manual
Lab Manual
Version: 2017.04
Expected Skills:
a. Capability of installing EMU 8086 and working with it.
b. Write, compile and execute assembly language programs using EMU 8086.
Tools Required:
a. EMU 8086
Session Detail:
Emu8086
Emu8086 combines an advanced source editor, assembler, disassemble and software emulator
(Virtual PC) with debugger. It compiles the source code and executes it on emulator step by step.
Visual interface is very easy to work with. You can watch registers, flags and memory while your
program executes. Arithmetic & Logical Unit (ALU) shows the internal work of the central processor
unit (CPU). Emulator runs programs on a Virtual PC, this completely blocks your program from
accessing real hardware, such as hard-drives and memory, since your assembly code runs on a
virtual machine, this makes debugging much easier. 8086 machine code is fully compatible with all
next generations of Intel's microprocessors, including Pentium II and Pentium 4. This makes 8086
code very portable, since it runs both on ancient and on the modern computer systems. Another
advantage of 8086 instruction set is that it is much smaller, and thus easier to learn.
The source editor of EMU86 is a special purpose editor which identifies the 8086 mnemonics,
hexadecimal numbers and labels by different colors as seen in Figure below.
The compile button on the taskbar starts assembling and linking of the source file. A report window
is opened after the assembling process is completed. Figure below shows the emulator of 8086
which gets opened by clicking on emulate button.
Sample Programs to practice on the lab (Programs to be performed may be decided by the
course teacher):
Program 1.1
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Use of basic I/O, movement & arithmetic instructions.
Tools Required:
a. EMU 8086
Session Detail:
Basic syntax will be discussed with example and then they will be asked to implement the solution of
some small problems.
I/O DOS Function Calls: Table below summarizes the main I/O functions. These functions are mainly
used to read a character or a string from the keyboard, which could be an input data to a program,
and display characters or strings, which could be results, or an output, of a program:
Program 2.1:
Write a program in assembly to read a character from the keyboard and display on the screen using
interrupt 21H.
Program 2.2:
Write a program to displays a string terminated by a $ sign using INT 21H function 09H.
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Ability to solve problems using arithmetic & other basic instructions
Tools Required:
a. EMU 8086
Session Detail:
Students will be introduced with basic arithmetic operations and they will be asked to solve
problems using these operations.
Program 3.1:
Write a program that reads two numbers from the keyboard and gives their sum as output.
Source:
.MODEL SMALL
.STACK 100H
.DATA
CRLF DB 0DH,0AH,'$'
PROMPT1 DB 'Enter the first positive integer: ','$'
PROMPT2 DB 'Enter the second positive integer: ','$'
PROMPT3 DB 'The sum of the two numbers is: ','$'
.CODE
MAIN PROC
LEA DX,PROMPT1 ;DISPLAY PROMPT1
MOV AH,09H
INT 21H
MOV CL,AL
ADD CL,30H ;CONVERT DIGIT TO CHARACTER
Program 3.2:
Write a program to convert a given lowercase letter to its uppercase form and prints it.
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Aptitude to solve more complex decision making problems using branching instructions
Tools Required:
a. EMU 8086
Session Detail:
Students will be introduced with branching operations and they will be asked to solve problems
using these operations.
Compare instruction:
The compare instruction is used to compare two numbers. At most one of these numbers may reside
in memory. The compare instruction subtracts its source operand from its destination operand and
sets the value of the status flags according to the subtraction result. The result of the subtraction is
not stored anywhere. The flags are set as indicated in Table below.
Jump Instructions:
The jump instructions are used to transfer the flow of the process to the indicated operator.
An overview of all the jump instructions is given in Table below.
Program 4.1:
Suppose AL and BL contains extended ASCII characters. Display the one that comes first in the
character sequence.
Program 4.2:
IF AX contains a negative number, put -1 in BX; if AX contains 0, put 0 in BX; if AX contains a positive
number, put 1 in BX.
Program 4.3:
Program 4.4:
Read a character. If it’s “y” or “Y”, display it; otherwise, terminate the program.
Program 4.5:
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Capability of solving problems using looping techniques.
Tools Required:
a. EMU 8086
Session Detail:
Students will be introduced with looping operations and they will be asked to solve problem using
these operations.
Types of looping:
For
While
Do While
In this lab session we will see the use of all of these looping operations.
The LOOP instruction is a combination of a DEC and JNZ instructions. It causes execution to branch to
the address associated with the LOOP instruction. The branching occurs a number of times equal to
the number stored in the CX register.
Program 5.1:
Program 5.2:
Program 5.3:
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Aptitude to solve problems associated with these operations
Tools Required:
a. EMU 8086
Session Detail:
Program 6.1:
Prompt the user to enter a line of text. On the next line, display the capital letter entered that comes
first alphabetically and the one that comes last. If no capital letters are entered, display "No capital
letters".
*More practice problems like the one above can be used by the course teacher.
Program 6.2:
*More practice problems like the one above can be used by the course teacher.
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Ability to solve problems associated with these operations
Tools Required:
a. EMU 8086
Session Detail:
Students will be introduced with basic logical operations and they will be asked to solve problems
using these operations.
Logical Instructions:
Logic shift and rotate instructions are called bit manipulation operations. These operations are
designed for low-level operations, and are commonly used for low level control of input/output
devices. The list of the logic operations of the 8086 is given below along with examples.
The shift operations are used to multiply or divide a number by another number that is a power of 2
(i.e. 2n or 2–n). Multiplication by 2 is achieved by a one-bit left shift, while division by 2 is achieved by
a one-bit right shift. The Shift Arithmetic Right (SAR) instruction is used to manipulate signed
numbers. The regular Right Shift (SHR) of a signed number affects the sign bit, which could cause
numbers to change their sign. The SAR preserves the sign bit by filling the vacated bits with the sign
of the number. Shift Arithmetic Left (SAL) is identical in operation to SAR.
The rotate operations are very similar to the shift operations, but the bits are shifted out from one
end of a number and fed back into the other end to fill the vacated bits. They are provided to
facilitate the shift of long numbers (i.e. numbers of more than 16 bits). They are also used to
reposition a certain bit of a number into a desired bit location. The rotate right or left instructions
through the carry flag (RCL and RCR) are similar to the regular rotate instructions (ROL and ROR), but
the carry flag is considered as a part of the number. Hence, before the rotate operation, the carry
flag bit is appended to the number as the least significant bit in the case of RCL, or as the most
significant bit in the case of RCR.
Program 7.1:
Source:
.MODEL SMALL
.STACK 100H
.DATA
NUM1 DW 0FA62H
NUM2 DB 94H
.CODE
MAIN PROC
MOV AX, NUM1 ;load AX with number NUM1
AND AX, 0FFDFH ;Reset 6th bit of AX
OR AL, 20H ;Set 6th bit of AL
XOR NUM1, 0FF00H; Complement the high order byte of NUM1
NOT NUM2 ; Complement NUM2
XOR AX, AX ; Clear AX
MOV AX, NUM1
AND AX, 0008H; Isolate bit 4 of NUM1
XOR AX, 0080H; Complement 4th bit of AX
MAIN PROC
END MAIN
Program 7.2:
Use ROL to count the number of l bits In BX, without changing BX. Put the answer In AX.
Program 7.3:
Program 7.4:
Program 7.5:
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Capability to solve problems using stack.
Tools Required:
a. EMU 8086
Session Detail:
Students will be acquainted with stack and its implementation and then they will be given relevant
problems which can be solved using stack.
The Stack:
The stack is a special segment in memory used to facilitate subroutine handling. The SS register
contains the Stack Segment number where the stack is stored. The ".STACK" directive instructs the
assembler to reserve a stack segment of a desired size. The stack always starts at a high address and
grows towards the beginning of the stack segment at a lower address. When a program starts, the
stack is empty, and its size is zero. The microprocessor stores data on the stack as needed, and uses
the SP register to point to the last item stored on the stack. The stack size dynamically changes as
data is stored or retrieved from the stack.
Program 9.1:
Write a program that read a string and prints its reverse string.
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings:
Expected Skills:
a. Capability of solving problems using string manipulation operations.
Tools Required:
a. EMU 8086
Session Detail:
String handling instructions are very powerful because they allow the programmer to manipulate
large blocks of data with relative ease. Block data manipulation occurs with the string instructions.
Each of the string instructions defines an operation for one element of a string only. Thus, these
operations must be repeated to handle a string of more than one element.
String handling instructions use the direction flag, SI and DI registers. The Direction Flag (DF) selects
auto-increment or auto-decrement operation for the DI and SI registers during string operations.
Whenever a string instruction transfers a byte, the contents of SI and/or DI get increased or
decreased by 1. If a word is transferred, the contents of SI and/or DI get increased or decreased by 2.
Program 10.1:
Program 10.2:
Program 10.3:
Write a program that reads a character string and displays the number of vowels and consonants in
the output.
Individual Assignments will be given based on the Skills developed in this session by the course
teacher.
References:
1. Assembly Language Programming and Organization of the IBM PC by Ytha Yu, Charles Marut.
Further Readings: