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

Cl11 Notes Mod4

Ca

Uploaded by

mk.kavitha2006
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Cl11 Notes Mod4

Ca

Uploaded by

mk.kavitha2006
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

MODULE IV
THE 8085 MICRPROCESSOR
 Architecture of 8085

Intel 8085 is an 8-bit, NMOS microprocessor designed by Intel in 1977.


o It is a 40 pin I.C. package fabricated on a single LSI chip.
o The Intel 8085 uses a single +5Vd.c. supply for its operation.
o Intel 8085’s clock speed is about 3 MHz; the clock cycle is of 320ns.
o 8 -bit data bus.
o Address bus is of 16-bit, which can address up to 64KB
o 16-bit stack pointer
o 16-bit PC (Program Counter).
o Six 8-bit registers are arranged in pairs: BC, DE, HL
Intel 8085 is used in mobile phones, microwave ovens, washing machines etc.

o ALU
The Arithmetic and Logic Unit, ALU performs the arithmetic and logical
operations: Addition, Subtraction, Logical AND, Logical OR, Logical
MODULE – 4- CA PROF. ANJALI SOMAN
PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

EXCLUSIVE OR, Complement (Logical NOT), Increment (add 1),


Decrement (subtract 1), Left shift, Rotate left, Rotate right, Clear, etc.

o Timing and Control Unit

It is used to generate timing and control signals which are necessary for the
execution of instructions. It is used to control data flow between CPU and peripherals
(including memory). It is used to provide status, control and timing signals which are
required for the operation of memory and I/O devices. It is used to control the entire
operations of the microprocessor and peripherals connected to it. Thus, we can see
that the control unit of the CPU acts as the brain of the computer system.

o Registers

Registers are used for temporary storage and manipulation of data and
instructions by the microprocessor. Data remain in the registers till they are sent to the
I/O devices or memory. Intel 8085 microprocessor has the following registers:

o One 8-bit accumulator (ACC) i.e. register A,


o Six general purpose registers of 8-bit, these are B, C, D, E, H and L,
o One 16-bit stack pointer, SP,
o One 16-bit Program Counter, PC,
o Instruction register,
o Temporary register.

In addition to the above-mentioned registers the 8085 microprocessor contains


a set of five flip-flops which serve as flags (or status flags).

A flag is a flip-flop which indicates some conditions which arises after the
execution of an arithmetic or logical instruction.
1. Accumulator (ACC): The accumulator is an 8-bit register associated with the
ALU. The register 'A' is an accumulator in the 8085. It is used to hold one of
the operands of an arithmetic and logical operation.
The final result of an arithmetic or logical operation is also placed in the
accumulator.
2. General-Purpose Registers: The 8085 microprocessor contains six 8-bit
general purpose registers. They are: B, D, C, E, H and L register.
To hold data of 16-bit a combination of two 8-bit registers can be employed.
The combination of two 8-bit registers is called register pair. The valid register
pairs in the 8085 are: D-E, B-C and H-L. The H-L pair is used to act as a
memory pointer.
3. Program Counter (PC): It is a 16-bit special purpose register. It is used to hold
the address of memory of the next instruction to be executed. It keeps the track
of the instruction in a program while they are being executed.
MODULE – 4- CA PROF. ANJALI SOMAN
PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

The microprocessor increments the content of the next program counter during
the execution of an instruction so that at the end of the execution of an
instruction it points to the next instruction’s address in the program.
4. Stack Pointer (SP): It is a 16-bit special function register used as memory
pointer. A stack is nothing but a portion of RAM. In the stack, the contents of
only those registers are saved, which are needed in the later part of the
program.
The stack pointer (SP) controls the addressing of the stack. The Stack Pointer
contains the address of the top element of data stored in the stack.
5. Instruction Register: The instruction register holds the opcode (operation code
or instruction code) of the instruction which is being decoded and executed.
6. Temporary Register: It is an 8-bit register associated with the ALU. It holds
data during an arithmetic/logical operation. It is used by the microprocessor. It
is not accessible to programmer.
7. Flags: The Intel 8085 microprocessor contains five flip-flops to serve as a
status flags. The flip-flops are reset or set according to the conditions which
arise during an arithmetic or logical operation.

The five status flags of Intel 8085 are:


o Carry Flag (CS)
o Parity Flag (P)
o Auxiliary Carry Flag (AC)
o Zero Flag(Z)
o Sign Flag(S)

If a flip-flop for a particular flag is set, then it indicates 1. When it is reset, it


indicates 0.

o Data and Address Bus

The Intel 8085 is an 8-bit microprocessor. Its data bus is 8-bit wide and therefore, 8
bits of data can be transmitted in parallel from or to the microprocessor. The Intel 8085
requires an address bus of 16-bit wide as the memory addresses are of 16-bits. The 8
most significant bits of the address are transmitted by the address bus, A-bus (pins
A8 to A15). The 8 least significant bits of the address are transmitted by data/address
bus, AD-bus (pins AD0 to AD7).

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

 Pin Configuration

Address Bus and Data Bus

o A8 to A15 (Output): These are address bus and are used for the most significant bits
of the memory address or 8-bits of I/O address.
o AD0 to AD7 (Input/output): These are time multiplexed address/data bus i.e. they
serve dual purpose. They are used for the least significant 8 bits of the memory
address or I/O address during the first cycle. Again, they are used for data during 2nd
and 3rd clock cycles.

Control and Status Signals

o ALE (Output): ALE stands for Address Latch Enable signal. ALE goes high during
first clock cycle of a machine cycle and enables the lower 8-bits of the address to be
latched either into the memory or external latch.
o IO/M (Output): It is a status signal which distinguishes whether the address is for
memory or I/O device.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

o S0, S1 (Output): These are status signals sent by the microprocessors to distinguish
the various types of operation given in table below:

Status codes for Intel 8085

S1 S0 Operations

0 0 HALT

0 1 WRITE

1 0 READ

1 1 FETCH

o RD (Output): RD is a signal to control READ operation. When it goes low, the


selected I/O device or memory is read.
o WR (Output): WR is a signal to control WRITE operation. When it goes low, the
data bus' data is written into the selected memory or I/O location.
o READY (Input): It is used by the microprocessor to sense whether a peripheral is
ready to transfer a data or not. If READY is high, the peripheral is ready. If it is low
the micro-processor waits till it goes high.

Interrupts and Externally Initiated Signals

o HOLD (INPUT): HOLD indicates that another device is requesting for the use of the
address and data bus.
o HLDA (OUTPUT): HLDA is a signal for HOLD acknowledgement which indicates
that the HOLD request has been received. After the removal of this request the HLDA
goes low.
o INTR (Input): INTR is an Interrupt Request Signal. Among interrupts it has the
lowest priority. The INTR is enabled or disabled by software.
o INTA (Output): INTA is an interrupt acknowledgement sent by the microprocessor
after INTR is received.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

o RST 5.5, 6.5, 7.5 and TRAP (Inputs): These all are interrupts.

o When any interrupt is recognized, the next instruction is executed from a fixed
location in the memory as given below:

Line Location from which next


instruction is picked up

TRAP 0024

RST 5.5 002C

RST 6.5 0034

RST 7.5 003C

RST 7.5, RST 6.5 and RST 5.5 are the restart interrupts which cause an internal restart to
be automatically inserted.

The TRAP has the highest priority among interrupts. The order of priority of interrupts is
as follows:
o TRAP (Highest priority)
o RST 7.5
o RST 6.5
o RST 5.5
o INTR (Interrupt Request - Lowest priority).
o INTA (Interrupt Acknowledgement)

Reset Signals
o RESET IN (Input): It resets the program counter (PC) to 0. It also resets interrupt

enable and HLDA flip-flops. The CPU is held in reset condition till RESET is not
applied.
o RESET OUT (Output): RESET OUT indicates that the CPU is being reset.

Clock Signals

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

o X1, X2 (Input): X1 and X2 are terminals to be connected to an external crystal


oscillator which drives an internal circuitry of the microprocessor. It is used to
produce a suitable clock for the operation of microprocessor.
o CLK (Output): CLK is a clock output for user, which can be used for other digital
ICs. Its frequency is same at which processor operates.

Serial I/O Signals


o SID (Input): SID is data line for serial input. The data on this line is loaded into the
seventh bit of the accumulator when RIM instruction is executed.
o SOD (Output): SOD is a data line for serial output. The seventh bit of the
accumulator is output on SOD line when SIM instruction is executed.

Power Supply
o Vcc: +5 Volts supply
o Vss: ground reference
o Vpp: for connecting EPROM

 8085 programming model

The programming model of 8085 consists of an 8-bit accumulator, flag registers, 6


general-purpose registers, two 16-bit special purpose registers.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

Accumulator:
Accumulator is an 8-bit register. For processing the numbers, 8085 assumes that one of the
numbers is in
accumulator. After processing, the result is accumulated in accumulator. The usage of the
accumulator is given below in assembly language format:
MOVA, M
MOV B, C
; this instruction moves the content of a memory location into accumulator It moves the
content of register C into register B.
ADD B; it adds the content of Accumulator(A) and B and saves the result in
Accumulator(A). AB A+B
STA 2020H
; This instruction saves the content of accumulator at memory location given in HL pair.

General purpose registers:


8085 has six general purpose registers. These are B, C, D, E, H, L registers.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

All these registers are 8-bits each. These registers can also be used in pair as BC, DE and
HL for use as 16-bit data operations. The above registers when used in pair act as follows:
BC: 8-bit B and 8-bit C registers can be used as one 16-bit BC register pair. When used as
a pair register C contains the low-byte. Some instructions use register pair BC as a data
pointer.
DE: 8-bit D and 8-bit E registers can be used as one 16-bit DE register pair. When used as
a pair register E contains the low-byte. Some instructions use register pair DE as a data
pointer.
HL: 8-bit H and 8-bit L registers can be used as one 16-bit HL register pair. When used as
a pair register L contains the low-byte. Some instructions use register pair HL as a memory
pointer.

Program Counter (PC):


This 16-bit register deals with sequencing the execution of instructions. This register is a
memory pointer. Memory locations have 16-bit addresses, and that is why this is a 16-bit
register.
The microprocessor uses this register to sequence the execution of the instructions. The
function of the program counter is to point to the memory address from which the next
byte is to be fetched. When a byte (machine code) is being fetched, the program counter is
incremented by one to point to the next memory location.

Stack Pointer (SP):


The stack pointer is also a 16-bit register used as a memory pointer. It points to a memory
location in R/W memory, called the stack. The beginning of the stack is defined by loading
16-bit address in the stack pointer. The 8085 uses PUSH and POP instructions for stack
operations.

Flag Register:
ALU of 8085 contains a special register called a "Flag register" and is an 8-bit register. At
the time of design of 8085 only five flags of this register were used and the rest three were
reserved. These flags are set or reset after an operation according to data conditions of the
result in the accumulator and other registers. They are called Zero(Z), Carry (CY), Sign
(S), Parity (P), and Auxiliary Carry (AC) flags; their bit positions in the flag register are
shown in the Figure below. The most commonly used flags are Zero, Carry, and Sign. The
microprocessor uses these flags to test data conditions.

o Carry Flag – Carry flag is used to understand whether a carry is generated as a


result of adding two numbers.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

o Parity Flag - Parity flag is used to indicate whether the parity of the number
has changed or not. The parity flag ('P') is set to one if the number of '1's in the
result is odd. The flag is reset to 'O' if the number '1' in the result is even. In
figure (a) the result of 'A+B' = 1010111. Here number of 1's is five i.e. odd
number of bits are high ('1'), so the parity flag gets set to "1.

o Auxiliary Carry Flag - This flag is set or reset depending on whether there is a
carry out as result of addition of the lower nibble data of an eight-bit number.

o Zero Flag - The zero flag is an indication of whether the result of addition or
subtraction is zero or non-zero. If the addition or subtraction of two numbers
result in zero, the zero (Z) flag is set to "1', in case of a non-zero result the flag
will be reset to zero.

o Sign Flag - The MSB of the number indicates its sign, and is of interest when
dealing with signed numbers. For processing the unsigned numbers, we simply
ignore the sign bit. The sign (S) flag will be set to '1' if the result of addition or
subtraction results in a negative answer. For the positive result the sign flag
will be reset to '0'.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

In the above figure, +ve numbers is represented by taking the sign bit as '0'
and negative number is represented by taking the sign-bit as '1. Negative
number (-7) is represented as 11111000 in 1's complement representation. So,
the addition of +6 ("00000110") and -7(11111000") results in "11111110". In
the example above the MSB of the result is "1", it indicates that the result is
negative, and this sets the sign (S) flag to 1. For the positive result i.e. when
the MSB of the result is '0', the sign (S) flag is reset to '0'.

 Instruction Classification
A binary command that is used to perform a function in the microprocessor over
provided data is known as instruction. A set of instructions is known as an instruction
set that decides the microprocessor function. Every instruction includes two parts like
Opcode & the Operand where Opcode is used to specify the function to be executed &
operand gives the data to be functioned on.

 Classification of Instructions based on word length


 Classification of Instructions based on Function/Purpose
 Classification of Instructions based on Word length – The 8085 instruction set is
classified into 3 categories by considering the length of the instructions. In 8085, the
length is measured in terms of “byte” rather than “word” because 8085 microprocessor has
8-bit data bus. Three types of instruction are: 1-byte instruction, 2-byte instruction, and 3-
byte instruction.
 One-byte instructions – In 1-byte instruction, the opcode and the operand of an
instruction are represented in one byte. Example-1: Task- Copy the contents of
accumulator in register B.
Mnemonic- MOV B, A
Opcode- MOV
Operand- B, A
Hex Code- 47H
Binary code- 0100 0111

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

 Two-byte instructions - Two-byte instruction is the type of instruction in which the


first 8 bits indicates the opcode and the next 8 bits indicates the operand. Example-
1: Task- Load the hexadecimal data 32H in the accumulator.
Mnemonic- MVI A, 32H
Opcode- MVI
Operand- A, 32H
Hex Code- 3E
32
Binary code- 0011 1110
0011 0010

 Three-byte instructions – Three-byte instruction is the type of instruction in which


the first 8 bits indicates the opcode and the next two bytes specify the 16-bit address.
The low-order address is represented in second byte and the high-order address is
represented in the third byte. Example-1: Task- Load contents of memory 2050H in
the accumulator.
Mnemonic- LDA 2050H
Opcode- LDA
Operand- 2050H
Hex Code- 3A
50
20
Binary code- 0011 1010
0101 0000
0010 0000

 Classification of Instructions based on Function –

o Data Transfer Instruction - An instruction that is used to transfer the data from one
register to another is known as data transfer instruction. So, the data transfer can be
done from source to destination without changing the source contents. Data transfer

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

mainly occurs from one register to another register, from memory location to register,
register to memory, and between an I/O device & accumulator.

Mov r, M - This data transfer instruction is used to transfer data present within the
memory (M) to the register (r). But the memory location address must be there within
the HL register. Example: MOV R, 1020H

Mov M, Data - This type of instruction specifies the data transfer immediately to a
location of memory. This memory location address can be specified at the H-L
registers. Example: MOV M, 28H

MVI r, Data (Move Immediate) - In this type of instruction, the transmission of data
can be done immediately toward the particular register. E.g.: MVI R, 32H

o Arithmetic Instruction of 8085 - The arithmetic instructions perform different


operations like addition, subtraction, increment & decrement on the data within
memory & register in the 8085 microprocessor.

ADD r - This arithmetic instruction adds the data which is available in the register
to the data available within the accumulator & the final result will be stored in the
accumulator. Example: ADD C

ADD M - This type of instruction is mainly used to add the date in the memory
address data denoted at the operand to the data available at the accumulator. So, the
addition result will be stored within the accumulator. Example: ADD 28H

ADI Data (Add Immediate) - In this instruction, the 8-bit data is specified as an
operand is added immediately to the data available at the accumulator & the result
is stored at the accumulator. Example: ADI 24 H

o Logical Instruction - Logical instructions are mainly used to perform different


operations like logical or Boolean over the data available in either memory or register.
These instructions will modify the flag bits based on the operation executed.

CMP R/M (Compare the Register/Memory with the Accumulator) - This


instruction is used to compare the data at the accumulator with the data present at
the register or memory which is given as operand. According to the result obtained
by the comparison, the flags are set. While the data that is compared remains
unchanged. Example: CMP B

ANA R/M (Logical AND register or memory with the accumulator) - This
instruction executes the AND operation of the data available within the
MODULE – 4- CA PROF. ANJALI SOMAN
PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

accumulator to the data available in the memory or register. After the operation of
AND, S, P, Z will be changed to show the outcome of the comparison. Example:
ANA C

o Branching Instruction - These types of instructions are mainly used to transfer or


switch the microprocessor from one location to another. So, it simply changes the
general sequential flow.

JMP address (Jump unconditionally) - This type of instruction is mainly used to


transfer the series of the current program to that location of memory whose 16-bit
address can be simply specified within the operand of the instruction. Example:
JMP 2014H

CALL address - This instruction shifts the control of a series of current programs
toward the memory address available at the operand. However, the PC gets
decreased before transferring. Example: CALL 2400H

RET (Return from the Subroutine) - This type of instruction can cause the
unconditional return of the sub-routine to the actual program.

o Control Instruction - These instructions are mainly used to control the


microprocessor operations. These instructions are discussed below.

NOP (No operation) - NOP stands for no operation. Once the 8085
microprocessor gets this instruction, then it does not perform any operation based
on execution.

DI (Disable Interrupts) - DI is the disabling of the interrupt that is generated


within the microprocessor. Interrupt resetting will allow disabling all the interrupts
apart from TRAP.

HLT (Halt & Enter Wait State) - Once the HLT interrupt is decoded through the
microprocessor, it stops the current operation and waits for further instruction. To
escape from the halt condition either a reset or an interrupt is necessary.

 Steps to write, assemble and execute a simple program

Each personal computer has a microprocessor that manages the computer's arithmetical,
logical, and control activities. 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'.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

A processor understands only machine language instructions, which are strings of 1's and
0's. However, machine language is too obscure and complex for using in software
development. So, the low-level assembly language is designed for a specific family of
processors that represents various instructions in symbolic code and a more
understandable form.

 Steps in Writing, Assembling and Executing an Assembly language program -

1. Writing the Source Code

 Use a text editor (e.g., Notepad, Vim, or an IDE like Visual Studio Code) to write
your assembly language program.
 Save the file with the appropriate extension for the assembler you are using
(e.g., .asm).

2. Assembling the Program

 Use an assembler to convert the assembly code into machine code (object code).
Popular assemblers include:
o NASM (Netwide Assembler) for x86 or x86-64 assembly.
o MASM (Microsoft Macro Assembler) for Windows development.
o GAS (GNU Assembler) for Unix/Linux systems.

Steps:

1. Open the terminal or command prompt.


2. Run the assembler with your source file. For example:
o NASM: nasm -f elf64 program.asm -o program.o
o MASM: ml /c /coff program.asm
o GAS: as program.s -o program.o

The assembler generates an object file (e.g., program.o).

3. Linking the Object File

 Link the object file to produce an executable. A linker combines object files and
resolves external references.

Command:

 Use a linker like ld (Linux) or the default linker of your assembler.


o For NASM on Linux: ld program.o -o program
o For MASM on Windows: Use link.exe, which often comes with MASM.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

This step produces an executable file (e.g., program or program.exe).

4. Running the Executable

 Execute the program directly in your terminal or command prompt:


o Linux: ./program
o Windows: program.exe

5. Debugging (Optional)

 If your program doesn’t work as expected, use a debugger to step through the
instructions and identify issues.
o Linux: Use gdb (GNU Debugger).
o Windows: Use Debug or Visual Studio's debugging tools.

 Steps to Execute a program in GNUSim8085 -

1. Writing the Program

1. Open GNUSim8085.
2. In the editor, write the 8085 assembly program. For example:

Assembly

MVI A, 0x05 ; Load immediate value 5 into the accumulator

MVI B, 0x03 ; Load immediate value 3 into register B

ADD B ; Add the value of register B to the accumulator

HLT ; Halt the program

3. Save your program:


o Go to File > Save As.
o Save the file with a .asm extension (e.g., program.asm).

2. Assembling the Program

 GNUSim8085 automatically converts the assembly instructions into machine code


when you run the program.
 To ensure your code is error-free:
o Click on Assemble from the toolbar or go to Tools > Assemble.
o Check for any syntax errors in the output window.

3. Executing the Program

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

1. Set Memory and Registers (if needed):


o Go to View > Memory to set initial memory values if required.
o Open View > Registers to observe register values.
2. Run the Program:
o Click on the Run button (▶) or go to Simulator > Run.
o The program will execute until it encounters the HLT instruction.
3. Step-by-Step Execution:
o Use Step Into (F7) or Step Over (F8) to execute instructions one by one.
o Observe how the values in registers and memory change after each step.
4. View Results:
o Check the Registers window to see the final values of registers.
o View Memory to see any changes in memory locations if your program stores
data there.

 Addressing modes of 8085


An addressing mode in a microprocessor defines the way in which the operand (data) is
specified for an instruction. It determines how the data is accessed from memory or
registers and how it is operated upon. The various addressing modes allow for flexibility
in how instructions interact with data, making it possible to optimize performance,
minimize memory usage, and reduce code complexity. The 8085 microprocessor, for
example, uses multiple addressing modes such as immediate, direct, and indirect, each
suited to specific programming needs.

In 8085 Microprocessor there are 5 Types of Addressing Modes -


 Immediate Addressing Mode
In immediate addressing mode the source operand is always data. If the data is 8-bit,
then the instruction will be of 2 bytes, if the data is of 16-bit then the instruction will
be of 3 bytes.
Examples
MVI B 45 (move the data 45H immediately to register B)
LXI H 3050 (load the H-L pair with the operand 3050H immediately)
JMP address (jump to the operand address immediately)

 Register Addressing Mode


In Register Addressing Mode, the data to be operated is available inside the register(s)
and register(s) is(are) operands. Therefore, the operation is performed within various
registers of the microprocessor.

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

Examples:
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in register A)
INR A (increment the contents of register A by one)

 Direct Addressing Mode


In direct addressing mode, the data to be operated is available inside a memory
location and that memory location is directly specified as an operand. The operand is
directly available in the instruction itself.
Examples:
LDA 2050 (load the contents of memory location into accumulator A)
LHLD address (load contents of 16-bit memory location into H-L register pair)
IN 35 (read the data from port whose address is 35)

 Register Indirect Addressing Mode


In register indirect addressing mode, the data to be operated is available inside a
memory location and that memory location is indirectly specified by a register pair.
Examples:
MOV A, M (move the contents of the memory location pointed by the H-L pair to the
accumulator)
LDAX B (move contents of B-C register to the accumulator)
STAX B (store accumulator contents in memory pointed by register pair B-C)

 Implied/Implicit Addressing Mode


In implied/implicit addressing mode the operand is hidden and the data to be operated
is available in the instruction itself.
Examples:
CMA (finds and stores the 1’s complement of the contents of accumulator A in A)
RRC (rotate accumulator A right by one bit)
RLC (rotate accumulator A left by one bit)

 Relative Addressing Mode


In this mode, the operand is a memory location specified by the contents of the
program counter plus a constant value.
Example:
MOV R0,#05H
AGAIN:
MVI A,#55H

MODULE – 4- CA PROF. ANJALI SOMAN


PKM Educational Trust

RR Institute of Management Studies


(Affiliated to Bangalore University, Recognized by Karnataka Government)
Raja Reddy Layout, Chikkabanavara, Bengaluru-560090
COURSES OFFERED:
BBA | BBA-Aviation | BCA | MSc & BSc -Forensic Science | BCom IQAC

ADD A,R0
JMP AGAIN

In this example, the instruction JMP AGAIN uses the Relative Addressing Mode. The
instruction jumps to the label AGAIN by adding the contents of the program counter with
the specified constant value. The constant value is calculated based on the distance
between the current instruction and the label AGAIN.
In this case, the instruction JMP AGAIN is executing a loop that loads the accumulator
with the value 55H, adds the contents of the register R0 to the accumulator, and then
jumps back to the label AGAIN to repeat the loop.

MODULE – 4- CA PROF. ANJALI SOMAN

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy