0% found this document useful (0 votes)
7 views25 pages

Coa Lab 2025 CS404 Exp 1 4

The document provides an overview of the COA Lab, focusing on assembly language programming and the 8085 microprocessor architecture. It includes a list of experiments, detailed descriptions of assembly language tools, and instructions for using the GNUSim8085 simulator. Additionally, it presents sample assembly programs for performing arithmetic operations and managing data in memory.

Uploaded by

4hmc2e62ad
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)
7 views25 pages

Coa Lab 2025 CS404 Exp 1 4

The document provides an overview of the COA Lab, focusing on assembly language programming and the 8085 microprocessor architecture. It includes a list of experiments, detailed descriptions of assembly language tools, and instructions for using the GNUSim8085 simulator. Additionally, it presents sample assembly programs for performing arithmetic operations and managing data in memory.

Uploaded by

4hmc2e62ad
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/ 25

INDEX OF THE CONTENTS of COA Lab

1. Introduction to the lab

2. List of experiments

3. Codes

PIEMR/CSE 1|Page
ASSEMBLY LANGUAGE PROGRAMMING

Machine language (computer's native language) is a system of impartible instructions


executed directly by a computer's central processing unit (CPU). Instructions consist
of binary code: 1s and 0s.

Assembly Language is a programming language that is very similar to machine


language, but uses symbols instead of binary numbers. It is converted by the
assembler (e.g. Tasm and MASM) into executable machine-language programs.

Assembly language is machine-dependent; an assembly program can only be


executed on a particular machine Introduction to Assembly Language Tools : Software
tools are used for editing, assembling, linking, and debugging assembly language
programming. You will need an assembler, a linker, a debugger, and an editor. These
tools are briefly explained below.

Assembler An assembler is a program that converts source-code programs written in


assembly language into object files in machine language. Popular assemblers have
emerged over the years for the Intel family of processors. These include MASM (Macro
Assembler from Microsoft), TASM (Turbo Assembler from Borland), NASM (Netwide
Assembler for both Windows and Linux), and GNU assembler distributed by the free
software foundation. We will use GNUSim8085 is a graphical simulator, assembler
and debugger for the Intel 8085 microprocessor in Linux and Windows.

Linker A linker is a program that combines your program's object file created by the
assembler with other object files and link libraries and produces a single executable
program. You need a linker utility to produce executable files.

Debugger A debugger is a program that allows you to trace the execution of a program

and examine the content of registers and memory.

PIEMR/CSE 2|Page
1. INTRODUCTION TO THE LAB
Computer Organization and architecture lab consist of performing various experiments in
GNU Sim (A simulator for 8085 microprocessor).

Before doing the coding on the simulator it’s necessary to study the complete architecture
of 8085 microprocessor along with its instruction set.

1.1 ARCHITECTURE OF MICROPROCESSOR 8085

PIEMR/CSE 3|Page
List of registers used in 8085 to perform various operations:

Accumulator: -It is a 8-bit register which is used to perform arithmetical and logical operation. It stores the
output of any operation. It also works as registers for i/o accesses.
It can be one of the operands in the instruction.
Temporary Register: -It is a 8-bit register which is used to hold the data on which the accumulator is
computing operation. It is also called the operand register because it provides operands to ALU.
Registers: -These are general purposes registers. Microprocessor consists of 6 general purpose registers
of 8-bit each named as B, C, D, E, H and L. Generally, these registers are not used for storing the data
permanently. It carries 8-bits data. These are used only during the execution of the instructions.
These registers can also be used to carry the 16 bits data by making the pair of 2 registers. The valid register
pairs available are BC, DE, and HL. We cannot use other pairs except BC, DE, and HL. These registers are
programmed by user.
Flag Registers: -It consists of 5 flip flops which changes its status according to the result stored in an
accumulator. It is also known as status registers. It is connected to ALU. There are five flip-flops in the flag
register as follows:

The bit position of the flip flop in flag register is:


All of the three flip flops set and reset according to the stored result in the accumulator.
1. Sign- If D7 of the result is 1 then sign flag is set otherwise reset. As we know that a number
on the D7 always decides the sign of the number.if D7 is 1: the number is negative. if D7
is 0: the number is positive.
2. Zeros(Z)-If the result stored in an accumulator is zero then this flip flop is set as 1 otherwise it is reset and
also if the result of any arithmetic or logical operation is zero its set as 1( The result of this operation can
be in any registers).
3. Auxiliary carry (AC)-If any carry goes from D3 to D4 in the output then it is set otherwise it is reset.
4. Parity(P)-If the number of 1's is even in the output stored in the accumulator then it is set otherwise it is
reset for the odd.
5. Carry(C)- If the result stored in an accumulator generates a carry in its final output, then it is set
otherwise, it is reset.

PIEMR/CSE 4|Page
Instruction registers (IR): -It is an 8-bit register. When an instruction is fetched from memory then it is stored
in this register.

Description of other components of 8085 to:


Instruction Decoder: - Instruction decoder identifies the instructions. It takes the information from
the instruction register and decodes the instruction to be performed.
Program Counter: -It is a 16-bit register used as memory pointer. It stores the memory address of the
next instruction to be executed. So, we can say that this register is used to sequencing the program.
Generally, the memory has 16 bit addresses so that it has 16-bit memory. The program counter is set to
0000H.
Stack Pointer: -It is also a 16-bit register used as memory pointer. It points to the memory location called
stack. Generally, stack is a reserved portion of memory where information can be stored or taken back
together.
Timing and Control Unit: -It provides timing and control signal to the microprocessor to perform the
various operations. It has three control signals. It controls all external and internal circuits. It operates with
reference to clock signal. It synchronizes all the data transfers.
There are three control signals:
1. ALE-Arithmetic Latch Enable, It provides a control signal to synchronize the components of
microprocessor.
2. RD- This is active low used for reading operation.
3. WR-This is active low used for writing operation.

There are three status signals used in microprocessor S0, S1 and IO/M. It changes its status according to the
provided input to these pins.
Serial Input Output Control-There are two pins in this unit. This unit is used for serial data communication.

Interrupt Unit-There are 6 interrupt pins in this unit. Generally, an external hardware is connected to these
pins. These pins provide interrupt signal sent by external hardware to microprocessor and microprocessor sends
acknowledgement for receiving the interrupt signal. Generally, INTA is used for acknowledgement.

PIEMR/CSE 5|Page
INTRODUCTION TO GNU Simulator 8085

8085 simulator is software on which instructions are executed by writing programs in


assembly language.
GNUSim8085 is a 8085 microprocessor simulator with following features.
• A simple editor component with syntax highlighting.
• A keypad to input assembly language instructions with appropriate arguments.
• Easy view of register contents.
• Easy view of flag contents.
• Hexadecimal <--> Decimal converter.
• View of stack, memory and I/O contents.
• Support for breakpoints for programming debugging.
• Stepwise program execution.
• One click conversion of assembly program to opcode listing.
• Printing support (known not to work well on Windows).
• UI translated in various languages.

Writing a program in assembly language: -


Format of the instruction is as follows: -

Label Operation Operands Comments


Its optional Necessary Necessary Its optional

A basic assembly program consists of 4 parts.

1. Labels
2. Operations :- these operations can be specified as
Machine operations (mnemonics):- used to define operations in the
form of opcode as mention in the instruction set of microprocessor
8085.Pseudo operations (like preprocessor in C):- these are assembly
directives.

3. Operands
4. Comments

In addition, you have constants in an assembly program. Unless otherwise specified, a


constant which is always numeric is in decimal form. If appended with a character h it is
assumed to be in hexadecimal form. If a hex constant starts with an alpha-char don't forget to
include the

PIEMR/CSE 6|Page
number 0 in the beginning, since that will help the assembler to differentiate between a
label and a constant.

Labels:- When given to any particular instruction/data in a program, takes the address of that instruction
or data as its value. But it has different meaning when given to EQU directive. Then it takes the operand of
EQU as its value. Labels must always be placed in the first column and must be followed by an instruction
(no empty line). Labels must be followed by a : (colon), to differentiate it from other tokens.

Operations:-
As mentioned above, the operations can be specified in two ways that are mnemonics and pseudo-
operation. Pseudo operations can be defined by using following directives:-
There are only 3 directives currently available in our assembly language.

1. DB - define byte ( 8 bits )


2. DS - define size (no. of bytes)
3. EQU - like minimalistic #define in C

DB is used to define space for an array of values specified by comma separated list. And the
label (if given to the beginning of DB) is assigned the address of the first data item.
DS is used to define the specified number of bytes to be assigned and initialize them to zero.
To access each byte you can use the + or -operator along with label.
EQU behaves similar to #define in C. But it is simple. It can be used to give names only to
numeric constants. Nesting of EQU is not allowed. You can use EQU only in operands for
pseudo ops and mnemonics.

Operands:-

Operands are specified according to the user. The register set specified in the architecture
of 8085 (A, B, C, D, H and L) are used to access and store data. These registers are specified
as operand. In case of accessing data or storing data in the memory ‘m’ is specified as an
operand and the address of this memory location is taken from the HL pair (data in HL pair).

PIEMR/CSE 7|Page
HOW TO START WITH GNU Simulator 8085

Picture 1

Step1:open GNU Sim 8085 above window will open. Now click on close button highlighted
in the above screen shot.

PIEMR/CSE 8|Page
Picture 2

Step2: start writing the code after start: nop in load me at 10 that is at load me at 11.

PIEMR/CSE 9|Page
Picture 3

Step 3: click on reset and reset all the registers by clicking on reset all.

Picture 4

Step 4: click on the highlighted button to execute the

code
PIEMR/CSE 10 | P a g e
Picture 5

Step 5: after you execute the code mention the name your program by writing the name in the
name section as mentioned in the screen shot in picture 5 and the drive where you want to
save it. After that click on save.

PIEMR/CSE 11 | P a g e
Picture 6

Step 6: after this you will see the result of the instructions in the respective
registers as seen in the above picture 6.

PIEMR/CSE 12 | P a g e
List of Experiments
1. Study of Multiplexer and Demultiplexer
2. Study of Half Adder and Subtractor
3. Study of Full Adder and Subtractor
4. WAP to add two 8 bit numbers and store the result at memory location
2000
5. WAP to multiply two 8 bit numbers stored at memory location 2000
and 2001 and stores the result at memory location 2000 and 2001.
6. WAP to add two 16-bit numbers. Store the result at memory address
starting from 2000.
7. WAP which tests if any bit is '0' in a data byte specified at an address
2000. If it is so,00 would be stored at address 2001 and if not so then
FF should be stored at the same address.
8. Assume that 3 bytes of data are stored at consecutive memory
addresses of the data memory starting at 2000. Write a program which
loads register C with (2000), i.e. with data contained at memory
address2000, D with (2001), E with (2002) and A with (2001).
9. Sixteen bytes of data are specified at consecutive data-memory
locations starting at 2000.Write a program which increments the value
of all sixteen bytes by 01.
10. ALP to add t 10 bytes stored at memory location starting from 3000.
Store the result at memory location 300A

PIEMR/CSE 13 | P a g e
Experiment 1
AIM: Write an assembly language program to add two 8-bit numbers.
PROGRAM 1:
start: nop ; No operation, used as a placeholder

MVI A,32H ; Load the immediate value 32H into register A

MVI B,48H ; Load the immediate value 48H into register B

ADD B ;Add the value in register B to register A

OUT 01H ; Output the result stored in register A to port 01H

hlt ; Halt the execution of the program

Result:
32 H=0011 0010
48H=0100 1000
0011 0010
+0100 1000
--------------
0111 1010=7A H=122 in decimal

Register Value
A (Accumulator) 7A

Flag Value
S 0
Z 0
AC 0
P 0
C 0

PIEMR/CSE 14 | P a g e
Program 2:
START: NOP

LDA VAR1 ; Load the value at address VAR1 into the accumulator

MOV B, A ; Move the value from accumulator to register B

LDA VAR2 ; Load the value at address VAR2 into the accumulator

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

STA VAR3 ; Store the result from the accumulator into address VAR3

HLT ; Halt the program

VAR1: DB 04H ; Define byte 04H for VAR1

VAR2: DB 09H ; Define byte 09H for VAR2

VAR3: DB 00H ; Define byte 00H for VAR3 (result storage)

Result:

Register Value
A (Accumulator) 0D

Flag Value
S 0
Z 0
AC 0
P 0
C 0

PIEMR/CSE 15 | P a g e
Program 3:
LDA 2000h ; Load the value from memory address 2000h into the
accumulator
MOV B,A ; Move the value in the accumulator to register B
LDA 2001h ; Load the value from memory address 2001h into the accumulator
ADD B ; Add the value in register B to the accumulator
MVI C,00h ; Move the immediate value 00h into register C
JNC NOC ; Jump to label NOC if there is no carry
INR C ; Increment the value in register C
NOC: STA 2002h ; Store the value from the accumulator to memory address
2002h
MOV A,C ; Move the value in register C to the accumulator
STA 2003h ; Store the value from the accumulator to memory address 2003h
hlt ; Halt the execution of the program

Result:

Register/memory Value
2000H
2001H
2002H

Flag Value
S
Z
AC
P
C

PIEMR/CSE 16 | P a g e
Experiment 2
AIM: Write an assembly language program to add two 8-bit numbers by considering the
carry bit.

Program 1:
LDA 3000h ; Load the value from memory location 3000h into register A
MOV B, A ; Move the value of register A into register B (store first number)
LDA 3001h ; Load the value from memory location 3001h into register A
ADD B ; Add the value of register B to A (A = A + B)
MVI C,00h ; Move immediate value 00h into register C (initialize carry flag
storage)
JNC NOC ; Jump to label NOC if there is no carry
INR C ; Increment C if carry occurred (store carry information)
NOC: STA 3002h ; Store the sum (A) into memory location 3002h
MOV A,C ; Move the value of C (carry flag status) into register A
STA 3003h ; Store the carry flag status at memory location 3003h
HLT ; Halt the execution
Result:

Register/memory Value
3000H
3001H
3002H

Flag Value
S
Z
AC
P
C
PIEMR/CSE 17 | P a g e
Program2:
start: nop ; No operation, used for synchronization or delay.
LXI H,0100H ; Load immediate data 0100H into HL pair. HL now points
to the memory location 0100H.
MOV A,M ; Move the content of memory pointed by HL into accumulator (A).
INX H ; Increment HL to point to the next memory location (0101H).
MOV B,M ; Move the content of memory pointed by HL into register B.
ADD B; Add the content of register B to accumulator (A), & store result at A.
MVI C,00H ; Move immediate value 00H into register C (used for carry).
JNC NOC ; Jump to label NOC if there is no carry (CY flag is not set).
INR C ; Increment register C to account for carry (if CY flag is set).
NOC: INX H ; Increment HL to point to the memory location (0102H).
MOV M,A ; Store the content of accumulator (result lower byte) into
memory location pointed by HL.
INX H ; Increment HL to point to the next memory location (0103H).
MOV M, C ; Store the content of register C into memory location pointed by
HL.
hlt ; Halt the program execution.
Result:

Register/memory Value
0100H
0101H
0102H

Flag Value
S
Z
PIEMR/CSE 18 | P a g e
AC
P
C

PIEMR/CSE 19 | P a g e
Experiment 3

AIM: write an assembly language program for the subtraction of two 8-bit
numbers.
Program1: Using addition instruction
start: nop ; No operation, used to synchronize or delay execution.
LDA 3000H ; Load the 8-bit number from memory address 3000H into
accumulator (A).
MOV B, A ;Copy the value of accumulator (A) into register B, storing the
first number.
LDA 3001H ; Load the second 8-bit number from memory address 3001H
into accumulator
CMA ; Complement the accumulator (1’s complement of second
number).
INR A ; Increment the accumulator to obtain the 2’s complement of
the second number.
ADD B ; Add the first number (in B) to the 2’s complement of the second
number (now in A).
STA 3002H ; Store the final result (difference) at memory location 3002H.
hlt ; Halt the program, stopping execution.

Result:

Register/memory Value
0100H
0101H
3002H

Flag Value
PIEMR/CSE
S 20 | P a g e
Z
AC
P
C

Program2: Using subtraction instruction


START: NOP ; No operation (Placeholder)
MVI C,00H ; Initialize C to 0 (used for carry count)
LXI H, 0100H ; Load register pair HL with memory address 0100H
MOV A, M ; Load first number from memory into A
INX H ; Increment HL to point to next memory location
MOV B, M ; Load second number from memory into B
SUB B ; Subtract B from A
JNC LAB ; Jump to NOB if no carry (C flag is 0)
INR C ; Increment C (if carry occurred)
LAB: INX H ; Increment HL to point to next memory location
MOV M, A ; Store the result of subtraction in memory
INX H ; Increment HL to point to next memory location
MOV M, C ; Store the carry flag (0 or 1) in memory
CMA ; Complement the content of Accumulator
INR A ; Add 1 into A register to get 2's complement if result
HLT ; Halt execution

PIEMR/CSE 21 | P a g e
Result:

Register/memory Value
0100H
0101H
0102H

Flag Value
S
Z
AC
P
C

PIEMR/CSE 22 | P a g e
Experiment 4
Aim: Write an assembly language program for addition of two 16-bit
numbers.
Program: Addition of 16-bit numbers without considering carry
start: nop ; No operation, used to provide a placeholder or ensure proper
timing.
LHLD 2000H ; Load the contents of memory location 2000H and 2001H
into HL register pair.
XCHG ; Exchange the contents of HL and DE register pairs.
LHLD 2002H ; Load the contents of memory location 2002H and 2003H
into HL register pair.
DAD D ; Add the contents of DE register pair to HL register pair (HL = HL +
DE).
SHLD 2004H ; Store the contents of HL register pair into memory locations
2004H and 2005H.
hlt ; Halt the program execution.
Result:

Register/memory Value
2000H
2001H
2002H
2003H
2004H

Flag Value
S
Z
AC
P
PIEMR/CSE 23 | P a g e
C

Program2: Addition of 16-bit numbers by considering carry bit


start: NOP ; No operation,
MVI C,00H ; Initialize register C with 00H (used for carry tracking).
LHLD 2000H ; Load contents of memory locations 2000H and 2001H into
HL register pair.
XCHG ; Exchange HL and DE register pairs (HL → DE, DE → HL).
LHLD 2002H ; Load contents of memory locations 2002H and 2003H into
HL register pair.
DAD D ; Add contents of DE register pair to HL (HL = HL + DE).
JNC L1 ; Jump to label L1 if there is no carry after addition.
INR C ; If a carry is generated, increment register C (to count carries).
L1: SHLD 2004H ; Store contents of HL register pair into memory locations
2004H and 2005H.
MOV A,C ; Move carry count from register C to accumulator A.
STA 2006H ; Store accumulator value (carry count) into memory location
2006H.
HLT ; Halt program execution.

PIEMR/CSE 24 | P a g e
Result:
Register/memory Value
2000H
2001H
2002H
2003H
2004H
2005H
2006H

Flag Value
S
Z
AC
P
C

PIEMR/CSE 25 | P a g e

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