0% found this document useful (0 votes)
11 views3 pages

19CCE211 - P2 Answers

Uploaded by

shreeshivaani28
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)
11 views3 pages

19CCE211 - P2 Answers

Uploaded by

shreeshivaani28
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/ 3

1.

Consider the following registers R0, R1, R2, R3, and R4 are holding the values 0x10, 0x08,
0x04, 0x02, and 0x01 respectively. Find what would be the register values after executing
each instruction.
(i) ADD R6, R3, R2, LSR #2
R6 – 0x00000003
(ii) MLS R7, R2, R3, R0
R7 – 0x00000008
(iii) SUB R8, R0, R2, LSL #2
R8 – 0x00000000
(iv) BIC R9, R1, #0x08
R9 – 0x00000000
(v) REV16 R10, R0
R10 – 0x00001000

2. Write an assembly language program to calculate the Amusement Park Ticket Fare based
on the age of the person and height of the person if the age is 10 and below. Consider the
following conditions:
(I) If the age is 10 and below and
(i) If height is 140 cm and below the fare is Rs. 500
(ii) If height is greater than 140 cm the fare is Rs. 600
(II) If the age is between 10 and 50 the fare is Rs. 750
(III) If the age is 50 and above the fare is Rs. 650

AREA EX12, CODE, READONLY


EXPORT __MAIN
__MAIN
LDR R0, = 59 ; age
LDR R1, = 141 ; height
MOV R2, #10
MOV R3, #50
MOV R4, #140
CMP R0, R2
BGT J1
CMP R1, R4
BGT J4
MOV R11, #500
B J2
J4 MOV R11, #600
B J2
J1 CMP R0, R3
BGE J3
MOV R11, #750
B J2
J3 MOV R11, #650
J2 B J2
END

Page 1 of 3
3. Write a program to receive a character from UART1 receiver and transmit it back through
UART2 of MSP432 microcontroller.

#include "msp.h"
void UART1_init(void)
{
EUSCI_A1->CTLW0 |= 1;
EUSCI_A1->MCTLW = 0;
EUSCI_A1->CTLW0 = 0x0081;
/* 1 stop bit, no parity, SMCLK, 8-bit data */
EUSCI_A1->BRW = 26;
P2->SEL0 |= 0x0C; /* P2.3, P2.2 for UART */
P2->SEL1 &= ~0x0C;
EUSCI_A1->CTLW0 &= ~1;
}
void UART2_init(void)
{
EUSCI_A2->CTLW0 |= 1;
EUSCI_A2->MCTLW = 0;
EUSCI_A2->CTLW0 = 0x0081;
/* 1 stop bit, no parity, SMCLK, 8-bit data */
EUSCI_A2->BRW = 26;
P3->SEL0 |= 0x0C; /* P3.3, P3.2 for UART */
P3->SEL1 &= ~0x0C;
EUSCI_A2->CTLW0 &= ~1;
}

int main(void)
{
char c;
UART1_init();
UART2_init();
while (1)
{
while(!(EUSCI_A1->IFG&0x01));
c = EUSCI_A1->RXBUF;
while(!(EUSCI_A2->IFG&0x02));
EUSCI_A2->TXBUF = c;
}
}

4. Represent the value 135.2510 in both 32-bit and 64-bit floating point IEEE 754 standard.

135 = 10000111
0.25 = 01
135.25 = 10000111.01
=1.000011101 x 2^7

Page 2 of 3
Single precision (32 bit):
Exponent = 127+7 = 134 = 10000110
Mantissa = 000011101

The IEEE 754 Single precision is:


= 0 10000110 00001110100000000000000
In hexadecimal form 43074000

2. Double precision:
Exponent = 1023+7 = 1030 = 10000000110
Mantissa = 000011101

The IEEE 754 Double precision is:


= 0 10000000110 0000111010000000000000000000000000000000000000000000
In hexadecimal form 4060E80000000000

5. Consider a room with attractive led lightings (3 red led lights and 3 blue led lights). Write
a program to generate 5 second time delay by using Timer32 of MSP432 microcontroller
to toggle between the different color LEDs. Consider 3 red LEDs are connected with P2.0
to P2.2 and 3 blue LEDs are connected with P2.3 to P2.5. Also, consider the master clock
is running at 3 MHz and Timer32 is configured in wrapping mode.

#include "msp.h"

int main(void)
{
P2->SEL1 &= ~0x3F;
P2->SEL0 &= ~0x3F;
P2->DIR |= 0x3F;

TIMER32_1->LOAD = 14999999; /* set the reload value */

/* no prescaler, wrapping mode, disable interrupt, 32-bit timer. */


TIMER32_1->CONTROL = 0xC2;

while (1) {
while((TIMER32_1->RIS & 1) == 0); /* wait until the RAW_IFG is set */
TIMER32_1->INTCLR = 0;
P2->OUT = 0x07; /* toggle LED */
while((TIMER32_1->RIS & 1) == 0); /* wait until the RAW_IFG is set */
TIMER32_1->INTCLR = 0;
P2->OUT = 0x38; /* toggle LED */
}
}

*****

Page 3 of 3

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