Introduc>on to MARIE 2 Schedule Today Introduce - - PowerPoint PPT Presentation

introduc on to marie
SMART_READER_LITE
LIVE PREVIEW

Introduc>on to MARIE 2 Schedule Today Introduce - - PowerPoint PPT Presentation

Computer Systems and Networks ECPE 170 Jeff Shafer University of the Pacific Introduc>on to MARIE 2 Schedule Today Introduce


slide-1
SLIDE 1

ì ¡

Computer ¡Systems ¡and ¡Networks ¡

ECPE ¡170 ¡– ¡Jeff ¡Shafer ¡– ¡University ¡of ¡the ¡Pacific ¡

Introduc>on ¡to ¡ MARIE ¡

slide-2
SLIDE 2

Schedule ¡

ì Today ¡

ì Introduce ¡MARIE ¡

ì Wed ¡15th ¡and ¡Fri ¡17th ¡ ¡

ì Assembly ¡programming ¡tutorial ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

2 ¡

slide-3
SLIDE 3

Recap ¡– ¡MARIE ¡Overview ¡

ì How ¡does ¡the ¡MARIE ¡architecture ¡represent ¡

posiEve/negaEve ¡numbers? ¡

ì Binary, ¡two’s ¡complement ¡data ¡representa>on ¡

ì How ¡is ¡MARIE’s ¡main ¡memory ¡configured? ¡ ¡

(# ¡of ¡words, ¡size ¡of ¡each ¡word) ¡

ì 4K ¡words, ¡16 ¡bits ¡wide, ¡word-­‑addressable ¡ ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

3 ¡

slide-4
SLIDE 4

Recap ¡– ¡MARIE ¡Overview ¡

ì MARIE ¡has ¡seven ¡registers ¡for ¡control ¡and ¡data ¡

movement ¡

ì AC? ¡ ì MAR? ¡ ì MBR? ¡ ì PC? ¡ ì IR? ¡ ì InReg? ¡ ì OutReg? ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

4 ¡

slide-5
SLIDE 5

Recap ¡– ¡MARIE ¡Data ¡Path ¡

ì Common ¡data ¡bus ¡

ì

Links ¡main ¡memory ¡and ¡registers ¡

ì

Each ¡device ¡iden>fied ¡by ¡unique ¡ number ¡

ì

Bus ¡has ¡control ¡lines ¡that ¡iden>fy ¡ device ¡used ¡in ¡opera>on ¡ ì Dedicated ¡data ¡paths ¡

ì

Permits ¡data ¡transfer ¡between ¡ accumulator ¡(AC), ¡memory ¡buffer ¡ register ¡(MBR), ¡and ¡ALU ¡without ¡using ¡ main ¡data ¡bus ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

5 ¡

slide-6
SLIDE 6

Recap ¡– ¡MARIE ¡ISA ¡

ì What ¡is ¡an ¡InstrucEon ¡Set ¡Architecture ¡(ISA)? ¡

ì Interface ¡between ¡hardware ¡and ¡soTware ¡ ì Specifies ¡the ¡format ¡of ¡processor ¡instruc>ons ¡ ¡ ì Specifies ¡the ¡primi>ve ¡opera>ons ¡the ¡processor ¡can ¡

perform ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

6 ¡

slide-7
SLIDE 7

Recap ¡– ¡MARIE ¡Instructions ¡(Full) ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

7 ¡

Binary ¡ Hex ¡ InstrucEon ¡ Meaning ¡ 0001 1 ¡ LOAD X Load ¡contents ¡of ¡address ¡X ¡into ¡AC ¡ 0010 2 ¡ STORE X Store ¡contents ¡of ¡AC ¡at ¡address ¡X ¡ 0011 3 ¡ ADD X Add ¡contents ¡of ¡address ¡X ¡to ¡AC ¡ 0100 4 ¡ SUBT X Subtract ¡contents ¡of ¡address ¡X ¡from ¡AC ¡ 0101 5 ¡ INPUT Input ¡value ¡from ¡keyboard ¡into ¡AC ¡ 0110 6 ¡ OUTPUT Output ¡value ¡in ¡AC ¡to ¡display ¡ 0111 7 ¡ HALT Terminate ¡program ¡ 1000 8 ¡ SKIPCOND Skip ¡next ¡instruc>on ¡on ¡condi>on ¡based ¡on ¡AC ¡value ¡ 1001 9 ¡ JUMP X Load ¡value ¡of ¡X ¡into ¡PC ¡ 1010 A ¡ CLEAR Set ¡AC ¡to ¡0 ¡ 1011 B ¡ ADDI X Add ¡contents ¡of ¡address ¡Mem[X] ¡to ¡AC ¡ 1100 C ¡ JUMPI X Load ¡contents ¡of ¡address ¡Mem[X] ¡into ¡PC ¡ 1101 D ¡ LOADI X Load ¡contents ¡of ¡address ¡Mem[X] ¡into ¡AC ¡ ¡ 1110 E ¡ STOREI X Store ¡contents ¡of ¡AC ¡at ¡address ¡Mem[X] ¡

See ¡table ¡ 4.7 ¡in ¡ book! ¡

slide-8
SLIDE 8

Recap ¡– ¡MARIE ¡Instructions ¡

ì How ¡does ¡MARIE ¡format ¡instrucEons ¡in ¡computer ¡

memory? ¡ ¡

ì Two ¡fields ¡

ì Opcode ¡(4 ¡bits) ¡– ¡Opera>on ¡code ¡ ì Address ¡(12 ¡bits) ¡– ¡Address ¡to ¡operate ¡to/from ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

8 ¡

slide-9
SLIDE 9

ì ¡

MARIE ¡Programming ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

9 ¡

slide-10
SLIDE 10

A ¡Simple ¡Program ¡

ì Consider ¡this ¡simple ¡MARIE ¡program ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

10 ¡

slide-11
SLIDE 11

A ¡Simple ¡Program ¡

ì What ¡happens ¡inside ¡the ¡computer ¡when ¡our ¡

program ¡runs? ¡

ì Instruc>on ¡1: ¡LOAD ¡104 ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

11 ¡

slide-12
SLIDE 12

A ¡Simple ¡Program ¡

ì Instruc>on ¡2: ¡ADD ¡105 ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

12 ¡

slide-13
SLIDE 13

ì ¡

Assembler ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

13 ¡

slide-14
SLIDE 14

Role ¡of ¡Assembler ¡

ì Mnemonic ¡instruc>ons: ¡LOAD ¡104 ¡

ì “Easy” ¡for ¡humans ¡to ¡write ¡and ¡understand ¡ ì Impossible ¡for ¡computers ¡to ¡understand ¡

ì Role ¡of ¡assembler ¡

ì Translate ¡instruc>ons ¡from ¡assembly ¡language ¡(for ¡

humans) ¡into ¡machine ¡language ¡(for ¡computers) ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

14 ¡

slide-15
SLIDE 15

Assembler ¡versus ¡Compiler ¡

ì What’s ¡the ¡difference ¡between ¡an ¡assembler ¡and ¡a ¡

compiler? ¡ ¡Which ¡has ¡the ¡harder ¡job? ¡

ì Assembly ¡language ¡è ¡machine ¡language ¡

ì One-­‑to-­‑one ¡correspondence ¡ ì Assembler ¡is ¡simple! ¡

ì High-­‑level ¡language ¡è ¡machine ¡language ¡

ì Many-­‑to-­‑one ¡correspondence ¡ ì Compiler ¡is ¡complicated! ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

15 ¡

slide-16
SLIDE 16

Assembler ¡Operation ¡

ì Assemblers ¡create ¡an ¡object ¡file ¡(containing ¡

machine ¡code) ¡from ¡mnemonic ¡assembly ¡source ¡ code ¡in ¡two ¡passes ¡

ì Pass ¡1 ¡

ì Assemble ¡as ¡much ¡of ¡the ¡program ¡as ¡possible ¡ ì Builds ¡a ¡symbol ¡table ¡(contains ¡memory ¡references ¡

for ¡all ¡symbols ¡in ¡the ¡program) ¡ ì Pass ¡2 ¡

ì Complete ¡instruc>ons. ¡Fill ¡in ¡addresses ¡stored ¡in ¡the ¡

symbol ¡table ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

16 ¡

slide-17
SLIDE 17

Assembler ¡Operation ¡

ì Example ¡program ¡

ì

HEX ¡and ¡DEC ¡direc>ves ¡to ¡ specify ¡radix ¡of ¡constants ¡ ì Assembler ¡Pass ¡#1 ¡

ì

Create ¡symbol ¡table ¡

ì

Create ¡par>ally-­‑assembled ¡ instruc>ons ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

17 ¡

Symbol ¡ Table: ¡ Name, ¡ Address ¡ ParEally-­‑ Assembled ¡ Program: ¡

slide-18
SLIDE 18

Assembler ¡Operation ¡

ì Assembler ¡Pass ¡#2 ¡

ì Fill ¡in ¡details ¡from ¡symbol ¡table ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

18 ¡

Program ¡ Symbol ¡ Table ¡ Machine ¡ Code ¡

slide-19
SLIDE 19

Assembler ¡Operation ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

19 ¡

Program: ¡ Symbol ¡Table: ¡ Machine ¡Code: ¡

slide-20
SLIDE 20

ì ¡

More ¡MARIE ¡Instructions ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

20 ¡

slide-21
SLIDE 21

New ¡Addressing ¡Modes! ¡

ì Direct ¡addressing ¡mode ¡

ì All ¡the ¡instruc8ons ¡covered ¡to ¡date… ¡ ì The ¡address ¡of ¡the ¡operand ¡is ¡explicitly ¡stated ¡in ¡the ¡

instruc>on ¡ ì New: ¡Indirect ¡addressing ¡mode ¡

ì The ¡address ¡of ¡the ¡address ¡of ¡the ¡operand ¡is ¡given ¡

in ¡the ¡instruc>on ¡

ì Just ¡like ¡pointers ¡in ¡COMP ¡51/53 ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

21 ¡

slide-22
SLIDE 22

Indirect ¡Addressing ¡Mode ¡Instructions ¡

ì Four ¡new ¡instruc>ons ¡use ¡indirect ¡addressing ¡

mode: ¡Load ¡/ ¡store ¡/ ¡add ¡/ ¡jump ¡indirect ¡ ¡

ì LOADI ¡X ¡and ¡STOREI ¡X ¡– ¡specified ¡the ¡address ¡of ¡

the ¡address ¡of ¡the ¡operand ¡to ¡be ¡loaded ¡or ¡stored ¡ ¡

ì In ¡RTL ¡: ¡ ¡

MAR ← X MBR ← M[MAR] MAR ← MBR MBR ← M[MAR] AC ← MBR MAR ← X MBR ← M[MAR] MAR ← MBR MBR ← AC M[MAR] ← MBR STOREI X

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

22 ¡

LOADI X

slide-23
SLIDE 23

Indirect ¡Addressing ¡Mode ¡Instructions ¡

ì ADDI ¡X ¡-­‑ ¡Combina>on ¡of ¡LOADI ¡X ¡and ¡ADD ¡X: ¡

ì In ¡RTL: ¡ ¡

MAR ← X MBR ← M[MAR] MAR ← MBR MBR ← M[MAR] AC ← AC + MBR ADDI X

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

23 ¡

slide-24
SLIDE 24

Subroutine ¡Instructions ¡

ì Remember ¡subrou>nes? ¡(i.e. ¡func>ons) ¡ ì Machine ¡instruc>ons ¡can ¡make ¡subrou>nes ¡easier ¡

to ¡implement ¡

ì Jump-­‑and-­‑store ¡instruc>on ¡(JNS X) ¡provides ¡

limited ¡subrou>ne ¡func>onality ¡

ì RTL: ¡ ¡

MBR ← PC MAR ← X M[MAR] ← MBR MBR ← X AC ← 1 AC ← AC + MBR PC ← AC

Does ¡JNS ¡permit ¡ recursive ¡calls? ¡ ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

24 ¡

No, ¡PC ¡is ¡stored ¡at ¡ address ¡X, ¡and ¡we ¡jump ¡ to ¡address ¡X+1. ¡You ¡ can’t ¡do ¡this ¡ repeatedly! ¡

slide-25
SLIDE 25

Clear ¡Instruction ¡

ì CLEAR ¡instruc>on ¡

ì Set ¡the ¡contents ¡of ¡the ¡accumulator ¡to ¡all ¡zeroes. ¡

ì RTL ¡for ¡CLEAR: ¡

AC ← 0

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

25 ¡

slide-26
SLIDE 26

MARIE ¡Instructions ¡(Full) ¡

Spring ¡2012 ¡ Computer ¡Systems ¡and ¡Networks ¡

26 ¡

Binary ¡ Hex ¡ InstrucEon ¡ Meaning ¡ 0001 1 ¡ LOAD X Load ¡contents ¡of ¡address ¡X ¡into ¡AC ¡ 0010 2 ¡ STORE X Store ¡contents ¡of ¡AC ¡at ¡address ¡X ¡ 0011 3 ¡ ADD X Add ¡contents ¡of ¡address ¡X ¡to ¡AC ¡ 0100 4 ¡ SUBT X Subtract ¡contents ¡of ¡address ¡X ¡from ¡AC ¡ 0101 5 ¡ INPUT Input ¡value ¡from ¡keyboard ¡into ¡AC ¡ 0110 6 ¡ OUTPUT Output ¡value ¡in ¡AC ¡to ¡display ¡ 0111 7 ¡ HALT Terminate ¡program ¡ 1000 8 ¡ SKIPCOND Skip ¡next ¡instruc>on ¡on ¡condi>on ¡based ¡on ¡AC ¡value ¡ 1001 9 ¡ JUMP X Load ¡value ¡of ¡X ¡into ¡PC ¡ 1010 10 ¡ CLEAR Set ¡AC ¡to ¡0 ¡ 1011 11 ¡ ADDI X Add ¡contents ¡of ¡address ¡Mem[X] ¡to ¡AC ¡ 1100 12 ¡ JUMPI X Load ¡contents ¡of ¡address ¡Mem[X] ¡into ¡PC ¡ 1101 13 ¡ LOADI X Load ¡contents ¡of ¡address ¡Mem[X] ¡into ¡AC ¡ ¡ 1110 14 ¡ STOREI X Store ¡contents ¡of ¡AC ¡at ¡address ¡Mem[X] ¡

See ¡table ¡ 4.7 ¡in ¡ book! ¡