0% found this document useful (0 votes)
3 views

ste.pdf

The document provides an overview of macros in NASM, outlining their definition, syntax, and usage in assembly programming. It details the program development steps, including problem definition, algorithm creation, coding, and initialization, as well as the tools required for assembly language program development such as editors, assemblers, linkers, and debuggers. The conclusion emphasizes the understanding gained in assembly programming and system operations through the project.

Uploaded by

Surabhi Gharat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ste.pdf

The document provides an overview of macros in NASM, outlining their definition, syntax, and usage in assembly programming. It details the program development steps, including problem definition, algorithm creation, coding, and initialization, as well as the tools required for assembly language program development such as editors, assemblers, linkers, and debuggers. The conclusion emphasizes the understanding gained in assembly programming and system operations through the project.

Uploaded by

Surabhi Gharat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

INTRODUCTION

• What is MACRO?

 A macro is a sequence of instructions, assigned by a name and


could be used anywhere in the program. In NASM, macros are
defined with %macro and %end macro directives. The macro
begins with the %macro directive and ends with the %end
macro directive.

Syntax for macro :

• %macro macro_name number_of_params


<macro body>
%end macro
Where, number_of_params specifies the number parameters,
macro_name specifies the name of the macro.

• The macro is invoked by using the macro name along with the
necessary parameters. When you need to use some sequence of
instructions many times in a program, you can put those
instructions in a macro and use it instead of writing the
instructions all the time.

• We have observed that, some instructions like IMUL, IDIV, INT,


etc., need some of the information to be stored in some particular
registers and even return values in some specific register(s). If the
program was already using those registers for keeping important
data, then the existing data from these registers should be saved in
the stack and restored after the instruction is executed.
 PROGRAM DEVELOPMENT STEPS

• The Programming in Assembly language or for that matter any language


follows the specific sequence of steps which is called as Program
Development steps. It is also called as Program Development Life Cycle
(PDLC) or Software Development Life Cycle (SDLC).

• These steps can be listed as follows –

1. Defining the Problem

2. Representation of the Program Logic by - ➤ Algorithm – Textual


representation

 Algorithm -Textual representation 


Flowchart-Graphical representation

3. Coding – Choosing correct Instructions

4. Converting Algorithms to Assembly Language Programs

5. Converting Algorithm to assembly language program

• The further discussion gives the detailed account of above mentioned


steps.
 Definition the Problems

• The first step in writing a program is to think very carefully about the
problem that you want the program. It is a good idea to write down
exactly what you want the program to do and the order in which you

• Want the program to do it. At this point you do not write down program
statements, you just write the operations you want in general terms.

• It involves finalizing the functionality (What the program is supposed to


do) as well as the Input and Output Specifications (What the program
receives from the user and what the program delivers are result, to the
user)

• Specifying functional and I/O specs is very crucial part of this Problem
definition stage.

Algorithm :
• Once the problem is defined, it is analyzed for the solution. The solution
is designed for the given problem.

• The solution is crystallized and it is required to be represented


systematically, by some specific method or in the standard form.

• Algorithm is defined as the textual mode representation of the specific


program logic designed; in the form of sequence of steps.

• The language used is English like but important control structures are
expressed by specific words such as SET (To initialize The Entity or
variable
All operational details are in the form of step by step sequence and it
makes easy for the programmer to understand the flow of the program.

• The algorithm is programming language independent


In many cases, the program logic and flow is written in the Technical
language having appearance similar to generic programming languages
such as C, C++ and called as Pseudo-code which is another form of
Algorithmic expression.

 Initialization checklist :

• Besides the instructions constituting main program, there are few


additional instructions that you need to determine before you actually
write your program.

• The purpose of these additional instructions is to initialize various parts


of the system, such as segment registers, Flags and Programmable ports.

• The various segment registers are initialized by loading immediate value


in it. But this cannot be Done directly
because immediate data cannot be loaded directly in segment registers, e.g. to
load 0500 in DS, the instruction sequence will be -MOV AX, Ø5ØØ
followed by MOV DS, AX.

• Thus before writing a program, the initialization check list should be


prepared as follows.

 Data segment register DS

 Stack segment register SS

 Extra segment register ES

 Stack pointer register SP

 8255 Programmable parallel port

 8259 A Programmable interrupt controller

 8254 programmable counter

 8251 A programmable serial port

 Initialize data variables, Set Interrupt Enable flag


 Initialize the constants and Flags, if required any.

Converging Algorithm To Assembly Language

o Every step in the algorithm is converted into program statement


using correct and effection instruction or group of instruction.

o When all steps are converted in this way, it forms the assembly
language program for given problem. The program is now ready.
At the start of program, required initialization instructions are
written.

The program should have following sequence of Operations-

 Initialize Variables and Data structures needed for the program

 Initialize Constants needed

 Declare un-initialized variables, data structures using assembler operators

 Done with Data Segment

 Work with Code Segment

 Initialize required Segment registers

 Initialize Stack by loading the Stack pointer

 Initialize Ports, flags, Chips as per the initialization checklist

 Write Instructions/Set of Instructions for Algorithm/Flowchart steps

 Write Subroutines and Macro, if needed any


 Done with the Code segment
 End program with specified entry point.

 ASSEMBLY LANGUAGE PROGRAM DEVELOPMENT TOOLS

• These tools are programs which help you run the program to
perform same function on the program you are writing

• These tools are pre develop program software that come to the
aid of developer programmer for writing assembling running
testing and debugging the program at the various stages in the
program development life cycle.

EDITOR
• An editor is a program which allows you to create a file
containing the Assembly language statements for your program.

• Program is typed using editor. If there is any typing error, it can


corrected by moving the cursor at that position and
correcting/re-typing it. It is needed to store the Assembly
language program source code file with ASM extension. E.g.
MyProg.ASM
• With the Editor tool, we are able to create, edit, modify, list,
print, save or update and delete the Assembly language source
code files of the program.

• Examples of the Editor are – EDIT from the DOS, NOTEPAD


and
WORDPAD of the Microsoft Windows, are the well known
editors

Assembler
• An assembler is a program used to translate or convert the assembly
language mnemonics of the source code program for instructions to
the corresponding binary codes (machine language) which is called
as the Object code of the program.

• It uses the source file with ASM extension, as an input.

• It works in two pass. On the first pass through source program, the
assembler determines the displacement of named data items, the
offset of labels, etc. and puts this information in a symbol table.

• On the second pass through the source program, the assembler


produces the binary code for each instruction and inserts the offset
etc. that is calculated during the first pass.

• The assembler generates two files as output.

• The output file is called object file and has extension OBJ. The
object file contains the binary codes for the instructions and
information about the addresses of the instructions. After further
processing the contain of this file would be loaded into memory and
executed

• The other file generated by the assemblers is list file having


extension LST. This file contains assembly instruction and binary
code side by side this can be used for testing and debugging

• Assembler finds the syntax errors. These errors can be corrected by


re-editing the program using editor and then assembled again. This
process is repeated to get syntax error-free source code of the
program.
• Examples of Assembler are – MASM, TASM etc.

Linker
o Linker is a program used to join several object files into one large
object file and converts the machine language object code of the
program into Executable code of the program

o When writing large programs, it is usually much more efficient to


divide the large program into smaller modules. Each module can be
individually written, tested, and debugged. Then, when all the
modules work, their object modules can be linked together to form
a large, functioning program.

o Also the object modules for useful programs like square root
program can be kept in library file and linked into other program as
needed. The linker produces a link file which contains the binary
codes for all the combined modules.

o The linker also produces a link map file which contains the address
information about the linked files.
o The linker assigns only relative address to the program starting
from zero This form of program is said to be re-locatable because it
can be put anywhere in memory to be run.

o TASM or MASM assemblers use Tlink exe and Link exe as the
linker tools, respectively. The output of the linker is executable
code of the developed program, which is stored as .EXE file.

Debugger
o If the program does not require any external hardware or
console input or output then debugger is used to load the. EXE
file in main memory and run it.

o It automatically assigns physical starting address to the


segments.

o Debugger is the tool that helps us test and examine the program
for its desired specified functionally as it is executing.

o By executing instructions stepwise, you can check the contents


of registers and memory locations and check the problems or
software bugs at the various steps or stages in the program.

o Debugging is essentially a Testing tool. It employees testing and


debugging methods such as Single stepping, Trace, Watches and
Breakpoints for this purpose.

o Debugger optionally generates DBG files, which can be of help


to the developer/programmer in checking testing program
variable and logic.
o Logical errors in the program are detected in the process of
debugging with the help of the debugger. Logical errors are
errors in the logic of the program. i.e. Program does not
function the way it is supposed to.

o Logical errors are removed by doing appropriate corrections in


the operating program logic as suitably modifying the source
code of the Program, accordingly.
• Conclusion
Thus by completing by project we have not only understand the Assembly
programming language but also different method of solving a problem. we
have understood the core of system related operation getting value and
passing to variable, shifting of data resisting etc.

• Reference
 https://www.educba.com/what-is-assembly-language/

 https://en.m.wikipedia.org/wiki/Assembly_language

 https://www.quora.com/What-are-some-projects-in-
assemblylanguagethat-I-can-make-for-my-college

You might also like