bg287

csc205 Notes

Posted in csc205 by bnmng on 2011 01/18

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 2n-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)
-2n-1 to 2n-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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: