0% found this document useful (0 votes)
22 views12 pages

8085 Assembly Programs Overview

The document describes designing a traffic light simulation using an Arduino board. It defines the logic to control LEDs to represent traffic lights in four directions following standard traffic light sequences, with periods of red, amber and green lights in each direction. The Arduino code implements this logic by defining pin connections and using loops and delays to control the LED states over time.
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)
22 views12 pages

8085 Assembly Programs Overview

The document describes designing a traffic light simulation using an Arduino board. It defines the logic to control LEDs to represent traffic lights in four directions following standard traffic light sequences, with periods of red, amber and green lights in each direction. The Arduino code implements this logic by defining pin connections and using loops and delays to control the LED states over time.
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

EXPERIMENT 01

Q1. Given N in memory location 2030H. find the value of


Y=1+2+……..N. Store the 8bit Y value in Memory location 2031H.

LOGIC: Load N from memory location 2030H. Move Memory to C, Add


the loop counter (1, 2, 3, ..., N) to the C register. While decreasing C,
add current C value to Accumulator. Break loop when C=1. Store the
value of A to memory location 2031H.

CODE:
ORG 0000H;
LXI H,2030H;
MOV C, M
LOOP ADD C;
DCR C;
JNZ LOOP;
STA 2031H;
HLT;
ORG 2030H;
DB 05H;

RESULT AND CONCLUSIONS:


For N=6, the result is (1+2+3+4+5+6) = 21.
In this experiment, we successfully designed and executed an 8085-
assembly language program to calculate the sum of numbers from 1 to
N and store the result in a specified memory location. The program
utilized the microprocessor's arithmetic and loop control instructions to
perform the computation.
Q2. A set of 10 numbers is stored in memory location starting at 0030H.
write an assembly language program to find the number of odd numbers
in the set and store the number in memory location 0031H.

LOGIC:
1. The program starts at memory location 2000H.
2. It counts the number of odd numbers in a set of 10 numbers stored in
memory locations starting from 0030H.
3. The program initializes counters and registers.
4. It loops through the set, checking each number's oddness using
bitwise operations.
5. If a number is odd, the odd count is increased.
6. After processing all numbers, the odd count is stored in memory
location 0031H.
7. The program halts, completing its task of determining the count of odd
numbers in the set.

CODE:
LXI H, 0030H; #Load HL pair with memory location 0030H
MVI B, 0AH; # Initialize B register with number of elements
MVI C, 00H; #Initialize C to store the count of odd numbers
LOOP: MOV A, M; #Load number from memory into Accumulator
ANI 01H; #Perform bitwise AND with 01H
JNZ ODD; #Jump to ODD if the zero flag is not set
INX H; #Increment HL pair to point to the next number
DCR B; #Decrement the counter B
JNZ LOOP; #Jump to LOOP if B is not zero
JMP DONE; #Jump to DONE to finish the program
ODD: INR C; #Increment the count of odd numbers
INX H; #Increment HL pair to point to the next number
DCR B; #Decrement the counter B
JNZ LOOP; # Jump to LOOP if B is not zero

DONE: MOV M, C; #Store the count of odd numbers in memory


location 0031H
HLT; #Halt the processor

RESULT AND CONCLUSIONS:


If we give input numbers 05H, 10H, 15H, 20H, 45H, 56H, 62H, 85H, 88H
then total odd numbers is 4 that will be stored in 0031H location.
Here in this experiment, we use instructions to write a code to finding
numbers of odd numbers. In this experiment, we successfully designed
and implemented an assembly language program for the 8085
microprocessor to determine the number of odd numbers within a set of
10 numbers stored in memory. The objective of the experiment was to
utilize the 8085 microprocessor's instruction set and programming
capabilities to solve a specific problem
Q3. Addition of 10 numbers, stored in consecutive memory location
starting from 0050H, store the summation result in memory location
0100Hand Carry in 0101H.

LOGIC:
1. Initialize a counter (C) to 10 and a sum (A) to 0.
2. Load the first number from memory (2050H) into the accumulator (A).
3. Add the number in the accumulator (A) to the current sum (L register).
4. Move to the next memory location (increment HL).
5. Repeat steps 2-4 until the counter (C) becomes zero.
6. Store the final sum (L register) in memory (2100H).
7. Store the carry from the addition in memory (2101H) to track any
overflow.
8. Halt the processor.

CODE:
XRA A;
MOV D, A;
MVI C,0AH; # C as a register counter
LXI h,0050H; # Load HL resister pair from memory
location 0050H.
LOOP ADD M; # Add content of M with the contents of A
JNC NEXT; # If no carry them go to INXH
INR D;
NEXT INX H; # Increment H, L pair by 1
DCR C; # Decrement value of register C by 1
JNZ LOOP; #If no zero, then go to LOOP, else continue
STA 0100H; #Store the content in desired location
MOV A, D; # Content of D into Accumulator
STA 0101H; # Store carry into 0101H
HLT; # Stop

RESULT AND CONCLUSION:


Sum = 01H + 02H + 03H + 04H + 05H + 06H + 07H + 08H + 09H + 0AH
= 2DH. It will be stored in 0100H, and as no carry is generated so 00H in
0101H will be stored.
In this experiment, we developed an assembly program for the 8085
microprocessor to calculate the sum of a set of numbers stored in
memory. The program effectively utilized the microprocessor's arithmetic
and control flow instructions to perform the calculations and count carry
occurrences during addition.
EXPERIMENT: 2
Q1. Design a traffic signal simulation using Arduino uno and a PCB
board with LEDs. The goal is to create a sequence of red, amber,
and green lights for each direction (west, north, east and south) in
accordance with traffic light signal rules.
Instructions and Logic:
1. Setup Phase:
a. Define pins for each LED corresponding to directions and colours.
b. For each LED pin:
a. Set the pin as output pin to control LEDs.
2. Main Loop:
a. Begin an infinite loop to simulate the traffic signal sequence.
3. Green Phase (West and South):
a. Turn off all LEDs.
b. Turn on the green LEDs for the west and south directions.
c. Wait for 3 seconds to simulate the green light duration.
4. Red and Green Phases (All Directions):
a. Turn off all LEDs.
b. Turn on the green LEDs for the east and north directions.
c. Turn on the red LEDs for the west and south directions.
d. Wait for 3 seconds to simulate the green light duration.
5. Red and Amber Phases (All Directions Except East and North):
a. Turn off all LEDs to ensure a clean transition.
b. Turn on the amber LEDs for the west and south directions.
c. Wait for 1 second to simulate the amber light duration.
6. Red Phase (All Directions):
a. Turn off all LEDs to ensure a clean transition.
b. Wait for 1 second to simulate the transition time between
phases.
7. Green Phase (North and East):
a. Turn off all LEDs to ensure a clean transition.
b. Turn on the green LEDs for the north and east directions.
c. Turn on the red LEDs for the west and south directions.
d. Wait for 3 seconds to simulate the green light duration.
8. Red and Green Phases (All Directions):
a. Turn off all LEDs to ensure a clean transition.
b. Turn on the green LEDs for the west and south directions.
c. Turn on the red LEDs for the north and east directions.
d. Wait for 3 seconds to simulate the green light duration.
9. Red and Amber Phases (All Directions Except West and South):
a. Turn off all LEDs to ensure a clean transition.
b. Turn on the amber LEDs for the north and east directions.
c. Wait for 1 second to simulate the amber light duration.
10. Repeat:
a. The loop goes back to step 3 to repeat the entire sequence.
11. End Loop

CODE:
int DELAY1=2000;
int DELAY2=1000;

void setup() {
// put your setup code here, to run once:
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(DELAY1);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(DELAY2);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(DELAY1);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(DELAY2);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
delay(DELAY1);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,LOW);
delay(DELAY2);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(DELAY1);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(DELAY2);
}

Result:
The result of running your code will be a traffic signal simulation where
the LEDs on the PCB board shows the behaviour of a traffic signal,
cycling through red, amber, and green lights for each direction.

Conclusion:
This logic provides a simple yet effective way to simulate a traffic signal
using LEDs and an Arduino Uno. It's organized into phases to mimic the
standard traffic signal sequence: green, amber, and red. By controlling
different pins for each LED, you can create a visual representation of a
traffic signal for various directions.

Common questions

Powered by AI

In assembly language, loops are initiated using register pairs and managed through decrementing counter registers (DCR) alongside conditional jump instructions (JNZ). Complex tasks like summations use accumulators to store intermediate results, and loop iterations are guided by decrementing or conditional checks to terminate the loop appropriately .

The objective is to simulate a traffic signal sequence adhering to standard signal rules using LEDs and an Arduino Uno. This is achieved by defining output pins for each LED corresponding to directions and colors, creating an infinite loop to run a sequence that simulates the lighting phases (green, amber, red) for different directions. The program waits for specified durations during each phase to mimic the real-world timing of traffic signals .

The Arduino traffic signal simulation implements sequences and logic by alternating green, amber, and red lights for different directions. Initially, only the west and south directions have green lights for three seconds, followed by east and north directions, each utilizing red and amber transitions accordingly. Phases are carefully timed and LEDs controlled via pin outputs to maintain realistic simulation .

Assembly language programs handle memory assignments post-computation by storing results in predetermined memory locations. After calculating sums, the accumulator content is moved and stored in specific memory addresses using instructions like STA for storage. In counting operations, results are similarly moved to designated memory slots after processing of the input dataset .

Key components include an Arduino Uno, PCB board with LEDs, and correct wiring to map LEDs to specific directions and colors. Setup involves defining output pins for each LED to control their state. The simulation requires defining phase durations in the code to replicate traffic light sequences using controlling functions such as pinMode() and digitalWrite().

Clean transitions between LED phases in the Arduino traffic signal simulation are ensured by turning off all LEDs before initiating a new phase. This step prevents residual signals from the previous state from affecting the current display. It is important for maintaining the clarity of the signal and ensuring safety and accuracy, replicating real traffic signal operations .

The program determines if a number is odd by using a bitwise AND operation with 01H in the accumulator. If the result is non-zero, the number is odd, and the odd count is incremented. This count is stored in memory location 0031H after the set of 10 numbers is processed .

The program handles addition by initializing a counter and sum, loading each number from memory into the accumulator, adding it to the sum stored in the L register, and iterating through all numbers. Address increments are managed by adjusting the HL register pair. For overflow, the program checks for carry using the JNC instruction, storing any carry in a separate memory location (0101H) to handle potential overflows .

Controlling and storing the carry during summation is essential for managing overflow during arithmetic operations. The carry indicates an extra bit resulting from an addition that exceeds the 8-bit capacity of the accumulator. By checking and storing the carry, the program ensures that calculations accurately reflect the total sum, even when exceeding standard register size .

The program calculates the sum of numbers from 1 to N by utilizing the 8085 microprocessor's arithmetic and loop control instructions. The logic begins by loading the value of N from the memory location 2030H into register C. A loop is then initiated where the loop counter (1, 2, 3, ..., N) is added to register C. The value of C is decreased by 1 during each iteration of the loop, and the current value of C is added to the Accumulator. The loop continues until C equals 1, at which point the accumulated sum is stored in memory location 2031H .

You might also like