130 likes | 283 Views
Praktikum Organisasi Komputer (Jump). Departemen Ilmu Komputer FMIPA IPB 2006. Conditional Jump Instruction. A conditional jump instruction transfer control to a destination address when a flag condition is true J cond destination
E N D
Praktikum Organisasi Komputer (Jump) Departemen Ilmu Komputer FMIPA IPB 2006
Conditional Jump Instruction • A conditional jump instruction transfer control to a destination address when a flag condition is true Jcond destination • Destination address must be -128 to +127 bytes from the current location • Cond refer to flag condition, identifying the state of one or more flag
flags are set by arithmetic, comparison, and boolean instruction. Each conditional jump instruction checks one or more flags, returning a result true or false. If the result is TRUE, otherwise, the program does nothing and continue to the next instruction.
cmp ax, bx ; compare ax, bx je equal not equal : ; continue here if ax <> bx . . jmp exit equal : ; jump here if ax = bx ... exit : ; always end up here
Case 1 : AX = 5 and BX = 5 • Case 2 : AX = 5 and BX = 5
Example 1 : larger of two number • We might want to compare unsigned value in AX and BX and move the larger one to DX
-a 100 13A1:0100 mov ax,50 13A1:0103 mov dx,ax 13A1:0105 mov bx,60 13A1:0108 cmp ax,bx 13A1:010A jae 10E 13A1:010C mov dx,bx 13A1:010E int 20 13A1:0110
-a 100 13A1:0100 mov ax,50 13A1:0103 mov dx,ax 13A1:0105 mov bx,10 13A1:0108 cmp ax,bx 13A1:010A jae 10e 13A1:010C mov dx,bx 13A1:010E int 20 13A1:0110
Latihan 1 • After the following instruction are executed, what will be the values of AL and BL ? -a 100 13A1:0100 mov al,6B 13A1:0102 mov bl,3F 13A1:0104 and ax,0FB6 13A1:0107 cmp al,bl 13A1:0109 ja 10F 13A1:010B mov al,bl 13A1:010D jmp 111 13A1:010F mov bl,al 13A1:0111 int 20 13A1:0113
Latihan 2 • After the following instruction are executed, what will be the values of AL and BL ? -a 100 13A1:0100 mov al,3F 13A1:0102 mov bl,6B 13A1:0104 or bl,0F 13A1:0107 sub al,bl 13A1:0109 jb 10F 13A1:010B mov al,1 13A1:010D jmp 111 13A1:010F mov bl,1 13A1:0111 int 20 13A1:0113
Tugas • Buat Program yang Membendingkan 3 bilangan di register al, bl, cl mana yang merupakan bilangan terkecil. Hasilnya di simpan dalam alamat 150, 151, 152 secara berurut mulai dari yang terkecil • Nilai awal dari al, bl, cl secara berurut adalah 27, 3, 11 • hasil di print screen berserta nama, nama kelompok dan nrp pada alamat 160(nama), 170(nama kelompok), • 180 (nrp) • Hint :Gunakan fungsi cmp dan jump