Question

Four 8-bit 2's complement (signed) integers A, B, C, and D are packed into the 32-bit...

Four 8-bit 2's complement (signed) integers A, B, C, and D are packed into the 32-bit word stored in the memory of an ARM processor at address 0x36F0:

Extract the 8-bit integer A into the 32-bit register Ra, the 8-bit register B into the 32-bit register Rb,the 8-bit register C into the 32-bit register Rc, and the 8-bit register D into the 32-bit register Rd.

Hint: in ARM an address refers to a byte, not a word

0 0
Add a comment Improve this question Transcribed image text
Answer #1


unsigned long ptr=0x36F0;
long TwosCompVal=0,temp;
char TempA,TempB,TempC,TempD;
/*
Pack the Two's complement
*/

temp = A; TwoCompVal = temp << 24;
temp = B; TwoCompVal = TwoCompVal + (temp << 16);
temp = C; TwoCompVal = TwoCompVal + (temp << 8);
temp = D; TwoCompVal = TwoCompVal + temp;

//Now TwoCompVal = ABCD

/*
Unpack the TwoCompVal
*/

TwoCompVal = *ptr; //Retrieve Data from memory location 0x36F0
Temp = (TwoCompVal && 0x000000FF); TempD = temp;
Temp = (TwoCompVal && 0x0000FF00)>>8; TempC = temp;
Temp = (TwoCompVal && 0x00FF0000)>>16; TempB = temp;
Temp = (TwoCompVal && 0xFF000000)>>23; TempA = temp;

Add a comment
Know the answer?
Add Answer to:
Four 8-bit 2's complement (signed) integers A, B, C, and D are packed into the 32-bit...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT