## csc205 Notes

Reading Assignment.

Read 10.1 (skip bool algebra), 10.2,

two to the nth power minus 1 (unsigned storage with n bits).

The carry bit could indicate that the result is too big, or could indicate a borrow.

Given N bits, the two’s compliment of a number x _{ 2 } is 2^{n}-x (the technique is to add one to the not). This is not the way it works in a high level language — we’re talking about the way the computer stores data.

Range of signed integers (with N bits)

-2^{n-1} to 2^{n-1} – 1

1 1 1 1

0 0 0 1

——–

0 0 0 0 with a carry flag of 1 and overflow of 0.

In signed numbers, overflow is a sign change.

0 1 0 1

0 0 1 0

——–

0 1 1 1

0 1 0 1

0 1 0 0

——–

1 0 0 1

cf =0

vf = 1

1 0 1 1

1 1 1 0

——–

1 0 0 1 cf = 1 vf = 0

1 0 1 1 0 1 1 1 (-73)

1 0 0 1 1 0 1 1 (-101)

————————–

1 0 1 0 0 0 1 0

cf 1

vf 1

nf 0

zf 0

The computer does the same thing whether we’re doing signed or unsigned. If we’re doing unsigned, the same flags will be set, but we don’t care about the overflow flag or the negative flag. We would care about the carry flag. If signed, then we care about those flags.

leave a comment