Matakuliah Tahun Versi : T0324 / Arsitektur dan Organisasi Komputer : 2005 :1 Pertemuan 3 Instruksi Mesin dan Program: I 1 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • Menjelaskan prinsip kerja instruksi mesin dan konsep representasi bilangan ( C2 ) ( No TIK : 2 ) 2 Chapter 2. Numbers, Arithmetic Operations, and Characters 3 B Values represented b3 b2b1b0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 Sign and magnitude 1's complement +7 +6 +5 +4 +3 +2 +1 +0 - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 +7 +6 +5 +4 +3 +2 +1 +0 -7 -6 -5 -4 -3 -2 - 1 -0 2's complement + + + + + + + + - 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 Figure 2.1. Binary, signed-integer representations. 4 0 + 0 0 1 + 0 1 0 + 1 1 + 1 1 10 Carry-out Figure 2.2. Addition of 1-bit numbers. 5 N - 1 0 1 N - 2 2 (a) Circle representation of integers mod N 0000 1111 1110 1101 - 2 - 3 -1 0 0001 +1 - 4 1100 1011 - 5 - 6 1010 0010 + 2 + 3 0011 + 4 - 7 - 8 + 7 + 5 + 6 0100 0101 0110 1001 0111 1000 (b) Mod 16 system for 2's-complement numbers Figure 2.3. Modular number systems and the 2's-complement system. 6 (a) (c) (e) 0010 + 0011 ( + 2) ( + 3) 0101 1011 + 1110 1001 1101 - 1001 ( + 5) (- 5 ) ( - 2) ( - 7) (f) (g) (h) - 0010 0100 0110 0011 1001 1011 (- 3 ) (- 7 ) ( + 2) ( + 4) ( + 6) ( + 3) ( - 7) ( - 5) (b) (d) 0100 + 1010 1110 0111 + 1101 0100 1101 + 0111 0100 0010 + 1100 1110 0110 + 1101 0011 1001 + 0101 1110 (i) (j) - 1001 0001 0010 1101 (- 7 ) ( + 1) ( + 2) ( - 3) 1001 + 1111 1000 0010 + 0011 0101 ( + 4) (- 6 ) (- 2 ) ( + 7) ( - 3) ( + 4) ( + 4) ( - 2) ( + 3) ( - 2) ( - 8) ( + 5) Figure 2.4. 2's-complement Add and Subtract operations. 7 B Values represented b3 b2b1b0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 Sign and magnitude 1's complement +7 +6 +5 +4 +3 +2 +1 +0 - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 +7 +6 +5 +4 +3 +2 +1 +0 -7 -6 -5 -4 -3 -2 - 1 -0 2's complement + + + + + + + + - 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 8 (a) (c) (e) 0010 + 0011 ( + 2) ( + 3) 0101 1011 + 1110 1001 1101 - 1001 ( + 5) (- 5 ) ( - 2) ( - 7) (f) (g) (h) (i) (j) - 0010 0100 0110 0011 1001 1011 1001 0001 0010 1101 (- 3 ) (- 7 ) ( + 2) ( + 4) ( + 6) ( + 3) ( - 7) ( - 5) (- 7 ) ( + 1) ( + 2) ( - 3) (b) (d) 0100 + 1010 1110 0111 + 1101 0100 1101 + 0111 0100 0010 + 1100 1110 0110 + 1101 0011 1001 + 0101 1110 1001 + 1111 1000 0010 + 0011 0101 ( + 4) (- 6 ) (- 2 ) ( + 7) ( - 3) ( + 4) ( + 4) ( - 2) ( + 3) ( - 2) ( - 8) ( + 5) Figure 2.4. 2's-complement Add and Subtract operations. 9 n bits first word second word • • • i th word • • • last word Figure 2.5. Memory words. 10 Address Begin execution here i i +4 i +8 Contents Move Add Move A,R0 B,R0 R0,C 3-instruction program segment A B Data for the program C Figure 2.8. A program for C [A] + [B]. A simple program doing the basic arithmetic expression C = A + B; Note the simple instructions: Move and Add and that data is stored with the instructions. 11 Move Clear LOOP Program loop N,R1 R0 Determine address of "Next" number and add "Next" number to R0 Decrement Branch>0 Move SUM N NUM1 NUM2 NUM n R1 LOOP R0,SUM • • • n • • • A branch or looping program. Two new instructions Branch and Decrement. 12
© Copyright 2026 Paperzz