IPC_UNIT I Assembly Language Programming
IPC_UNIT I Assembly Language Programming
; This program displays a message on screen or, on the same line along with an
instruction, like −
add eax , ebx ; adds ebx to eax
⮚This segment contains data values passed to functions and procedures within the
program.
⮚The reserve directives are used for reserving space for uninitialized data.
⮚The reserve directives take a single operand that specifies the number of units of space to be
reserved.
⮚Each define directive has a related reserve directive.
⮚There are five basic forms of the reserve directive −
Directive Purpose
RESB Reserve a Byte
RESD Reserve a Doubleword
RESQ Reserve a Quadword
REST Reserve a Ten Bytes
• It is an operator.
• It informs assembler to find the number of elements in a
named data item like a string or an array.
• The length of string is always stored in Hex by the 8086.
• Its format is :
e.g. MOV CX,LENGTH STRING ; Loads the Length of string
in CX.
Return
Next Instr.
After call in
Main prog Ret. To main
Prog
7/3/2023 Introduction to Processors and Chips 71
Recursive Procedure
main Procedure Procedure
Program
Next Instr.
After call in Return Return
7/3/2023
Main prog Introduction to Processors and Chips 72
MACROS
• To simplify and reduce the amount of repetitive coding
• To reduce the errors caused by repetitive coding
• To make the ALP more readable.
• Macro executes faster because there is no need of CALL and Return.
• In NASM, macros are defined with %macro and %endmacro
directives.
• The basic format is:
%Macro Name Macro ;define macro
; body of macro
Endmacro ;End macro
⮚ First check your nasm assembler version from your terminal by command nasm -v
⮚ If you do not have latest version of nasm, please use below commands.
🡪Remove your older nasm use command sudo apt-get remove nasm
🡪 Download the attached nasm zipped file.(better you download the file in to virtual machine)
🡪Extract the zipped file into the same folder.
🡪Assuming you have extracted the file in Download directory) follow the below commands
cd ~/Downloads/ <nasm directory>
sudo ./configure
cd rdoff/
sudo make all
cd ..
sudo make all
sudo make install
⮚ your installation part should be done now. Type nasm in terminal
7/3/2023 Introduction to Processors and Chips 78
Options used in ALP
1. The -o Option: Specifying the Output File Name
NASM provides the command-line option, which allows you to specify your
-o
desired output file name. You invoke by following it with the name you wish for
-o
80