0% found this document useful (0 votes)
47 views27 pages

Ece 2071

The document contains a mix of programming concepts, computer architecture, and binary operations, including instructions for various types of assembly language. It discusses the structure of instructions, memory operations, and the role of the CPU in processing information. Additionally, it covers topics such as bit manipulation, shifting, and floating-point number representation in IEEE 754 format.

Uploaded by

Nguyễn Bin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views27 pages

Ece 2071

The document contains a mix of programming concepts, computer architecture, and binary operations, including instructions for various types of assembly language. It discusses the structure of instructions, memory operations, and the role of the CPU in processing information. Additionally, it covers topics such as bit manipulation, shifting, and floating-point number representation in IEEE 754 format.

Uploaded by

Nguyễn Bin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

all 2071

Week 2

re

← via klhé > 18 rien do -


while run 1 loin

viet
vida qto.mg néu San
← written function -
k

diioc declare bein tren

Static variable
L
give nguyén qua cat

loin call function

⊕ lair 1-
~
a = b

⊕ 1Eur 2 I
a = a + b = Za
static
loin tmÉc
4 5878 9
0 I 23


'

23 22 2
hear = is
8 4 2 I 2 / °
.
16 16 16
. .

. .
.ie before : Junk
-

. _
.

20-323 int

- . . 24 → 27 char :/ bit
8
28 qg
µ
0×62 -

98116=6 Cdu '



↑ ?
re
24
6116=0 Cdu >

ten → 62
ngño:c
du '
don't have access

① vi bat doin hi . . .
.
20 → Ic < 20 → Junk
( out of scope )

② .
.
20 : int ( 98 ) rien chitin 4 bits

Di 98 → he × → 62 → 0×62
( dec )

③ Éibary
"
d-
"
. . .
29 : ECE →
ASCII

95/43-45 → 0 ✗
95434500¢end
line ( lo )
② _ . .
28 : int CO2) d-of dec → hex

2 1 16 = 0 Cdu' 2) → 0×2

⑤ . . .
2C : mft int = 4 bits → 28 29 Za 2b

int 0×0 ( Cho d- énf moi En 30 )


→ 2C =
. .

= 0 Chex to dec )

0116 = 0 dci O 0×0

⑥ . . .
30 :
int (0×0) = 4 bits = 2C 2d Ze 2f

→ . -30 = int (7) tiép theo


7 1 16 = 0 die 7 → 0×7

(0×31^0×2)
⑦ . . .
34 :
hiong Hi ,
int

#
0011 0010

( hex to dec ) OR Chex to dec)


( dñumu )

0011

0001 → 0×1

0010 -

¥
Chi I khi 2 Cai Khai nhan
Week 7 quiz
prews

④ concept questions

112,3

[ load word
bits 3 32×3=96
I register = 32 =

instruction

storeinfo-instmch.com#
-

computer = device that

use its hardware process


info

accordingtoinslmctionu.it
trout
by
need of step
- -

step change
-

parts of computer :
CPU out instructions that are stored in the
:
carry memory
11

core
"
"

L interact with 2
higher-level blocks
task depends
① datapath : production line ,
doing on

> of different
decide instruction ( in
assembly ) Made

(
on .
up
operate data
firs units to on .

< for
register = short -
term
memory data path to
while instruction
brain access performing .

② Tonto 1 unit :
sending signal to components to

indicate what operation to do .


Tell data path how

to handle instruction ,
which steps
?⃝
⑤ Memory : where data stored . Data path access this

for information if
necessary

( IO ) =
Inputs/ Outputs : how computer interact with

outside world .

CPU )
Input gain information from outside world ( outside
-

via input devices (


eg :
keyboard )
or

internet
-

Output ; send information via screen / speakers . . .

MEPS
assembly language link between high level
language
-
-

:
,

✗ machine code .

of instructions
⊕ 3
types ,
32 bits each : I, J ,
R

T
details below

⊕ an example of code :
of instruction
Types
-
R -

type : opcode = 000000 all the time FUNC


change ( only type
,

that has function code FUNC ) .


Write to rt .
ALUOP = 10 here

[ structure rt func
:
opcode rs rs

6 5 5 6 ( bits )
5

I -

type : work with immediate ,


branch .
Write tort ( no rd ) .

L structure rt immediate ( value )


: opcode rs
signed
6 5 ( bits )
#
5

tri
n
-
bits =
Chay
' -1
2n 2h
-

-
→ -1

J -

type : stand for


jump , jump to a speead ( unlike
condition if 1-
jump
no →
branch which
jump with condition ) ,

¥ .
cannot jump AND branch at the same time

[ structure :
opcode immediate
6 26 ( bits )
Caéh d-Éi R/I / I
type →
binary
representation

call Ctra them )


Sys
b
R =
array slower than

signal ≤ m=

Control register
of RAM >
array
. . .

1 I R
Reg Dst =
type =O type
-
-
-
:
,

1 I 0 R
ALU src
type type
= -
= -

:
-

-
Mem to Reg :

write
Reg :
-

-
Mem Write :
only 1 for SW

-
Branch :

ALUOP : -
1 :

¥ By default , everything is 0

✗ if mem Write

rnem Read =
0 everything = 0

write
reg

¥ cannot load AND store

write AND read at the same time

mem write AND write


reg
néu 1 ecii =0
caico-nl.ci = 0
Bit mask

when
changing
a
modifying bit

¥ difference between lw ,
hi
,
lb :

immediate 42 )
-
Ii : load an value
Ceg : ti $ to ,

hw load 32 bit word from mem -7 work with


reg
:
- -

location
memory .

④ eg : he $+0 ,
0 ( $ so ) = load word from

location store in $ so with offset =0 ( $ so -10 )


1 bits from Then
lb load
byte 9 mem →
reg
-
: = .

extended it to 32 bits
sign
-

( $ so ) with but
⊕ eg : lb $+0 ,
8 : same 1W
only
a byte
$+0 $+1 label
beg
:
beg , ,

① immediate : difference between instruction after beg


& label
label 0×20
rien beq
:
eg
: . _

J%f3.es
20
Linh nai to : 0×29
. _ . _ m&t
label . . . .
0.x 30

immediately =
0×30-0×2 , =3

( a bits between every instruction


)

ALU 0 trii 2 address =0


beg : sre =
,
zero
gate
in ALU = I [a
flag) branch =/

else → K branch

d-É k waste 2
shift left
zeros
- 2

Cvinhay 9--0100-7 \ -
_
-

Chi din line


j care
jump
-

[25-0] shift left 2 * PC -14

most
t
signif.ca# PC [31-28]
bits
"
I → jump
jump
-
-

31 bits →
-

pipelining :
%ML
info of
simultaneously load

multiple instruction after each

update ↑

In order successor

root ré Phai
'

him d-ui.ec larger


-
→ d-é

t
root nhat
ré trai d-É
goin
to

replace SÉ noiy ciao root


( keep track of the ↓

riay
'

parent = where child free so

come from ) ↓
point parent to NULL
* atoi =
sting to
integer
" "
11 → 11
PLC
Week 8 ws flux

① 11 in
binary :

24 2°
'

25 23 22 2

0 0 I 0 I 1

= 8 + 2 + I = 1

② -11 in
binary

flip everything : 110100

bit
⊕ turn least
significant to 1 : 110101

③ 10110 t 10011 = ?

carry
10110 I + I = 0 ( I
carry
+
10011 to next Col )
I 01001 ✓ Ot 0 = 0

I t 0 = 0 + I =
I

④ 10110 = ?

into two complement


change this

( flip
everything & add 1)
I 0110
ioiio
100 11
-

= 10110 1- 0110 I

01 1 01
00011 = 11 ✓

✗ 00011 ✓ i
the overflow ( most of the case )
ignore
?⃝
?⃝
⑤ perform the
following ,
what happen ?

or $ -12
, $-11 ,
$ to
(
0×6 LO ✗ C

0×6 = 6 Chexa) = 0110 (4+2)

0 ✗ C = C = 12 Chexa ) = 1100 (8+4)

1 1 00

0
⑤ → 1 1 10 → 8+4+2+0
Oil
= 14 Chexa ) ✓

⑥ left shift bit shift 2


Shifting :
→ 1 = ✗

Sll $ rd ,
$ rt ,
shift Amount

shift bit left


right → 1 = ÷ 2

Srt $ rd ,
$ rt ,
shift Amount

left

shifting a
binary by 3 =
2×2×2


# of step = 23 = 8 ✓
shift left = 23
Week 8
pre
-
ws quiz

① converting floating point number 1954.1234 into IEEE 754

format of exponent part


. What is value in
binary ?
(
single precision )

1954 . 1239
-
T ( number
whole number
decimal

portion portion

① convert whole number into


binary : read from bottom to top

division result remainder

1954 12 997 0

997 12 988 I

488 12 294 0
1954=1111 0100010
24912 122 0

12212 61 0

6112 30 1

3012 15 0

1512 7 1

712 3 I

312 I 1

1 12
⑤ I

divide until this = 0


convert decimal portion to ( read from top -7 bottom )
② binary
multiply result number infront of decimal

0.1234×2 0.2468 0

0.1234
0.2468 ✗ 2 0.9936 0
= 0001
0.9936×2 0.9872 0

0.9872×2 1.9799 I

③ combine :

¥ '"É◦◦o
' '

,
1111 0100010

\ /
1111 0100 010 .
0001

"
decimal point form where steps
④ move to i. abed ✗ 2 =

§
'
=) 1111 0100 010
t.jo#
.
0001 = 0001 ✗ 2

10
steps used to

⑤ determine the
sign find exponent
/ = ⊖ 0 = ⊕ 1954 . 1234 = ⊕
,
,

sign = 0

⑥ find exponent (
single precision)
(double precision -_ 1023 )
127
single → exponent bias =

'7 8 1
10001001

:
exponent = 127 +10 = 137

137 -

binary
137

68
68

34
17
0


1

: :
a


2

'
0

34
⑦ Compile all the part

C1 bit ) 18 bits ) mantissa 23 bits )


sign +
exponent + [ =
32

0 1000 I 001 I 110 1000 1000 0100 0000

I
i.IE/iE?aio
- - / \

fill the rest bits


the final

result

two complement
10
-

I 000
1010--1010
' =

sign bit ,
I means ⊖
-
10

0×23 =
'
00T
'
= 2° + 2
'
+ 25 = 35
hex a
binary decimal

he ✗ a value
→ this is
to decimal
have to change

9 bits
I
jump =

[
101µg
8 9
]
. . .

[4 67
[0 I 23 ] 5

- -
Week 9 prews quiz

0×0000 0080

Vi 0×80 in 16 bit = 0000 0000 1000 0000

I
bit:O
TT
least sig
kéo _dÉn muÉn
doii least
Sig bit d-§ dai
mong

0 0 0 0 r-i.l0 0 0 32bitsd.ua
=3

theo
being nñy

I.
Week 10 prews quiz

-
assert = set to 1

-
on
-

delay timer : when input =L how


long
will

turn from off


the output → on ( not on
immediately)
off delay timer when input 0 how will
long
-
-
: =

off [ not off


the output turn from
immediately )

on
( connect when 0 )
-1 / 1- = NOT
gate
-1 1- =
normal ( connect when 1)
For MIPS test
-
I /R / T
type
-

Data path (
everything )
-
ALU op [ 0] ,
[I ] = 2 bits ( how can 3 bits )

How know which control unit used action ?


to
being in an
-

C. for ? )
eg , beg
-
Lw ,
Sw ,
1b ,
Sb
-

$sp ( stack
pointer )
Week 11 pre
-
ws

You might also like