Coa Lab 2025 CS404 Exp 1 4
Coa Lab 2025 CS404 Exp 1 4
2. List of experiments
3. Codes
PIEMR/CSE 1|Page
ASSEMBLY LANGUAGE PROGRAMMING
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
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.
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:
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.
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
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
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.
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
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
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
LDA VAR2 ; Load the value at address VAR2 into the accumulator
STA VAR3 ; Store the result from the accumulator into address VAR3
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
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
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