Pelajari program tersebut, lalu isilah berapa nilai data yang seharusnya ada pada R03 jika program tersebut selesai dijalankan
R03 =
Sekarang pastikan tidak ada centang pada opsi No Instruction Pipeline dan opsi Do Not Insert Bubbles pada layar Instruction Pipeline (gambar 18) kemudian jalankan program tersebut. Amatilah berapa nilai data yang ada pada R03 !
R03 =
Sekarang sisipkan set instruksi NOP pada program tersebut sehingga program anda tamapak seperti di bawah ini MOV #1, R01 MOV #5, R03 MOV #3, R01 NOP ADD R01, R03 HLT
Reset program anda lalu jalankan lagi dengan konfigurasi yang sama seperti di atas (tidak ada centang pada opsi No Instruction Pipeline dan opsi Do Not Insert Bubbles). Amatilah nilai data yang ada pada R03 sekarang !
R03 =
Dari hasil pengamatan anda di atas, simpulkan apa yang menyebabkan perbedaan nilai pada R03 di atas !
Bubbles. Reset program anda, lalu jalankan kembali. Amatilah berapa nilai data yang ada pada R03 sekarang !
R03 =
Berikanlah kesimpulan dari hasil pengamatan anda tersebut kenapa nilai pada R03 sekarang sama dengan nilai yang ada pada saat program dengan set instruksi NOP dijalankan !
Pada layar Instruction Pipeline, amatilah Bubble yang muncul ! Apa warna dari Bubble tersebut ? apa kegunaannya ?
Amatilah sekali lagi layar Instruction Pipeline kemudian isilah tabel di bawah ini ! CPI (Clocks Per Instruction)
SF (Speed Factor)
4.3. Sekarang kita akan mempelajari metode Operand Forwarding yang ada pada proses Pipeline dalam komputer. Untuk melakukan hal ini, berilah centang pada opsi Enable Operand Forwarding yang ada pada layar Instruction Pipeline seperti pada gambar 18. Reset program anda yang ada pada prosedur percobaan 4.2. kemudian jalankan lagi. Amatilah apakah ada Bubble yang timbul pada proses Pipeline !
Simulator akan menghitung jumlah dependency (dalam hal ini adalah Data Hazard) yang dideteksinya setiap sebuah set instruksi mengalami proses Pipeline. Amatilah hasil percobaan anda dan isilah tabel di bawah ini !
CPI (Clocks Per Instruction) SF (Speed Factor)
Data Hazards
Compiler seperti pada gambar 11. Buat program seperti di bawah ini program Ex4_1 for n = 1 to 8 t = t + 1 next end
Kemudian, pada layar Compiler, klik tab Optimize yang ada pada bagian bawah, lalu berilah centang pada opsi Enable Optimizer dan pilihlah opsi Redundant Code (dilakukan dengan cara memberi centang pada opsi yang diinginkan). Compile program tersebut ! Amatilah Code Size hasil dari proses compile ! (dapat dilihat pada Code Size yang ada di Assembly Code Tab bagian kanan bawah dari layar Compiler)
Code Size =
Sekarang lakukan Load In Memory untuk program Ex4_1 anda.
Berikutnya pilihlah opsi Loop Unrolling pada Enable Optimizer anda (dilakukan dengan cara yang sama seperti Redundant Code di atas, yaitu dengan memberi centang pada opsi Loop Unrolling), lalu rubah nama program anda menjadi program Ex4_2, lakukan proses Compile dan Load In Memory program Ex4_2 tersebut sehingga akan ada dua versi program pada layar utama CPU-OS Simulator anda (gambar 1). Amati berapa Code Size dari program Ex4_2 anda !
Code Size =
Buka layar Instruction Pipeline seperti pada gambar 18. Hilangkan centang (jika ada) pada opsi Enable Operand Forwarding dan opsi Enable Jump Prediction, lalu pilih program Ex4_1 pada layar utama CPU-OS Simulator. Klik Reset Program, lalu jalankan program Ex4_1 tersebut. Amatilah apa yang terjadi pada layar Instruction Pipeline kemudian isilah tabel di bawah ini
CPI (Clocks Per Instruction) SF (Speed Factor)
No of Instruction Executed
Lakukan hal yang sama seperti di atas tetapi kali ini untuk program Ex4_2, lalu isilah tabel di bawah ini CPI (Clocks Per Instruction)
SF (Speed Factor)
No of Instruction Executed
Dari hasil pengamatan anda dan mengacu kepada Code Size dan No of Instruction Executed, berilah kesimpulan !
pada proses Pipeline menggunakan Compiler. Sekarang anda akan mengamati cara lain menggunakan Compiler untuk mengatasi dependency pada proses Pipeline. Hilangkan tanda centang pada opsi Show Dependencies di Options Tab layar Compiler anda (gambar 11) dan pilihlah hanya opsi Redundant Code (dengan cara memberi centang) pada Optimize Tab di layar Compiler kemudian buat program seperti di bawah ini
program Ex5_1 a = 1
b = a c = 2 end
Lakukan proses Compile, amatilah set instruksi yang terbentuk lalu tuliskan hasilnya !
Sekarang, pilihlah opsi Code Dependencies (berilah tanda centang). Rubah nama program menjadi program Ex5_2, lakukan proses Compile dan Load In Memory.
Amatilah set instruksi yang terbentuk lalu tuliskan hasilnya !
Apa perbedaan yang timbul dari hasil Compile kedua program tersebut ? Apa pengaruh perbedaan tersebut terhadap algoritma program ? Jelaskan !
Modifikasi program anda menjadi seperti di bawah ini
program Ex5_3 for n = 1 to 50 a = 1 b = a c = 2 next end
Code Dependencies (tanpa centang), yang satu lagi dengan opsi Code Dependencies (memberi centang) dengan nama program Ex5_4. Jalankan program Ex5_3, amati, lalu isi tabel di bawah ini
CPI (Clocks Per Instruction) SF (Speed Factor)
Sekarang jalankan program Ex5_4, amati, lalu isi tabel di bawah ini CPI (Clocks Per Instruction)
SF (Speed Factor)
Apa yang anda dapat dari hasil pengamatan kedua program di atas ? Berikan kesimpulan !
4.6. Sekarang kita akan mempelajari cara lain untuk mengatasi dependencies pada prose Pipeline, yaitu dengan menggunakan metode Jump Prediction. Buat program seperti di bawah ini
program Ex6 i = 0 for p = 1 to 40 i = i + 1 if i = 10 then i = 0 r = i end if next end
Lakukan proses Compile dan Load In Memory dengan hanya memilih opsi Enable Optimizer dan opsi Remove Redundant Code (dengan cara memberi centang). Jalankan program, amati layar Instruction Pipeline kemudian isilah tabel di bawah ini
CPI (Clocks Per Instruction) SF (Speed Factor)
Sekarang pilih opsi Enable Jump Prediction pada layar Instruction Pipeline (gambar 18), reset program anda, lalu jalankan lagi. Amati layar Instruction Pipeline, lalu isilah tabel di bawah ini
CPI (Clocks Per Instruction) SF (Speed Factor)
yang muncul ! Perkirakan apa arti masing-masing kolom yang ada pada tabel tersebut dan berilah masukan anda ! V JlnstAddr JTarget PStat Count
Window)
program OSQueuesDemo %Start of program
while true %Forever loop
for n = 1 to 15 %Repeat 15 times
i = 1 %Just something to do!
next %End of repeat loop
wait(3) %Suspend program for 3 secs
wend %End of forever loop
end %End of program
program WaitOnReadDemo
regvar d integer %Keep input in a register while true
for n = 1 to 15 %This loop keeps CPU busy
i = 1 %Just something to do!
next
write("> ") %Display this prompt
read(d) %Wait for keyboard input
writeln(d) %Display input character if d = 42 then %Test if end of program
break %End program if a * character end if
wend end
program ForeverLooping
while true %Do a forever loop
n = 1 %Does nothing useful but
wend %keeps the CPU busy
Instruction Description Data Transfer Instructions
MOV
Move data to register; move register to register e.g.
MOV #2, R01 moves number 2 into register R01
MOV R01, R03 moves contents of register R01 into register R03 LDB Load a byte from memory to register
LDW Load a word (2 bytes) from memory to register STB Store a byte from register to memory
STW Store a word (2 bytes) from register to memory
PSH
Push data to top of hardware stack (TOS); push register to TOS e.g.
PSH #6 pushes number 6 on top of the stack
PSH R03 pushes the contents of register R03 on top of the stack
POP
Pop data from top of hardware stack to register e.g.
POP R05 pops contents of top of stack into register R05
Note: If you try to POP from an empty stack you will get the error message “Stack overflow”.
Arithmetic Instructions
ADD
Add number to register; add register to register e.g.
ADD #3, R02 adds number 3 to contents of register R02 and stores the result in register R02.
ADD R00, R01 adds contents of register R00 to contents of register R01 and stores the result in register R01.
SUB Subtract number from register; subtract register from register MUL Multiply number with register; multiply register with register DIV Divide number with register; divide register with register Control Transfer Instructions
JMP Jump to instruction address unconditionally e.g. JMP 100 unconditionally jumps to address location 100
JGT Jump to instruction address if greater than (after last comparison)
JEQ
Jump to instruction address if equal (after last comparison instruction)
e.g.
JEQ 200 jumps to address location 200 if the previous comparison instruction result indicates that the two numbers are equal, i.e. the Z status flag is set (the Z box will be checked in this case).
JNE Jump to instruction address if not equal (after last comparison) CAL Jump to subroutine address
RET Return from subroutine
SWI Software interrupt (used to request OS help)
HLT Halt simulation
Comparison Instructions
CMP
Compare number with register; compare register with register e.g.
CMP #5, R02 compare number 5 with the contents of register R02 CMP R01, R03 compare the contents of registers R01 and R03 Note:
If R01 = R03 then the status flag Z will be set, i.e. the Z box is checked.
If R03 > R01 then non of the status flags will be set, i.e. none of the status flag boxes are checked.
If R01 > R03 then the status flag N will be set, i.e. the N status box is checked.
Input Output Instructions
IN Get input data (if available) from an external IO device OUT Output data to an external IO device
Stallings, William. Computer Organisation And Architectures. 8th Edition. Prentice Hall. 2010. Stallings, William. Operating Systems. 5th Edition. Prentice Hall. 2008.