60 likes | 183 Views
NILAI OPERAND: Address vs. Data. Jenis-jenis Operand. Format Instruksi: OP-CODE DEST,SRC DEST (Destination Operand): Register Operand: operand menunjuk ke register tujuan EAX, EBX, ... Memory Operand: operand menunjuk ke alamat lokasi memori tujuan [LABEL]
E N D
NILAI OPERAND: Address vs. Data
Jenis-jenis Operand • Format Instruksi: • OP-CODE DEST,SRC • DEST (Destination Operand): • Register Operand: operand menunjuk ke register tujuan • EAX, EBX, ... • Memory Operand: operand menunjuk ke alamat lokasi memori tujuan • [LABEL] • [REG], [R-base+Scale*R-index+Displacement] • SRC (Source Operand): • Register Operand: operand menunjuk register, tempat data sumber • Memory Operand: operand menunjuk alamat lokasi memori, tempat data sumber • Immediate Operand: data sumber berupa konstanta • NAMA, LABEL, Konstanta
Nilai Sebuah Operand • Konstanta dapat dideklarasikan terlebih dahulu: • const equ 3 • Data harus dideklarasikan terlebih dahulu: • var_a dd 0x234 • Nilai Immediate Operand • mov ecx,8 ; ecx 8 • mov ecx,const ; ecx 3 (nilai yang direpresentasikan oleh const) • mov esi,var_a ; esi alamat lokasi memori yang direpresentasikan ; oleh var_a, dimana 0x234 disimpan • Nilai Memory Operand • mov eax,[var_a] ; eax 0x234 (data yang disimpan di lokasi memori ; yang alamatnya direpresentasikan oleh var_a) • mov eax,[esi] ; eax [[esi]] ; [esi] = alamat lokasi memori tempat data disimpanmov [esi],eax ; [esi] [eax] ; [esi] = alamat lokasi memori tujuan • Nilai Register Operand • add eax,ebx ; eax [eax] + [ebx]
Register Transfer Notation (RTN) • Digunakan untuk menggambarkan proses pertukaran data yang terjadi pada eksekusi sebuah instruksi: • DEST SRC1 OP SRC2 • OP: ‘+’, ‘-’, … • DEST: alamat tujuan sebagai tempat penyimpanan hasil operasi • MOV EAX,EBX ; EAX [EBX] ; alamat tujuan: register EAX • MOV [ESI],EAX ; [ESI] EAX ; alamat tujuan: alamat lokasi memori yang ditunjuk oleh ; register ESI • MOV [VAR_A],EAX ; VAR_A [EAX] ; alamat tujuan: alamat lokasi memori yang direpresentasikan ; oleh VAR_A • SRC: data yang akan dioperasikan • MOV EAX,EBX ; EAX [EBX] ; data: isi register EBX • MOV EAX,[ESI] ; EAX [[ESI]] ; data: isi lokasi memori yang alamatnya ditunjuk oleh register ; ESI • MOV EAX,[VAR_A] ; EAX [VAR_A] ; data: isi lokasi memori yang alamatnya direpresentasikan ; oleh VAR_A
Contoh Interpretasi Nilai Operand 92d0:01 00 00 00 92d4: 02 00 00 00 92d8:00 00 00 00 15c0: push eax 15c1: mov ecx,0x3 ... 15c8: mov eax,[0x92d0] 15cd: mov ebx,[0x92d4] 15d3: mov esi,0x92d8 15d8: addeax,ebx 15da: mov [0x92d8],eax ... 15de: pop eax const equ 3 segment .data var_add 1 var_bdd 2 var_cdd 0 ... segment .text global _main _main: push eax mov ecx,const ... mov eax,[var_a] mov ebx,[var_b] mov esi,var_c add eax,ebx mov [esi],eax ... pop eax