Labs a PreLabs and Labs
Labs a PreLabs and Labs
1
LAB - 1
Addition and Subtraction of Two 8-bit Numbers
2
Pre LAB - 2
Activity 1: Study Data Transfer and Arithmetic Instructions
3
LAB - 2
Simulation – 1 Loading of of Two 8-bit Numbers Data Transfer and Arithmetic
Instructions
LOOP:
MOV A, M ; Load data from source into Accumulator
STAX D ; Store data at destination
INX H ; Increment source address
INX D ; Increment destination address
DCR C ; Decrement counter
JNZ LOOP ; Repeat until C = 0
Explanation:
1. Initialize Pointers:
o H stores source address (2000H).
o D stores destination address (3000H).
o C is the counter (N = 10 bytes).
2. Loop Execution:
o Read data from source (MOV A, M).
o Write data to destination (STAX D).
o Increment source and destination addresses (INX H, INX D).
o Decrease counter (DCR C).
o If counter ≠ 0, repeat (JNZ LOOP).
3. Halt Execution (HLT) when all data is transferred.
4
Pre LAB - 3
Activity: Study Logical Operations: AND, OR, XOR of two numbers
5
LAB - 3
Logical Operations:
6
PreLab 4
Activity: Study Branching and Looping Instructions
Labs 4
7
Prelab 5
1. Short Definitions
What is the difference between binary, BCD, and ASCII?
How is a BCD number different from a binary number?
What does the DAA instruction do in 8085?
8
Lab 5
Experiment 1: Binary to BCD Conversion
Objective: Convert an 8-bit binary number to its equivalent BCD.
Algorithm:
Divide the binary number by 100 to get hundreds.
Divide the remainder by 10 to get tens.
Store hundreds, tens, and units in memory.
Sample Code:
STEP2:
LOOP2: CPI 0AH ; Compare with 10
JC STORE
SUI 0AH
INR D
JMP LOOP2
STORE:
STA 3002H ; Units
MOV A, D
STA 3001H ; Tens
MOV A, C
STA 3000H ; Hundreds
HLT
9
Experiment 2: ASCII to BCD Conversion
Objective: Convert an ASCII digit (e.g., '3' = 33H) to its BCD numeric value.
Logic:
ASCII of '0' is 30H, '1' is 31H … '9' is 39H
Subtract 30H from ASCII to get the number
Sample Code:
Concept:
Divide hex number by 10 repeatedly and Store quotient and remainder as decimal digits
Sample Pseudocode:
MVI A, 2FH ; Load hex number (47)
MOV B, A
MVI C, 00H ; Tens
MVI D, 00H ; Units
LOOP:
CPI 0AH
JC STORE
SUI 0AH
INR C
JMP LOOP
STORE:
MOV D, A ; Units = remainder
MOV A, C
STA 3200H ; Tens
MOV A, D
STA 3201H ; Units
HLT
10
Pre Lab 6
• Interrupt
• Maskable vs Non-Maskable Interrupts
• Vector and Non-Vector Interrupts
• Interrupt Service Routine (ISR)
RST 7.5
TRAP
INTR
11
Lab 6
Sample Code:
; Main program
ORG 8000H
MVI A, 11H
CALL 0024H ; Simulating TRAP interrupt manually
HLT
Sample Code:
ORG 8000H
EI ; Enable interrupts
RST 5 ; Simulate interrupt (jumps to 0028H)
HLT
12
Notes for GNU 8085 Use:
• Use manual CALL to ISR locations to simulate hardware interrupts.
• You can emulate vector execution by putting the code at those addresses (0024H,
0028H, etc.).
• Since external triggers aren’t simulated, you just call the ISR manually.
13