Top Banner
Andrian Rakhmatsyah
23

Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Mar 07, 2018

Download

Documents

truongxuyen
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Andrian Rakhmatsyah

Page 2: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Pendahuluan (1)

A

B C

D E F

H L

PC

SP

Page 3: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Pendahuluan (2)

Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor 8085

SAP-3 lebih berfokus pada model pemrograman

Memiliki register tambahan, selain yang terdapat

pada SAP-2 yaitu register D, E, H dan L.

Register tambahan berfungsi untuk pemrosesan data yang lebih efisien dan memudahkan dalam pemrogramannya.

Register stack pointer (SP), register 16-bit berfungsi untuk mengendalikan bagian di memori yang disebut STACK

Page 4: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Register Flag Register F (Flag) berfungsi untuk menyimpan bit-bit flag

pengaruh dari beberapa instruksi SAP-3. Yaitu bit Sign (S), Zero (Z), Parity (P), Carry (CY)

Sign : A < 0 S = 1, A ≥ 0 S = 0 Zero : A = 0 Z = 1, A ≠ 0 Z = 0 Parity : Σ bit di A = Genap P = 1, else P = 0 Carry : C = 1, jika operasi ALU overflow, else C = 0 Pada instruksi SUB, Flag CY disebut Borrow Pada instruksi ADD, Flag CY disebut Carry

S Z 0 0 0 P 0 CY

Page 5: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi MOV dan MVI Sama seperti pada SAP-2

Jumlah register lebih banyak

reg : A, B, C, D, E, H, dan L

Format

MOV reg1, reg2

MVI reg, byte

Contoh,

MOV A, A ; A A

Page 6: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Aritmatika (1)

Instruksi Carry-Flag

STC (set carry)

akan membuat CY = 1

CMC (complement the carry)

akan mereset CY

Contoh, kondisi CY tidak diketahui.

STC

CMC

Hasil akhir, CY = 0

Page 7: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Aritmatika (2)

Instruksi ADD

Format

ADD reg reg : A, B, C, D, E, H, dan L

Instruksi ADC

Instruksi ADD dengan melibatkan Carry

Format

ADC reg reg : A, B, C, D, E, H, dan L

Contoh, CY = 1; A = 1000 0011; E = 0001 0010

Hasil akhir dari instruksi : ADC E

1000 0011 A = 1001 00110

0001 0010 E = 0001 0010

1+ CY = 1

1001 0110

Page 8: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Aritmatika (3)

Instruksi ADI Instruksi penjumlahan byte dengan reg A Format ADI byte ; A A + byte

Instruksi ACI Instruksi ADI dengan melibatkan Carry Format ACI byte Contoh, CY = 1; A = 1000 0011; byte = 0001 0010 Hasil akhir dari instruksi : ACI 12h 1000 0011 A = 1001 00110 0001 0010 byte = 0001 0010 1+ CY = 1 1001 0110

Page 9: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Aritmatika (4)

Instruksi SUB Format SUB reg reg : A, B, C, D, E, H, dan L

Instruksi SBB Instruksi SUB dengan melibatkan Borrow Format SBB reg reg : A, B, C, D, E, H, dan L Contoh, CY = 1; A = 1111 1111; E = 0000 0010 Hasil akhir dari instruksi : SBB E 0000 00 1 0 E 1+ CY + 0000 0011 1 1 1 1 1 1 1 1 A = 1111 1100 0000 001 1 - E = 0000 0010 1 1 1 1 1 1 0 0

Page 10: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Aritmatika (5)

Instruksi SUI Instruksi Pengurangan register A dengan byte Format SUI byte ; A A - byte

Instruksi SBI Instruksi SUI dengan melibatkan Borrow Format SBI byte Contoh, CY = 1; A = 1111 1111; byte = 0000 0010 Hasil akhir dari instruksi : SBI 02h 0000 00 1 0 byte 1+ CY + 0000 0011 1 1 1 1 1 1 1 1 A = 1111 1100 0000 001 1 - byte + CY = 0000 0010 1 1 1 1 1 1 0 0

Page 11: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Contoh (1)

Buatlah program untuk menjumlahkan bilangan desimal 700 dengan 900 !

Jawab

700 = 02BCH = 0000 0010 1011 11002

900 = 0384H = 0000 0011 1000 01002

Bilangan 700 dan 900 membutuhkan lebih dari 1-byte

Sehingga bilangan tersebut di-’pisahkan’ menjadi dua bagian 8-bit LSB dan 8-bit MSB

700 = 02BCH = 0000 0010 1011 11002

Reg B = 02h C = BCh

900 = 0384H = 0000 0011 1000 01002

Reg D = 03h E = 84h

Page 12: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Contoh (2)

700 = 02BCh = 0000 0010 1011 11002

900 = 0384h = 0000 0011 1000 01002

0640h = 0000 0110 0100 0002

C = BCh = 1011 11002 B = 02h 0000 00102

E = 84h = 1000 01002 D = 03h 0000 00112

140h 1 0100 00002 CY = 01h 12

0000 01102

Page 13: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Contoh (3)

Label Instruksi Komentar MVI A, 00h ; A 0 (Inisialisasi) MVI B, 02h ; Up Byte dari 700 MVI C, BCh ; Lower Byte dari 700 MVI D, 03h ; Up Byte dari 900 MVI E, 84h ; Lower Byte dari 900 ADD C ; A 00h + BCh = BCh ADD E ; A BCh + 84h = 40h ; CY = 1 MOV L, A ; L 40h MVI A, 00h ; A 00h (inisialisasi) ADC B ; A A + B + CY ADD D ; A A + D MOV H, A ; H A HLT ; Selesai

Page 14: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Contoh (4)

Label Instruksi Komentar

MVI A, 84h ; A Lower Byte dari 900

SUI BCh ; A A – Lower byte dari 700

MOV L, A ; L 40h

MVI A, 03h ; A Upper Byte dari 900

SBI 02h ; A A – Upper Byte dari 700 - CY

MOV H, A ; H A

HLT ; Selesai

Page 15: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Increment, Decrement, dan Rotate (1)

INR INR reg; reg = A, B, C, D, E, H, L

DCR DCR reg; reg = A, B, C, D, E, H, L

Andrian Rakhmatsyah 15

Page 16: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Increment, Decrement, dan Rotate (2)

RAL, mnemonik dari rotate the accumulator left yaitu menggeser semua bit ke kiri termasuk CY

RAR, mnemonik dari rotate the accumulator right yaitu menggeser semua bit ke kiri termasuk CY

Andrian Rakhmatsyah 16

MSB RAL LSB

MSB RAR LSB

CY

CY

Page 17: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Increment, Decrement, dan Rotate (3)

RAL RAR

Andrian Rakhmatsyah 17

0111 0100 1

1110 1001 0

0111 0100 1

1011 1010 0

Page 18: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Increment, Decrement, dan Rotate (4)

Instruksi RLC (Rotate Left with Carry)

Bit CY, tidak diikutsertakan dalam perpindahannya

Instruksi RRC (Rotate Right with Carry)

Bit CY, tidak diikutsertakan dalam perpindahannya

MSB RAL LSB CY

MSB RAR LSB CY

Page 19: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Increment, Decrement, dan Rotate (5)

Jika CY = 0:

RLC satu posisi = perkalian dengan 2

RLC dua posisi = perkalian dengan 4

dst

RRC satu posisi = pembagian dengan 2

RRC dua posisi = pembagian dengan 4

dst

Page 20: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Logika Selain instruksi yang ada di SAP-2 (ANA, ORA, XRA,

CMA, dsb), di SAP-3 terdapat tambahan instruksi yaitu Tambahan register, reg : A, B, C, D, E, H dan L Intruksi CMP reg ; (compare) membandingkan isi

reg. A dengan isi reg tertentu. Flags yang berpengaruh yaitu pada Z-bit Z = 1, if A = reg Z = 0, if A ≠ reg

Intruksi CPI byte ; (compare) membandingkan isi reg. A dengan byte tertentu. Flags yang berpengaruh yaitu pada Z-bit

Page 21: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Aritmatika dan Logika Immediate SAP-2

ANI byte ORI byte XRI byte

SAP-3 ADI byte ACI byte SUI byte SBI byte CPI byte

Page 22: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Instruksi Jump Selain instruksi Jump pada SAP-2

JMP address; JM address; JZ address; JNZ address

pada SAP-3 terdapat tambahan instruksi jump sesuai dengan kondisi Flags Register

JP address ; Lompat jika S = 0

JC address ; Lompat jika CY = 1

JNC address ; Lompat jika CY = 0

JPE address ; Lompat jika P = 1

JPO address ; Lompat jika P = 0

Page 23: Simple As Possible #3 - Telkom Universitycdndata.telkomuniversity.ac.id/pjj/14152/CSG2G3/END/COURSE... · Pendahuluan (2) Mikrokomputer 8-bit yang kompatibel dengan mikroprocessor

Referensi:

23

Malvino, Albert Paul; Jerald A. Brown. 1999. “Digital Computer Electronics”.3rd edition. McGraw-Hill. New York