0% found this document useful (0 votes)
8 views5 pages

Mpassign2 Khayam

The document contains an assembly code for a microprocessor system that initializes a stack pointer, configures PORTB pins as outputs, and uses a lookup table to control LEDs based on an input value. It defines constants and subroutines for turning on specific LEDs corresponding to binary input values. The program ends with an infinite loop after executing the LED control logic.

Uploaded by

Usama Atiqq
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)
8 views5 pages

Mpassign2 Khayam

The document contains an assembly code for a microprocessor system that initializes a stack pointer, configures PORTB pins as outputs, and uses a lookup table to control LEDs based on an input value. It defines constants and subroutines for turning on specific LEDs corresponding to binary input values. The program ends with an infinite loop after executing the LED control logic.

Uploaded by

Usama Atiqq
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/ 5

Microprocessor Systems & Interfacing

ASSIGNMENT : 02

Name ALEEZA AHMAD

Registration Number FA19-BEE-045

Class BEE-5B

Instructor's Name Sir Khiyam Iktikhar


Question : 01

Code
; Define constants

.EQU INPUT_VALUE = 0b01

; Main program

RESET:

; Initialize Stack Pointer

ldi r16, HIGH(RAMEND)

out SPH, r16

ldi r16, LOW(RAMEND)

out SPL, r16

; Set all pins of PORTB as outputs


ldi r16, 0xFF ; Load 0xFF (all bits set to 1) into r16

out DDRB, r16 ; Configure all pins of PORTB as outputs

; Load input value into the register

ldi r16, INPUT_VALUE

; Create a lookup table for LED control based on input

ldi r17, 0b00001000 ; Lookup table for 0b00 (PB3 is set)

ldi r18, 0b00000100 ; Lookup table for 0b01 (PB2 is set)

ldi r19, 0b00000010 ; Lookup table for 0b10 (PB1 is set)

ldi r20, 0b00000001 ; Lookup table for 0b11 (PB0 is set)

; Check the input value and use the lookup table to control the LEDs

cpi r16, 0b00

breq INPUT_00

cpi r16, 0b01

breq INPUT_01
cpi r16, 0b10

breq INPUT_10

cpi r16, 0b11

breq INPUT_11

; Default case (if input_register is none of the above)

DEFAULT:

rjmp DEFAULT

; Subroutines for turning on LEDs based on input

INPUT_00:

out PORTB, r17 ; Turn on LED D3 (PB3)

rjmp END

INPUT_01:

out PORTB, r18 ; Turn on LED D2 (PB2)

rjmp END

INPUT_10:

out PORTB, r19 ; Turn on LED D1 (PB1)


rjmp END

INPUT_11:

out PORTB, r20 ; Turn on LED D0 (PB0)

rjmp END

; End of program

END:

; Infinite loop (optional)

rjmp END

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