Question: MASM Assembly Language x86 Processor - Twos_Complement_Shortcut (Chapter 7, Supplied) Hello Chegg experts, this is one of my programming assignments for MASM assembly language x86
MASM Assembly Language x86 Processor -
Twos_Complement_Shortcut (Chapter 7, Supplied)
Hello Chegg experts, this is one of my programming assignments for MASM assembly language x86 Processor.
I desperately need your help on this!! Also use Irvine32 library.
Here is the assignment:

Twos_Complement_Shortcut (Chapter 7, Supplied)
As seen from here: Working from LSB towards MSB, you can see a shortcut to manually convert a binary number into its two's complement. The shortcut allows to convert a number to its two's complement without forming its ones' complement and plus one. The algorithm can be described like this:
Start at the least significant bit (LSB), and copy all the zeros until the first 1 is reached
Copy that 1
Flip all the remaining bits to the beginning
For example: the two's complement of "0011 1100" is "1100 0100". Write a procedure:
TwosCompShortCut PROC ; Receives: EAX as a signed integer. ; Returns: EAX the 2's complement of EAX. |
Where you can create two conditional loops for step1 and step3. Don't think too complicated. Totally twelve instructions or so should be enough in the PROC body. When call TwosCompShortCut in main to let the user enter a 32-bit integer, your output should be look like:
Enter a 32-bit signed integer in decimal: 1 Your integer input in hexadecimal is 00000001 The 2's complement in hexadecimal is FFFFFFFF The 2's complement in decimal is -1 Press any key to continue . . . |
or
Enter a signed integer in decimal: 0 Your integer input in hexadecimal is 00000000 The 2's complement in hexadecimal is 00000000 The 2's complement in decimal is +0 Press any key to continue . . .
Thank you in advance.. |
Twos_Complement Shortcut (Chapter 7, Supplied) As seen from here: Worsing from LSB towards MSE, you can see a shortcut to manually convet a binary number into its two's complement. The shortcut allows to convert a number to its two's complement without forming its ones' complement and plus one. The algorithm can be descnbed Ike ths Start at the least signific ant hit (lSD), and copy al tha zeros until the first 1 is neachad Copy that 1 Flip all the remairing bits to the beginning For example the two's complement of 0011 1100" is 1100 0100" Wite a procedure ShortCot Recivea: RAX a8 a 8igned intiger Ratarn EAX the 2's oomplement of EX Where you can create two conditional loops for step1 and step3. Don't think too complicared. Totally twelve instructions or so should be enough in the PROC body. When call TwosCompShortCut in main to let the user enter a 32-bit integer, your output should be look like: Enter a 32-bit signed integer in decimal:1 The 2's conplenent in beradecimal 1s FFFFFFFr The ' complcnent: in decinal1 Press any key to aontioue or Enter81gtied integ6r in delnal ; 0 Your integer inpat in beadecinal 1s 0000dd00 The 2' onplenent in deaimal i+0 Press any key to continue top
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
