Unit 2
Unit 2
By
Mr. Parag R. Sali
Lecturer
Department of Computer Technology
SNJB’s Shri. Hiralal Hastimal ( Jain Brothers)
Polytechnic, Chandwad
Program Name: Computer Engineering Group
Program Code : CO/CM/IF/CW
Semester : Forth
Course Title : Microprocessors
Course Code : 22415
1. Editors
2. Assembler
3. Linker
4. Debugger.
assembly language program development steps.
1. Defining the problem: The first step in writing program is to think very carefully
about the problem that the program must solve.
2. Algorithm: The formula or sequence of operations to be performed by the
program can be specified as a step in general English is called algorithm.
3. Flowchart: The flowchart is a graphically representation of the program
operation or task.
4. Initialization checklist: Initialization task is to make the checklist of entire
variables, constants, all the registers, flags and programmable ports
5. Choosing instructions: Choose those instructions that make program smaller in
size and more importantly efficient in execution.
6. Converting algorithms to assembly language program: Every step in the
algorithm is converted into program statement using correct and efficient
instructions or group of instructions.
There are many good assembler programs, like:
Microsoft Assembler (MASM)
Borland Turbo Assembler (TASM)
The GNU assembler (GAS)
1. Programming Language
– Syntax: set of symbols + grammar rules for constructing statements using
symbols
– Semantics: what is meant by statements ultimately, what happens upon
execution
– Assembly Language : A readable language that maps one-to-one to the
machine instructions, to what operations are supported by the CPU.
Program Development..cont
2. Assembler : A Program that converts the assembly language to object
format
• Object Code is the program in machine format (ie. binary)
• May contain unresolved references (ie. file contains some or all of complete
program)
3. Linker : A program that combines object files to create an single
“executable” file
– Major functional difference is that all references are resolved. (ie. Program
contains all parts needed to run)
4. Loader : A program that loads executable files into memory, and may initialize
some registers (e.g. IP ) and starts it going.
5. Debugger : A program that loads but controls the execution of the program.
To start/stop execution, to view and modify state variables
Algorithm
Step 1 : Start
Step 2 : Declare the variable Num1,Num2 ; Sum
Step 3 : Read value for Num1,Num2
Step 4 : Add two numbers & assign the result to Sum
Sum = Num1 + Num2
Step 5 : Display the value of Sum
Step 6 : Stop
Q. Write a program to calculate area of circle
Step 1 : Start
Step 2 : Declare the variable r, area, Pi = 3.14
Step 3 : Read value for r
Step 4 : Calculate area of circle
area = Pi * r * r
Step 5 : Display the value of area
Step 6 : Stop
Flowchart
print sum
Stop
Start
Read r
calculate area
area = Pi * r * r
print area
Stop
Variables
Variable is a memory location. For a programmer it is much easier to have some
value be kept in a variable named "var1" then at the address 5A73:235B,
especially when you have 10 or more variables. Our compiler supports two types
of variables: BYTE and WORD.
Syntax for a variable declaration:
name DB value
name DW value
DB - stays for Define Byte. DW - stays for Define Word.
name - can be any letter or digit combination, though it should start with a letter.
It's possible to declare unnamed variables by not specifying the name (this
variable will have an address but no name).
value - can be any numeric value in any supported numbering system
(hexadecimal, binary, or decimal), or "?" symbol for variables that are not
initialized.
MOV instruction
copies the second operand (source) to the first operand (destination).
the source operand can be an immediate value, general-purpose register or
memory location.
the destination register can be a general-purpose register, or memory location.
both operands must be the same size, which can be a byte or a word.
these types of operands are supported:
MOV REG, memory
MOV memory, REG
MOV REG, REG
MOV memory, immediate
MOV REG, immediate
REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.