Question: MASM Assembly Language x86 Processor - Random_Screen_Location (Chapter 5, Pr 7) Hello Chegg experts, this is one of my programming assignments for MASM assembly language

MASM Assembly Language x86 Processor -

Random_Screen_Location (Chapter 5, Pr 7)

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. Totally a little more than 10 instructions should be enough in the TwosCompShortcut body. When calling TwosCompShortcut in main to let the user enter a 32-bit decimal integer either positive or negative, your output should be like:

C:\Teaching\CSCI241\KipIrvine\Prog_Ex_SM\ch07\Debug>project 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 . . . C:\Teaching\CSCI241\KipIrvine\Prog_Ex_SM\ch07\Debug>project Enter a 32-bit 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 . . . C:\Teaching\CSCI241\KipIrvine\Prog_Ex_SM\ch07\Debug>project Enter a 32-bit signed integer in decimal: -1 Your integer input in hexadecimal is FFFFFFFF The 2's complement in hexadecimal is 00000001 The 2's complement in decimal is +1 Press any key to continue... 

Thank you in advance..

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!