Microprocessor Chapter3
Microprocessor Chapter3
Microprocessor Chapter3
Each family of processors has its own set of instructions for handling
various operations such as getting input from keyboard, displaying
information on screen and performing various other jobs. These set of
instructions are called 'machine language instructions'.
Make sure you have set the path of nasm and ld binaries in your PATH environment
variable. Now, take the following steps for compiling and linking the above
program −
•Type the above code using a text editor and save it as hello.asm.
•Make sure that you are in the same directory as where you saved hello.asm.
•To assemble the program, type nasm -f elf hello.asm
•If there is any error, you will be prompted about that at this stage. Otherwise, an
object file of your program named hello.o will be created.
•To link the object file and create an executable file named hello, type ld -m
elf_i386 -s -o hello hello.o
•Execute the program by typing ./hello
If you have done everything correctly, it will display 'Hello, world!' on the screen.
The INC Instruction
The INC instruction is used for incrementing an operand by one. It works on a single operand that can be either in a
register or in memory.
Syntax
The INC instruction has the following syntax −
INC destination
The DEC instruction is used for decrementing an operand by one. It works on a single operand that can can be either
in a register or in memory.
Syntax
The DEC instruction has the following syntax − DEC destination
The ADD and SUB instructions are used for performing simple addition/subtraction of binary
data in byte, word and double word size, i.e., for adding or subtracting 8-bit, 16-bit or 32-bit
operands, respectively.
However, SUB like other instructions, memory-to-memory operations are not possible using
ADD/SUB instructions.
An ADD or SUB operation sets or clears the overflow and carry flags.
The MUL/IMUL Instruction
There are two instructions for multiplying binary data. The MUL
(Multiply) instruction handles unsigned data and the IMUL (Integer
Multiply) handles signed data. Both instructions affect the Carry and
Overflow flag.