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

  • Context: Comp Sci 
  • Thread starter Thread starter blue44
  • Start date Start date
  • Tags Tags
    Bit
Click For Summary
SUMMARY

The discussion focuses on calculating the two's complement of a given 16-bit number using the SimpSim program. Participants clarify the representation of numbers in binary and hexadecimal formats, emphasizing the need for precise understanding of bit lengths. The conversation also highlights the importance of writing assembly programs for operations such as addition and averaging of numbers. Key examples include modifying programs to handle both 16-bit and 32-bit numbers.

PREREQUISITES
  • Understanding of two's complement representation
  • Familiarity with assembly programming
  • Knowledge of binary and hexadecimal number systems
  • Experience with the SimpSim program for numerical operations
NEXT STEPS
  • Research how to implement two's complement in assembly language
  • Learn about the SimpSim program's functionalities and operations
  • Explore the differences between binary, hexadecimal, and decimal representations
  • Study algorithms for averaging multiple numbers in assembly programming
USEFUL FOR

Computer science students, assembly language programmers, and anyone interested in numerical operations and binary arithmetic.

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

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
13K
Replies
7
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
1
Views
7K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 30 ·
2
Replies
30
Views
7K