1. Write a sequence of instructions that would implement the following IF-THEN-E
ID: 3699898 • Letter: 1
Question
1. Write a sequence of instructions that would implement the following IF-THEN-ELSE structure. IF (9000H) is even THEN (9001H) 22H ELSE (9001H) 99H 2. You are given an array of 50 signed integers tored in 9000H write a program number of integers that are positive and save the count in 8900H. that would count the 3. You are given an array of signed integers stored in 21H. The end of the array is followed by a dummy end of data, oFFH. Write a program that would compute the checksum of only elements that are positive and odd and save the sum in 20H.Explanation / Answer
1-
if((9000H)%2)
(9001H) =22H
else (9001H) =99H
2-
int ar[50];
int varr = *(volatile uint8_t*)9000H;
ar[0]=varr;
int count =0;
for(int i=0;i<50;i++)
{
if(ar[i]>0)
count++;
}
void func (void)
{
*(volatile uint8_t*)8900H = count; // write
int var = *(volatile uint8_t*)8900H; // read
}
3-
int ar[50];
int varr = *(volatile uint8_t*)21H;
ar[0]=varr;
int checksum =0;
for(int i=0;;i++)
{
if(ar[i]>0 and (arr[i]%2==1))
checksum++;
if(ar[i]==*(volatile uint8_t*)0FFH;
}
void func (void)
{
*(volatile uint8_t*)8900H = checksum; // write
int var = *(volatile uint8_t*)20H; // read
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.