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

  • Comp Sci
  • Thread starter blue44
  • Start date
  • #1
1
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.
 

Answers and Replies

  • #2
phinds
Science Advisor
Insights Author
Gold Member
16,937
7,903
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
 
  • #3
35,057
6,793
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.
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.
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.
 

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

Replies
1
Views
6K
  • Last Post
Replies
8
Views
1K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
1
Views
1K
Replies
0
Views
4K
Replies
1
Views
839
  • Last Post
Replies
1
Views
1K
Replies
2
Views
1K
Replies
2
Views
11K
Replies
2
Views
960
Top