Mikroprosesor dan Antarmuka Tracing Instruksi · Mikroprosesor dan Antarmuka. Tracing Instruksi....
Transcript of Mikroprosesor dan Antarmuka Tracing Instruksi · Mikroprosesor dan Antarmuka. Tracing Instruksi....
Pemrograman[1]
Directives are statements that give directions to the assembler about how it should translate the assembly language instructions into machine code.
An assembly language instruction consists of four fields, [label:] mnemonic [operands] [;comments]
Brackets indicate that the field is optional. Brackets are not typed.1. The label field allows the program to refer to a line of
code by name.2. In a line of assembly language program there can be
mnemonic (instruction) and operand(s).• Ex: ADD AL,BL , MOV AX,6764H
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman[2]
3. Alternatively, instead of these two fields there can be directives. Directives are used by the assembler to organize the program as well as other output files. The following program adds two bytes to calculate their sum. In this program SEGMENT, DB, ENDS, ASSUME, END, and ENDP are examples of directives.
4. The comment field begins with a “;”
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman-contoh4.1[3]
;A Sample Assembly Language Program using FULL SEGMENT DEFINITION
STSEG SEGMENTDB 64 DUP (?)
STSEG ENDS;--------------------------------------------------DTSEG SEGMENT
DATA1 DB 52HDATA2 DB 29HSUM DB ?
DTSEG ENDS;--------------------------------------------------
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman-contoh4.1[4]
CDSEG SEGMENTMAIN PROC FAR ;This is the program entry point
ASSUME CS:CDSEG,DS:DTSEG,SS:STSEGMOV AX,DTSEG ;load the data segment addressMOV DS,AX ;assign value to DSMOV AL,DATA1 ;get the first operandMOV BL,DATA2 ;get the second operandADD AL,BL ;add the operandsMOV SUM,AL ;store result in location SUMMOV AH,4CH ;set up toINT 21H ;return to the Operating System (DOS)
MAIN ENDPCDSEG ENDS
END MAIN ;this is the program exit point
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman[5]
SIMPLIFIED SEGMENT DEFINITION An assembly language program can be written in two
segment definition formats. In addition to the Full Segment Definition Format, the recent assemblers support Simplified Segment Definition, which is simpler and easier to write.
The following program uses the Simplified Segment Definition.
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman-contoh4.2[6]
;A Sample Assembly Language Program using SIMPLIFIED SEGMENT DEFINITION
.MODEL SMALL ;Gives the memory model to be used by the program
.STACK 64;--------------------------------------------------.DATA
DATA1 DB 52HDATA2 DB 29HSUM DB ?
;--------------------------------------------------
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman-contoh4.2[7]
.CODEMAIN: MOV AX,@DATA
MOV DS,AX ;assign value to DSMOV AL,DATA1 ;get the first operandMOV BL,DATA2 ;get the second operandADD AL,BL ;add the operandsMOV SUM,AL ;store result in location SUMMOV AH,4CH ;set up toINT 21H ;return to the Operating System (DOS)END MAIN ;this is the program exit point
http://faraday.ee.emu.edu.tr/eeng410/lectures/eee410_Lecture6.pdf
Pemrograman-model memori[8]
SMALL MODEL (.MODEL SMALL): The model uses maximum of 64K bytes for Code and 64K bytes for Data (Code<=64K and Data <=64K). This model is the most widely used memory model and is sufficient for all the programs to be used in this course.
MEDIUM MODEL, (.MODEL MEDIUM): The model uses maximum of 64K bytes for Data and Code can exceed 64K bytes (Code>64K and Data <=64K).
COMPACT MODEL, (.MODEL COMPACT): The model uses maximum of 64K bytes for Code and Data can exceed 64K bytes (Code<=64K and Data >64K).
LARGE MODEL, (.MODEL LARGE): Both Code and Data can exceed 64K bytes. However no single data set (i.e. array) can exceed 64K bytes (Code>64K and Data >64K).
HUGE MODEL, (.MODEL HUGE): Both Code and Data can exceed 64K bytes. Additionally, a single data set (i.e. array) can exceed 64K bytes (Code>64K and Data >64K).
Pemrograman[9]
ASSEMBLE, LINK AND RUN A PROGRAM The following table summarizes the process required to
assemble, link and run an assembly language program. Step:1. Edit the program by using keyboard and Editor. Ex.myfile.asm2. Assemble the program myfile.asm by using MASM or TASM
myfile.obj3. Link the program myfile.obj by using LINK or TLINK myfile.exe “.asm” file is the source file created with an editor or a word
processor. “.obj” assembler (e.g.TASM) converts .asm file’s Assembly
language instructions into machine language. “.exe” TLINK is the program to produce the executable file.
Pemrograman[10]
DEBUG, is a program included in DOS operating system that allows the programmer to monitor the programs execution.
Useful commands are:-u (unassemble command is used to look et the machine code) -d (dump command displays the contents of memory to
the screen) -g (go command executes the program) -q (quits from DEBUG to DOS)
Tahap Decode [1]
Dari siklus FDX, proses yang paling rumit adalah decode Beberapa istilah : Program susunan instruksi (user) Instruksi bagian terkecil dari program (user) Mikroprogram susunan pekerjaan yang
diperintahkan Control System Mikroinstruksi pekerjaan yang diperintahkan Control
System Ada beberapa proses dilakukan yakni: Instruksi – fetch Control System Mikroprogram didekodekan
Tahap Decode-Cth.Instruksi [2]
Instruksi : ADD A,BUrutan Pendekodean:1. Opcode ADD dibawa ke
CU lalu di-decode-kan2. B (di memori) ALU3. B (di ALU) ACC 4. A (di memori) ALU5. B (di ACC) ALU 6. Eksekusi instruksi + A & B 7. Hasil ACC
ACC
Memory
A
ADD
B,Hasil
1
4
3,7
B2,5
B5
+ 6
Control System/Control Unit
/Instruction Decoder
Tahap Decode-Cth.Instruksi [3]
ACC
Memory
MOV
B
1
3
B 2
B4
Control System/Control Unit
/Instruction Decoder
Instruksi : MOV A,BUrutan Pendekodean:1. Opcode MOV dibawa ke
CU lalu di-decode-kan2. B (di memori) ALU3. B (di ALU) ACC 4. ACC A (di memori)
Tracing Instruksi [1]
Contoh sebuah program sbb: 136B:0100 BB0F00 MOV BX,000F 136B:0103 89D8 MOV AX,BX 136B:0105 8B07 MOV AX,[BX] 136B:0107 8B47FF MOV AX,[BX-01] 136B:010A A10D00 MOV AX,[000D]
Penjelasan: Perintah MOV BX,000F BX = 000F Perintah MOV AX,BX AX = BX Perintah MOV AX,[BX] AL = [DS:BX]
AH = [DS:BX+1]
Tracing Instruksi- [2]Alamat Code Program IP AX BX
100 0000 0000
CS:100 BB FC 00 MOV BX,00FC 103 0000 00FC
CS:103 B8 FF 00 MOV AX,00FF 106106106
00FF000200FF000100FF
00FC00FD00FE
CS:106 43 INC BX 107107107
00FF00FF00FF
00FD00FE00FF
CS:107 31 D8 XOR AX,BX 109109109
000200010000
00FD00FE00FF
CS:109 75 F8 JNZ 103 10310310B
000200010000
00FD00FE00FF
CS:10B 89 D8 MOV AX,BX 10D 00FF 00FF
Perhitungan Timing-contoh[1]
Contoh:Program input data ke AL setiap 75 mikrodetik = (75 us x 1 MHz) = 75 clock NOP : 2 clock IN : 10 clock JMP : 15 clock Clock : 1 MHz
Penjelasan: LOOP: IN COM1 10
NOP(25x) 50JMP LOOP 15
Perhitungan Timing-contoh[2]
Contoh 4.3:Sebuah program sbb: MOV BX,00FC 4 clock LOOP: MOV AX,00FF 4 clock INC BX 3 clock XOR AX,BX 3 clock JNZ LOOP 4/16 clock MOV AX,BX 2 clock
Berapa clock yang dibutuhkan program ini? Penjelasan:
penjelasan di slide berikutnya
Perhitungan Timing-contoh[3]Label AX BX Clock
0000 00FC 4LOOP 00FF 00FC 4
00FF 00FD 30002 00FD 30002 00FD 16
LOOP 00FF 00FD 400FF 00FE 30001 00FE 30001 00FE 16
LOOP 00FF 00FE 400FF 00FF 30000 00FF 30000 00FF 400FF 00FF 2
TOTAL 72
LOGO
Thank You!Please study this subject at home