Comp Sci Calculate the two's complement of a given 16 bit number

  • Thread starter Thread starter blue44
  • Start date Start date
  • Tags Tags
    Bit
AI Thread Summary
The discussion revolves around calculating the two's complement of a 16-bit number and the confusion surrounding the input format, specifically whether it is binary or hexadecimal. Participants clarify that the input "0000 0001" is ambiguous, as it could represent either an 8-bit binary number or a hexadecimal value. The conversation also touches on modifying programs to handle 32-bit numbers and computing averages of 8-bit numbers stored in memory. There is a request for examples and clearer instructions on using the specified program for these operations. Overall, the thread highlights the need for better guidance in understanding and implementing two's complement calculations.
blue44
Messages
1
Reaction score
0
Member warned that some effort must be shown
Homework Statement
Machine Language
Relevant Equations
Simpsim
I'm working on an assignment for a computer science course. The professor did not give very good instruction, and I can't find very much information about the subject online. We are supposed to use this http://www.anne-gert.nl/projects/simpsim/ program to perform various operations including adding, subtracting, multiplying, and dividing values. If I just had something to read or an example of how to use the program, it would be very helpful.
My Attempts:
1- Write an assembly program that calculates two’s complement of a given 16 bit number in 0000 0001
2- Modify your program so that it works for a 32bit number given in 0000 0001 0002 0003
3- Write an assembler program that computes the average of sixteen 8 bit numbers stored in memory and writes the result into 0000.

Thanks.
 
Physics news on Phys.org
First, tell us what your understanding is of 2's complement and show an example of adding two 2's complement numbers so we can be sure you've gotten at least that far on your own
 
blue44 said:
1- Write an assembly program that calculates two’s complement of a given 16 bit number in 0000 0001
What does 0000 0001 mean? Is it a binary number? If so, that's only 8 bits. Is it in hexadecimal? If so, that's 32 bits.
blue44 said:
2- Modify your program so that it works for a 32bit number given in 0000 0001 0002 0003
The number you show can't be binary, but if it's hexadecimal, it's 64 bits, not 32.
blue44 said:
3- Write an assembler program that computes the average of sixteen 8 bit numbers stored in memory and writes the result into 0000.
An 8-bit number would be ##b_7b_6b_5b_4 b_3b_2b_1b_0##, where each ##b_i## would be either 0 or 1. If 0000 represents a number in hex, that would be 16 bits; i.e., four bits for each hex digit.
 

Similar threads

Back
Top