computer science 101 computer systems organization machine language examples entire machine

12
Computer Science Computer Science 101 101 Computer Systems Computer Systems Organization Organization Machine Language Examples Machine Language Examples Entire machine Entire machine

Upload: nora-todd

Post on 13-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Computer Science Computer Science 101101

Computer Systems Computer Systems OrganizationOrganization

Machine Language ExamplesMachine Language Examples

Entire machineEntire machine

Page 2: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Hypothetical Lab MachineHypothetical Lab Machine

Memory ALU Control

MAR(12) MDR(16)

16

ALU

R(16)

PC(12) IR(16)

+1

GT EQ LT

Page 3: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Hypothetical Machine Hypothetical Machine InstructionsInstructions

Opcode Operation MeaningOpcode Operation Meaning

00000000 Load X Con(X) Load X Con(X)RR

00010001 Store X R Store X RCon(X)Con(X)

00100010 Clear X Clear X 0 0Con(X)Con(X)

00110011 Add X R+Con(X) Add X R+Con(X)RR

01000100 Increment X Con(X)+1 Increment X Con(X)+1 Con(X)Con(X)

0101 Subtract X R-Con(X) 0101 Subtract X R-Con(X) RR

0110 Decrement X Con(X)-1 0110 Decrement X Con(X)-1 Con(X)Con(X)

Page 4: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Hypothetical Machine Hypothetical Machine InstructionsInstructions

Opcode Operation MeaningOpcode Operation Meaning

01110111 Compare X If Con(X) > R Compare X If Con(X) > R CC: 100,etc. CC: 100,etc.

10001000 Jump X Jump X X X PC PC

10011001 JumpGT X JumpGT X If GT=1, If GT=1, X X PC PC

10101010 JumpEQ X JumpEQ X If EQ=1, If EQ=1, X X PC PC

10111011 JumpLT X JumpLT X If LT=1, If LT=1, X X PC PC

11001100 JumpNE X JumpNE X If EQ=0, If EQ=0, X X PC PC

Page 5: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Hypothetical Machine Hypothetical Machine InstructionsInstructions

Opcode Operation MeaningOpcode Operation Meaning

11011101 In X In X Input value Input valueCon(X)Con(X)

11101110 Out X Out X Con(X) Con(X)Output Output valuevalue

11111111 Halt Halt Stop execution Stop execution

Page 6: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Machine Language: Machine Language: Con(5)+Con(6) Con(5)+Con(6) Con(7) Con(7)

0: 0000000000000101 1: 0011000000000110 2: 0001000000000111 3: 1111000000000000 4: 0000001000001010 5: 0000000000101100 6: 0000000000001011 7: 0000001111111111

R:

0000000000000101 Load 5

1111000011110000

0011000000000110 Add 60001000000000111 Store 71111000000000000 Halt

0000000000101100

0000000000101100

0000000000001011

0000000000110111

0000000000110111

Python: c = a + b

Page 7: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine
Page 8: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

MicroMicro Steps: Fetch and Steps: Fetch and DecodeDecode

Phases PhasesFetch PhaseFetch Phase

PC PC MAR MAR

FetchFetch

MDR MDR IR IR

PC+1 PC+1 PC PC

DecodeDecode

IRIRopop ALU ALU

MUX MUX

Memory ALU Control

MAR(12) MDR(16)

16

ALU

R(16)

PC(12) IR(16)

+1

Page 9: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

Micro Steps: Execution of LoadMicro Steps: Execution of Loadand Storeand Store

Load XLoad XIRIRaddadd MAR MAR

FetchFetch

MDR MDR R R

Store XStore XIRIRadd add MAR MAR

R R MDR MDR

StoreStore

Memory ALU Control

MAR(12) MDR(16)

16

ALU

R(16)

PC(12) IR(16)

+1

Page 10: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

MicroMicro Steps: Execution of Steps: Execution of AddAddand Jumpand Jump

Add XAdd XIRIRaddadd MAR MAR

FetchFetch

MDR MDR ALU ALU

R R ALU ALU

AddAdd

ALU ALU R R

Jump XJump XIRIRadd add PC PC

Memory ALU Control

MAR(12) MDR(16)

16

ALU

R(16)

PC(12) IR(16)

+1

Page 11: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine

MicroMicro Steps: Execution of Steps: Execution of Compare and JumpGTCompare and JumpGT

Compare XCompare XIRIRaddadd MAR MAR

FetchFetch

MDR MDR ALU ALU

R R ALU ALU

SubtractSubtract (set CC) (set CC)

JumpGTJumpGTIf GT=1If GT=1

IR IRaddadd PC PC

Memory ALU Control

MAR(12) MDR(16)

16

ALU

R(16)

PC(12) IR(16)

+1

Page 12: Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine