pertemuan 5 bahasa rakitan: i

11
1 Pertemuan 5 Bahasa Rakitan: I Matakuliah : T0324 / Arsitektur dan Organisasi Komputer Tahun : 2005 Versi : 1

Upload: olinda

Post on 22-Jan-2016

54 views

Category:

Documents


2 download

DESCRIPTION

Pertemuan 5 Bahasa Rakitan: I. Matakuliah: T0324 / Arsitektur dan Organisasi Komputer Tahun: 2005 Versi: 1. Learning Outcomes. Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mendemonstrasikan penggunaan bahasa rakitan dalam instruksi mesin ( C3 ) ( No TIK : 3 ). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Pertemuan 5 Bahasa Rakitan: I

1

Pertemuan 5Bahasa Rakitan: I

Matakuliah : T0324 / Arsitektur dan Organisasi Komputer

Tahun : 2005

Versi : 1

Page 2: Pertemuan 5 Bahasa Rakitan: I

2

Learning Outcomes

Pada akhir pertemuan ini, diharapkan mahasiswa

akan mampu :

• Mendemonstrasikan penggunaan bahasa rakitan dalam instruksi mesin ( C3 ) ( No TIK : 3 )

Page 3: Pertemuan 5 Bahasa Rakitan: I

3

Chapter 2.

Assembly Language: I

Page 4: Pertemuan 5 Bahasa Rakitan: I

4

NUM2

NUM n

NUM1

R0Clear

R0,SUM

R1

#4,R2

(R2),R0

Figure 2.17. Memory arrangement for the program in Figure 2.12.

100

132

604

212

208

204

200

128

124

120

116

112

108

104

100

SUM

N

LOOP

LOOP

Decrement

Add

Add

Move

#NUM1,R2

N,R1Move

Move

Branch>0

Page 5: Pertemuan 5 Bahasa Rakitan: I

5

Memory Addressingaddress ordatalabel Operation information

Assemblerdirectives SUM EQU 200ORIGIN 204

N DATAWORD 100NUM1 RESERVE 400

ORIGIN 100Statementsthat START MOVE N,R1

generate MOVE #NUM1,R2machine CLR R0instructions LOOP ADD (R2),R0

ADD #4,R2DEC R1BGTZ LOOPMOVE R0,SUM

Assemblerdirectives RETURNEND START

Figure 2.18. Assembly language representation for the program in Figure 2.17.

Page 6: Pertemuan 5 Bahasa Rakitan: I

6

DATAIN DATAOUT

SIN SOUT

Keyboard Display

Bus

Figure 2.19 Bus connection for processor, keyboard, and display.

Processor

Page 7: Pertemuan 5 Bahasa Rakitan: I

7

Move #LOC,R0 InitializepointerregisterR0topoint totheaddressofthefirstlocationinmemorywherethecharactersareto bestored.

READ TestBit #3,INSTATUS Wait for a characterto be enteredBranch=0 READ in thekeyboardbufferDATAIN.MoveByte DATAIN,(R0) TransferthecharacterfromDATAIN into

thememory(thisclearsSIN to 0).ECHO TestBit #3,OUTSTATUS Waitforthedisplay to becomeready.

Branch=0 ECHOMoveByte (R0),DATAOUT Movethecharacterjust readto thedisplay

bufferregister(this clearsSOUT to 0).Compare #CR,(R0)+ Check if thecharacterjust readis CR

(carriagereturn). If it isnot CR, thenBranch0 READ branch back andreadanothercharacter.

Also,increment thepointertostorethenextcharacter.

Figure 2.20. A program that reads a line of characters and displays it.

Page 8: Pertemuan 5 Bahasa Rakitan: I

8

Figure 2.21. A stack of words in the memory.

register

Stackpointer

17

BOTTOM

0

SP Currenttop element

elementBottom

Stack

2 k 1-

•••

•••

•••

739

43

28-

Page 9: Pertemuan 5 Bahasa Rakitan: I

9

Figure 2.22. Effect of stack operations on the stack in Figure 2.21.

(b) After pop into ITEM(a) After push from NEWITEM

17

739

43

ITEM

SP

Stack

SP

NEWITEM

19

17

739

19

43

28-

28-28-

•••

•••

Page 10: Pertemuan 5 Bahasa Rakitan: I

10

SAFEPOP Compare #2000,SP Check to seeif thestack pointercontainsBranch>0 EMPTYERROR anaddressvaluegreaterthan2000.If it

does,thestack isempty. Branch to theroutine EMPTYERRORforappropriateaction.

Move (SP)+,ITEM Otherwise,popthetopof thestack intomemorylocationITEM.

SAFEPUSH Compare #1500,SP Check toseeif thestack pointerBranch 0 FULLERROR containsanaddressvalueequal

to or lessthan1500.If it does,thestack isfull. Branch to theroutineFULLERRORforappropriateaction.

Move NEWITEM, (SP) Otherwise,pushtheelement inmemorylocationNEWITEM ontothestack.

Figure 2.23. Checking for empty and full errors in pop and push operations.

(b) Routine for a safe push operation

(a) Routine for a safe pop operation

Page 11: Pertemuan 5 Bahasa Rakitan: I

11

ReturnCall

Figure 2.24. Subroutine linkage using a link register.

1000

204

204

Link

PC

Return

1000

locationMemory

Calling programMemorylocation

200204

Call SUBnext instruction

Subroutine SUB

first instruction