1 / 11

Pertemuan 5 Bahasa Rakitan: I

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 ).

olinda
Télécharger la présentation

Pertemuan 5 Bahasa Rakitan: I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Chapter 2. Assembly Language: I

  4. 100 Move N,R1 104 Move #NUM1,R2 108 Clear R0 LOOP 112 Add (R2),R0 116 Add #4,R2 120 Decrement R1 124 Branch>0 LOOP 128 Move R0,SUM 132 SUM 200 N 204 100 NUM1 208 NUM2 212 NUM n 604 Figure 2.17. Memory arrangement for the program in Figure 2.12.

  5. Memory Addressing address or data lab el Op eration information Assem bler directiv es SUM EQU 200 ORIGIN 204 N D A T A W ORD 100 NUM1 RESER VE 400 ORIGIN 100 Statemen ts that ST AR T MO VE N,R1 generate MO VE #NUM1,R2 mac hine CLR R0 instructions LOOP ADD (R2),R0 ADD #4,R2 DEC R1 BGTZ LOOP MO VE R0,SUM Assem bler directiv es RETURN END ST AR T Figure 2.18. Assembly language representation for the program in Figure 2.17.

  6. Mo v e #LOC,R0 Initialize p oin ter register R0 to p oin t to the address of the first lo cation in memory where the c haracters are to b e stored. READ T estBit #3,INST A TUS W ait for a c haracter to b e en tered Branc h=0 READ in the k eyb oard buffer D A T AIN. Mo v eByte D A T AIN,(R0) T ransfer the c haracter from D A T AIN in to the memory (this clears SIN to 0). ECHO T estBit #3,OUTST A TUS W ait for the displa y to b ecome ready . Branc h=0 ECHO Mo v eByte (R0),D A T A OUT Mo v e the c haracter just read to the displa y buffer register (this clears SOUT to 0). Compare #CR,(R0)+ Chec k if the c haracter just read is CR (carriage return). If it is not CR, then Branc h READ branc h bac k and read another c haracter. 0 Also, incremen t the p oin ter to store the next c haracter. Figure 2.20. A program that reads a line of characters and displays it.

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

  8. SP 19 - 28 - 28 17 SP 17 739 739 Stack • • • • • • 43 43 NEWITEM 19 ITEM - 28 (a) After push from NEWITEM (b) After pop into ITEM Figure 2.22. Effect of stack operations on the stack in Figure 2.21.

  9. SAFEPOP Compare #2000,SP Chec k to see if the stac k p oin ter con tains Branc h > 0 EMPTYERR OR an address v alue greater than 2000. If it do es, the stac k is empt y . Branc h to the routine EMPTYERR OR for appropriate action. Mo v e (SP)+,ITEM Otherwise, p op the top of the stac k in to memory lo cation ITEM. (a) Routine for a safe pop operation SAFEPUSH Compare #1500,SP Chec k to see if the stac k p oin ter  Branc h 0 FULLERR OR con tains an address v alue equal to or less than 1500. If it do es, the stac k is full. Branc h to the routine FULLERR OR for appropriate action. – Mo v e NEWITEM, (SP) Otherwise, push the elemen t in memory lo cation NEWITEM on to the stac k. (b) Routine for a safe push operation Figure 2.23. Checking for empty and full errors in pop and push operations.

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

More Related