ABCDEFGHIJKLMNOPQRSTU
1
Subtract 2 words (16 bits)josvandenenden@gmail.com
2
3
bit1514131211109876543210
4
bit value327681638481924096204810245122561286432168421
5
6
Input
7
8
word1 input1111111111111111
9
decimal value32768163848192409620481024512256128643216842165535
10
11
word2 input0000000000000001
12
decimal value00000000000000011
13
14
15
Input aid
16
17
bytes1 dec
255255
18
bytes1 bin
1111 11111111 111165535
19
copy error
0
20
bytes2 dec
01
21
bytes2 bin
0000 00000000 00011
22
copy error
0
23
24
25
Calculate two's complement word2
26
27
word2 one's com.
1111111111111110
28
29
carry00000000000000000
30
word2 one's com. copy
1111111111111110
31
one0000000000000001
32
-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
33
decimal sum01111111111111111
34
word2 two's com.
1111111111111111
35
36
37
Output = word1 + two's complement word2
38
39
carry11111111111111110
40
word1 copy1111111111111111
41
word2 two's com. copy
1111111111111111
42
-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
43
decimal sum13333333333333332
44
word1-word21111111111111110
45
32768163848192409620481024512256128643216842065534
46
47
48
Decimal check
49
decimal subtraction
65534
50
subtraction error
0
51