Docsity

BME303 Spring 2008 Lab 3 - Binary Addition and Complement Operations - Prof. Orly Alter, Lab Reports of Biology

Toggle sidebar
bg1
BME303
Spring 2008 Lab
3
Last Name:
AqorVr€ First Name:
P.Jf rc\\1cl.
Instructlons:
l. Use the tlrst page
ot this document
as the cover
page.
2. Each homework must
be stapled
[50
points
are deduct€d
otherwise].
3. The first
page
ot the homework must
have a completed
heading as above
(it
can be hand written).
4. Show
your
work,
except in the most
obvious cases where
the calculations
can be done mentally.
5. Your work must
b€
neat
and clear.
Probleml[4+2=61
a) You
havs a 4 bit computer, i.e.
a computer that
can only do 4 bit binary
arithm€tic
and everything beyond the 4rh
bit cannot be r€presented.
Complet€ the Iollowing
addition tabls wh€re
you
add the binary number in
the irh column with
lhe jrh
row. The numbers
are reprssont€d using 2's
complement tormat. An
example is
given
to
gel you
started.
0011 1110, 0110 1010
0001 o I r)A rl 0111 lal
0011 nll^ a00l 6oot) I
0111 <Ia-ii-r /ll Orr'l) at6 |
111'16', Al hn lol DI IOOI
.oooo,
b) ls ther6"ah
overflow in
some additions
(circl€
if
any)
Prcblem 212+2+2+2
= 8l
In the following table,
the 1'r column rapresents
a bit
pattern
on an 8 bit computer
(i.o.
anything
boyond I bits is not r6pr€s€nted).
Column A: Write th6 1's
complement of th€ initial bit
pattern.
Column B: Write
the 2's complement
of
the initial bit
pattern.
Column
C:
Write
th6 2's compl€m€nt
of
the number in
ggUIn[E!.
Column D; Writo tho addilion
ot
the numbers in
mlumns B and C.
lnitial Pattern cD
11111111 c]coa) o<r:x) AOOO (f,)a\ ll
001 1
001
tloo llol
1010
1010 .i rat I OtOl ntn t nt lr) I rrln l6lO ^Ok
a no^^
0000 0000 ,'{r..) ffi oa
pf3
pf4
pf5

Partial preview of the text

Download BME303 Spring 2008 Lab 3 - Binary Addition and Complement Operations - Prof. Orly Alter and more Lab Reports Biology in PDF only on Docsity!

BME303Spring Lab

LastName:

AqorVr€

FirstName:P.Jf rc\1cl.

Instructlons:

l. Usethe tlrst pageot this documentas the coverpage.

  1. Eachhomeworkmustbe stapled

[

points

arededuct€dotherwise].

  1. Thefirstpageot the homeworkmusthavea completed headingas above

(it canbe handwritten).

  1. Showyourwork,except in the mostobviouscaseswherethe calculations

canbe donementally.

  1. Yourworkmustb€ neatandclear.

Probleml[4+2=

a) You havsa 4 bit computer,i.e. a computerthat can onlydo 4 bit binary

arithm€tic and everythingbeyondthe 4rhbit cannotbe r€presented.

Complet€theIollowingadditiontablswh€re

you

addthe binarynumberin

the irhcolumnwith lhe jrhrow. The numbers are reprssont€dusing2's

complementtormat.An exampleis

given to gel

youstarted.

o I r)A rl 0111

lal

0011 nll^ a00l 6oot) I

0111 <Ia-ii-r /ll Orr'l) at6 |

111'16', Al hn lol DI

IOOI

.oooo,

b) ls ther6"ahoverflowin someadditions

(circl€ if any)

Prcblem 212+2+2+

= 8l

In the followingtable,the 1'rcolumnrapresents a bit

pattern on an 8 bit computer

(i.o.anything boyondI bitsis notr6pr€s€nted).

ColumnA: Writeth6 1'scomplementof th€ initialbit

pattern.

ColumnB: Writethe 2's complementof the initialbit

pattern.

ColumnC: Writeth6 2's compl€m€nt of

the numberin

ggUIn[E!.

ColumnD; Writotho addilionot thenumbersin mlumnsB andC.

lnitialPattern c D

11111111 c]coa) o<r:x) AOOO (f,)a\

ll

0011 001t loo llol

10101010

.i rat I OtOl ntn t nt lr) I rrln l6lO

^Oka no^^

,'{r..) ffi oa

1

BME303Spring

Problem

3 [

+r

Lab3'

I C)

C)

(:) o

o

() o

()

c)

Binarv

=

!ti-'-

Decimal

Add

the lollowingtwo'scomDlement

numbersand express

the answersin

borhbinaryand

decir"i,(J.F

?1,*"Jjt"vided

foryour

convenience)

Problem4 [4]

Calculat€the resultsof the tollowing

arithmeticoperations

on 16-bit2's

complementnumbors.

The numbersare

encodedin hexadocimal,

as indicated

by the prefix "0x".You

maydo the

calculations

in binary,decimalor hex,but

convert

youranswer to hoxadecimal

Statewhelher

overflowhasoccurred

(circle

one),

A B

'Arl''!'l

OxO

  • Ox'

Answer:

ild

l{

'-r\

la:\

t ,Jrl

{, ,l

10000001 ar L I lo

tL:a ao0 a

'

1111 a lo 1

-OCr{,

o{crl ooo i

"r:DO

C0 Oa

01100001

":t

I A

(fr('l

\a\14 o-aa

10001000

.l t11.)l

'}ri

i i croo I (j.a I aa

-.2D dC-)C

Circleone:

lhgtrOt

overflow

,--'-=7:-'>

.-'no

Ovemow ,j''

(

_-,

''

Problem 5 [3+3+3+

= 18]

a. Whaa

is the minimal

numberot bits

neededto represent

the foliowing

2's

complement

numberswrittenin hexadecimal

format

("0x" is the prefixthat

indicates

the hexadecimal

format):

\OO J/

,J., d,.,r s

o,nglerrLaT

/ zr'rrYt fI

I i

i

!ntive.

cdd

l l"atu

BME303Spring 2008

ProblemS[4+4+4+4=15]

c) 2048

dJ -114.

Lab 3

indthe equivalentIEFE754floating

pointrepresentationfor thedecimal

numbersbelow.

?

'r'

lltoto

a) -0.12 ,.

t-llt/Otc,tOLo''tu,t

..,-l

h)653--.V---/ b) 65.

gaain.

lem 9 [2+2+2+2+2=10]

Computethelollowing

logicoperations.Writeyourresults

in binary.

(Youcan

usethelablesto facilitate

thecalculations,butyoudon'thaveto)

a) 10101010AND

b) 00111101OR

c)

1')

((

o

,'

1000011)oR

(NoT(01110111))jND

(NOT(

)

A lrgjL

{-

.:llrJ

3^

';,; t

4

h:,"0,

BME303Spring

e) (NOT(ol

t00l1o)NAND

rowstothetable

it

You

need

to.)

lJ {,,)l)

p(

)) NOR(NOT(11011100))

(Addmore

l.Po\ 7)9!):

'-.-l

I

1t

ab

/,

to

^-.J-A-

lJl,.t',V

o

l

? !11Ju-*{-(

7 l'y.'v

rn!!*

,., t

Problem

Fillup

the blanksin thetruthtablswithsuitable

valuos.

output'l= NOT(Y)

NAND

(NOT(Z)OR X)

output2= Y AND(X OR

NOT(Z))

Output

= NOT(X)

NOR(Z

ANDNOT(Y))

r,.

ilgi

^i'l

il

it

I

o

o

o

o

,i

o o I I a a l

)a

'Y

z NOT

X

NOT

NOT

Y

AND

z

NOT

(Y)

oRz

Out

1 OR

z

NOT

(YOR

z)

XOR

NoT(z)

Out

Out

a

o c

n

1 o

() L

o C)

0 1 0 0 a

(,

o

' I

D

t)

o o

o o

,

0 0 o

o

a o

()

1 0 1 o

a

() o a

o

a

1

1 0 o

o o O

o

'

1 1

(

a o

I

o

t )Dt