Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
31 views9 pages

Lab 2 - Caal

This document provides an introduction and overview of the GNUSim8085 microprocessor simulator. It discusses the following key points in 3 sentences: GNUSim8085 is a graphical simulator for the Intel 8085 microprocessor that allows inputting and running assembly code. It displays registers, flags, memory, and I/O and includes features like breakpoints and stepping. The document then provides details on the architecture of the 8085, including its registers, flags, program counter, stack pointer, control unit, ALU, and instruction set.

Uploaded by

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

Lab 2 - Caal

This document provides an introduction and overview of the GNUSim8085 microprocessor simulator. It discusses the following key points in 3 sentences: GNUSim8085 is a graphical simulator for the Intel 8085 microprocessor that allows inputting and running assembly code. It displays registers, flags, memory, and I/O and includes features like breakpoints and stepping. The document then provides details on the architecture of the 8085, including its registers, flags, program counter, stack pointer, control unit, ALU, and instruction set.

Uploaded by

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

LAB 2 – Introduction to GNUSim8085

• Study the Introduction to GNUSim8085


Time Required: 3 hrs.
Programming Language: Assembly Language
Software Required: GNUSim8085
Hardware Required: NIL

GNUSim8085 is a graphical simulator, assembler and debugger for the Intel 8085 microprocessor in
Linux and Windows. It contains a simple editor component with syntax highlighting. Also it has a
keypad to input assembly language instructions with appropriate arguments.

The image above shows default appearance of the GNUSim8085.

In 8085 Instruction set, NOP is an instruction which is falling under Machine Control Instruction
category. NOP is a mnemonic that stands for “No Operation”. This instruction does nothing
during execution. Only it occupied 1-Byte of memory space.

Mnemonics, Operand Opcode(in HEX) Bytes


NOP 00 1

In spite of the fact that it does nothing, still it has got many different applications. It is useful in
the following cases −

 NOP instruction can be used to create small-time delay in the execution of the code. It is
very useful for generating small-time delays of the order of a few microseconds.
 8085 Microprocessor works faster compared to the speed of its other peripheral devices.
So introduction of this NOP instruction can produce synchronization of the speed.

Below are the characteristics highlights of the simulator GNUSim8085

• A keypad to input assembly language instructions with appropriate arguments.


• Easy view of register contents. The register contents by default are set to zero

• Easy view of flag contents. The flag contents by default are set to zero

• Hexadecimal <–> Decimal converter.

• View of stack, memory and I/O contents.

• Support for breakpoints for program debugging.

• Stepwise program execution.

• One click conversion of assembly program to op code listing.

• Printing support.

• UI translated in various languages

Registers and flags on the left size along with their status values; left below shows decimal to hex
conversion with I/O ports and Memory ports with editing accessibility; on the right is loaded address
contents.

Architecture of 8085
It is a general purpose microprocessor capable of addressing 64k of memory.
The device has 40 pins, require a +5V power supply and can operate with 3 MHz single phase clock.
It has also a separate address space for up to 256 I/O ports.
The instruction set is backward compatible with its predecessor 8080 even though they are not pin-
compatible.

The 8085 has a 16 bit address bus which enables it to address 64 KB of memory, a data bus 8 bit
wide and control buses that carry essential signals for various operations.

It also has a built in register array which are usually labelled A(Accumulator), B, C, D, E, H, and L.

Control Unit
Generates signals within microprocessor to carry out the instruction, which has been decoded. In
reality causes certain connections between blocks of the processor be opened or closed, so that data
goes where it is required, and so that ALU operations occur.

Arithmetic Logic Unit


The ALU performs the actual numerical and logic operation such as ‘add’, ‘subtract’, ‘AND’, ‘OR’,
etc. Uses data from memory and from Accumulator to perform arithmetic and always stores the
result of operation in the Accumulator.

Registers are a type of computer memory used to quickly accept, store, and transfer data and
instructions that are being used immediately by the CPU.
The 8085 microprocessor includes six registers, one accumulator.
In addition, it has two 16-bit registers: the stack pointer and the program counter.

The 8085 has six general-purpose registers to store 8-bit data; these are identified as B, C, D, E, H,
and L.

They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations. The
programmer can use these registers to store or copy data into the registers by using data copy
instructions.

Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This register is used
to store 8-bit data and to perform arithmetic and logical operations. The result of an operation is
stored in the accumulator. The accumulator is also identified as register A.

Flag Registers
The ALU includes five flip-flops, which 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 (C),
Sign (S), Parity (P), and Auxiliary Carry (AC) flags.
The most commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags to test
data conditions.

The respective position of these flag bits in flag register has been show the below figure. The
positions marked by “x” are to be considered as don't care bits in the flags register. The user is
not required to memorize the positions of these flags in the flags register.
Fig. Flags register

Now consider the programmer's view of 8085 contains the flags register has been depicted in the
following figure -

Fig. Programmer's view of 8085 Flags register

These individual flags are either set to 1, or reset to 0 depending on the result of execution of the
last executed arithmetic or logical instruction. But in a few arithmetic and logical instructions,
some or none of these flags are affected. Also there are some arithmetic and logical instructions,
flag bits in the flag register will not get affected as well. As example in the execution of DCX
and INX instructions, flag bit in flag register will not get affected at all.

However, in any data transfer instruction, none of the flags bits in flag register are affected. Now
let us consider each flag bit separately for our further discussions.

Carry flag (C): after performing the addition of any two 8-bit numbers, the carry generated can
be either 0 or 1. That is only 1-bit. Thus to store the carry information 1-bit storage is enough.
Instructions that use the C flag are widely used in the user programs.

Example 1: In the addition of 45H and F3H, the result thus produced will be 38H and with C flag
= 1, as shown below.
Example 2: In the addition of 85H and 1EH, the result thus produced will be A3H with C = 0, as
shown below.

Auxiliary carry flag (AC): Now let us consider the addition of any two 8-bit (2-hex digit)
numbers, a carry may be generated when we add the LS hex digits of the two numbers. Such a
carry is called intermediate carry also known as half carry, or auxiliary carry (AC). Intel prefers
to call it AC. In the above Example 1, AC was not generated but in Example 2, AC is generated.

As this is only an intermediate carry, we may not be interested in storing this bit information. But
8085 microprocessor still stores this AC information in bit position 4 of the flags register. The
result of execution of DAA instruction, is affected by the status of this flag. However, in our
8085 instruction set does not provide any instruction, which explicitly uses the AC flag.

Sign flag (S): The S flag is set to 1, when the result thus produced against any logical or
arithmetic operations is negative, indicated by MS bit of 8-bit result being 1. It is reset to 0
otherwise if the result is positive, indicated by MS bit of 8-bit result being 0.

Thus, the value of S flag is essentially the value of the MS bit of the 8-bit result. In the above
Example 1, as the 8-bit result is 38H = 0 011 1000, 0 in MSB indicates result is positive and the
sign flag is reset to 0. Note that we are not considering here the 9-bit result including the carry, to
decide the S flag value. In Example 2, as the 8-bit result is A3H = 1 010 0011, the MSB has
become 1 that means negative and the sign flag is set to 1.

But when we shall work with unsigned numbers, then we shall simply ignore the S flag. For
example, if we are treating 85H and 1EH as unsigned numbers, their sum will be the unsigned
number A3H. In this case, S flag becomes 1, but we do not care for the value of the S flag. And
we shall ignore it as well.

Instructions that use the S flag are quite often used in the user programs.

Parity flag (P): The P flag is set to 1, if the 8-bit result thus produced against any logical and
arithmetic operation has an even number of 1's in it. If there are odd number of 1's in the 8-bit
result, the P flag is reset to 0.

In our previous Example 1, as the 8-bit result 38H = 0011 1000 has three numbers of 1's, so
having odd number of 1’s, the parity flag is reset to 0. On the other hand, in Example 2, as the 8-
bit result A3H = 1010 0011 has four numbers of 1's (so an even number of 1’s), the parity flag is
set to 1.
As the user does not really care for the number of 1's present in the result after an arithmetic
operation, this flag is not of much use practically.

Zero flag (Z): The Z flag is set to 1, if after arithmetic and logical operations, the 8-bit result
thus produced, is 00H. If the 8-bit result is not equal to 00H, the Z flag is reset to 0. Thus the Z
flag is hoisted to indicate that the result is 0.

In previous Example 1, as the 8-bit result is 38H and is non-zero, the Z flag is reset to 0. Also in
the other hand in Example 2, as the 8-bit result is A3H, the Z flag is reset to 0 here again.
Instructions that use the Z flag are widely used in the user programs.

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.

Instruction Register / Decoder


This is a temporary store for the current instruction of a program. Latest instruction is sent to here
from memory prior to execution. Decoder then takes instruction and ‘decodes’ or interprets the
instruction. Decoded instruction is then passed to next stage.

Memory Address Register (MAR)


Holds addresses received from PC for eg: of next program instruction. MAR feeds the address bus
with address of the location of the program under execution.

Control Generator
Generates signals within microprocessor to carry out the instruction which has been decoded. In
reality it causes certain connections between blocks of the processor to be opened or closed, so that
data goes where it is required, and so that ALU operations occur.

Register Selector
This block controls the use of the register stack. Just a logic circuit which switches between different
registers in the set will receive instructions from Control Unit.

Program Status Word


PSW stands for Program Status Word. PSW combines accumulator A and flag register F.

8085 System Bus


The microprocessor performs four operations primarily.
• Memory Read
• Memory Write
• I/O Read
• I/O Write
All these operations are part of the communication processes between microprocessor and peripheral
devices. The 8085 performs these operations using three sets of communication lines called buses -
the address bus, the data bus and the control bus.

Address Bus
The address bus is a group of 16 lines. The address bus is unidirectional: bits flow only in one
direction – from the 8085 to the peripheral devices. The microprocessor uses the address bus to
perform the first function: identifying a peripheral or memory location. Each peripheral or memory
location is identified by a 16 bit address. The 8085 with its 16 lines is capable of addressing 64 K
memory locations.

Data Bus
The data bus is a group of eight lines used for dataflow. They are bidirectional: data flows in both
direction between the 8085 and memory and peripheral devices. The 8 lines enable the
microprocessor to manipulate 8-bit data ranging from 00 to FF.

Control Bus
The control bus consists of various single lines that carry synchronization signals. These are not
groups of lines like address of data bus but individual lines that provide a pulse to indicate an
operation. The 8085 generates specific control signal for each operation it performs. These signals
are used to identify a device type which the processor intends to communicate

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.

Instruction Register / Decoder


This is a temporary store for the current instruction of a program. Latest instruction is sent to here
from memory prior to execution. Decoder then takes instruction and ‘decodes’ or interprets the
instruction. Decoded instruction is then passed to next stage.

Memory Address Register (MAR)


Holds addresses received from PC for eg: of next program instruction. MAR feeds the address bus
with address of the location of the program under execution.

Control Generator
Generates signals within microprocessor to carry out the instruction which has been decoded. In
reality it causes certain connections between blocks of the processor to be opened or closed, so that
data goes where it is required, and so that ALU operations occur.

Register Selector
This block controls the use of the register stack. Just a logic circuit which switches between different
registers in the set will receive instructions from Control Unit.

8085 System Bus


The microprocessor performs four operations primarily.
• Memory Read
• Memory Write
• I/O Read
• I/O Write
All these operations are part of the communication processes between microprocessor and peripheral
devices. The 8085 performs these operations using three sets of communication lines called buses -
the address bus, the data bus and the control bus.

Address Bus
The address bus is a group of 16 lines. The address bus is unidirectional: bits flow only in one
direction – from the 8085 to the peripheral devices. The microprocessor uses the address bus to
perform the first function: identifying a peripheral or memory location. Each peripheral or memory
location is identified by a 16 bit address. The 8085 with its 16 lines is capable of addressing 64 K
memory locations.

Data Bus
The data bus is a group of eight lines used for dataflow. They are bidirectional: data flows in both
direction between the 8085 and memory and peripheral devices. The 8 lines enable the
microprocessor to manipulate 8-bit data ranging from 00 to FF.

Example for assembly language:


MVI: - move immediate date to a register or memory location.
MOV: - This instruction is used to copy the data from one place to another.
LDA: - Load accumulator. (this instruction copies the data from a given 16 bit address to the
accumulator)
MVI A, 2H ;Copy value 2H in register A
MVI B, 4H ;Copy value 4H in register B
Exercises: LAB 02

1. Write a code which stores 8-bit data in memory using direct addressing. You can use the
following algorithm:

1. Store 49H in the accumulator


2. Copy accumulator contents at address 2501H
3. Stop

2. Write a code which moves the contents of register A to register C

Write heading Windows Environment above/before the snapshot.


 Put another Copy of the snapshot in Word, put heading Program Output
 Copy and Paste the CODE (in text form) in MS Word, put heading Program Source
Code

NOTE:
Make a proper word document which includes:
1. Code
2. Proper comments in your own words with code
3. Clear screenshots of output
No late submissions will be entertained.

You might also like