Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Pertemuan 5 Bahasa Rakitan: I Matakuliah: T0324 / Arsitektur dan Organisasi Komputer Tahun: 2005 Versi: 1."— Presentation transcript:

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

2 2 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mendemonstrasikan penggunaan bahasa rakitan dalam instruksi mesin ( C3 ) ( No TIK : 3 )

3 3 Chapter 2. Assembly Language: I

4 4 NUM2 NUMn 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 Decrement Add Move #NUM1,R2 N,R1Move Branch>0

5 5 MemoryAddressing addressordata labelOperationinformation AssemblerdirectivesSUMEQU200 ORIGIN204 NDATAWORD100 NUM1RESERVE400 ORIGIN100 StatementsthatSTARTMOVEN,R1 generateMOVE#NUM1,R2 machineCLRR0 instructionsLOOPADD(R2),R0 ADD#4,R2 DECR1 BGTZLOOP MOVER0,SUM AssemblerdirectivesRETURN ENDSTART Figure 2.18. Assembly language representation for the program in Figure 2.17.

6 6

7 7 Move#LOC,R0InitializepointerregisterR0topointtothe addressofthefirstlocationinmemory wherethecharactersaretobestored. READTestBit#3,INSTATUSWaitforacharactertobeentered Branch=0READinthekeyboardbufferDATAIN. MoveByteDATAIN,(R0)TransferthecharacterfromDATAINinto thememory(thisclearsSINto0). ECHOTestBit#3,OUTSTATUSWaitforthedisplaytobecomeready. Branch=0ECHO MoveByte(R0),DATAOUTMovethecharacterjustreadtothedisplay bufferregister(thisclearsSOUTto0). Compare#CR,(R0)+CheckifthecharacterjustreadisCR (carriagereturn).IfitisnotCR,then Branch 00 READbranchbackandreadanothercharacter. Also,incrementthepointertostorethe nextcharacter. Figure 2.20. A program that reads a line of characters and displays it.

8 8 Figure 2.21. A stack of words in the memory. register Stack pointer 17 BOTTOM 0 SP Current top element element Bottom Stack 2 k 1- 739 43 28-

9 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- - -

10 10 SAFEPOPCompare#2000,SPChecktoseeifthestackpointercontains Branch>0EMPTYERRORanaddressvaluegreaterthan2000.Ifit does,thestackisempty.Branchtothe routineEMPTYERRORforappropriate action. Move(SP)+,ITEMOtherwise,popthetopofthestackinto memorylocationITEM. SAFEPUSHCompare#1500,SPChecktoseeifthestackpointer Branch0FULLERRORcontainsanaddressvalueequal toorlessthan1500.Ifitdoes,the stackisfull.Branchtotheroutine FULLERRORforappropriateaction. MoveNEWITEM,(SP)Otherwise,pushtheelementinmemory locationNEWITEMontothestack.  – 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

11 11 ReturnCall Figure 2.24. Subroutine linkage using a link register. 1000 204 Link PC Return 1000 location Memory Calling program Memory location 200 204 Call SUB next instruction Subroutine SUB first instruction


Download ppt "1 Pertemuan 5 Bahasa Rakitan: I Matakuliah: T0324 / Arsitektur dan Organisasi Komputer Tahun: 2005 Versi: 1."

Similar presentations


Ads by Google