[ create a new paste ] login | about

Link: http://codepad.org/KhypYtBA    [ raw code | output | fork ]

mohit_at_codepad - C++, pasted on Mar 16:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

// Verifying the problem
// CWD
// XOR AX,DX
// SUB AX,DX

int main() {
  for(int i = -15; i <= 15; ++i) {
    // CWD
    const int DX = i < 0 ? 0xFFFFFFFF : 0;
    // XOR AX,DX
    int AX = i ^ DX;
    // SUB AX,DX
    AX -= DX;
    cout << i << ':' << AX << endl;
  }
}


Output:
-15:15
-14:14
-13:13
-12:12
-11:11
-10:10
-9:9
-8:8
-7:7
-6:6
-5:5
-4:4
-3:3
-2:2
-1:1
0:0
1:1
2:2
3:3
4:4
5:5
6:6
7:7
8:8
9:9
10:10
11:11
12:12
13:13
14:14
15:15


Create a new paste based on this one


Comments: