Question: Computer Science: Assembly Language for x86 Processors C++ Twos Complement with Hexadecimal To implement TwosComplement(), only functions allowed to use are strlen(), strcpy(), and toupper()

Computer Science: Assembly Language for x86 Processors

C++

Twos Complement with Hexadecimal

Computer Science: Assembly Language for x86 Processors C++ Twos Complement with Hexadecimal

To implement TwosComplement(), only functions allowed to use are strlen(), strcpy(), and toupper() if needed. Please don't use printf() or scanf(). An implementation of TwosComplement() is suggested here:

1. Receive a 4-char C-string with 4 Hex digits

2. Loop through each char from right to left

- Get a Hex char digit

- Make it upper case if necessary

- Convert char digit to a number value

- Reverse every bit in Hex digit

- Plus one to the lowest digit (may cause a carry to propagate)

- Convert each number value back to char digit

3. A single loop should be enough without nested one

And please show me sample output.

Twos_Complement_with_Hexadecimal (Chapter 1) Write a C+program converting a 4-digit Hexadecimal integer to its Two's Complement. You can create functions declared like this : // Function: TwosComplement / Description: This function converts a Hexadecimal to its Two's Complement / Parameter: S [IN]- a C-string with a 4-digit Hexadecimal received / Return: void TwosComplement (char* s, char s2) s2 [out] - a C-string with a 4-digit of s two's complement None Then you can call it repeatedly in main() to verify that the 2's Complement is reversible with TwosComplement exe Please Enter 4-digit Hexadecimal integer (e.g., A1B2): A0Bc Two's Complement of Hex A0Bc is 5F44 Try again? (y) y Please Enter 4-digit Hexadecimal integer (e.g., A1B2) 5f44 Two's Complement of Hex 5f44 is A0BC Try again? (y) y Please Enter 4-digit Hexadecimal integer (e.g., A1B2) AoBC Two's Complement of Hex AoBC is Error Try again? (y) y Please Enter 4-digit Hexadecimal integer (e.g., A1B2) 0000 Two s Complement of Hex 0000 is 0000 Try again? (y) y Please Enter 4-digit Hexadecimal integer (e.g., A1B2): 0001 Two 's Complement of Hex 0001 is FFFF Try again? (y) n Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!