Machine Instructions and Programs

Machine Instructions and Programs - Chapter 2 B b3 b2b1b0 0...

Info iconThis preview shows pages 1–18. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 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 1 + 1 - 2 + 3 + 4 + 5 + 6 + 7 + 2 - 3 - 4 - 5 - 6 - 7 - 8 - 0 + 0 - 1 + 2 + 3 + 4 + 5 + 6 + 7 + 0 + 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0 - 1 + 2 + 3 + 4 + 5 + 6 + 7 + 0 + 7 - 6 - 5 - 4 - 3 - 2 - 1 - b 3 b 2 b 1 b 0 Sign and magnitude 1's complement 2's complement B Values represented Figure 2.1. Binary, signed-integer representations.
Background image of page 2
Figure 2.2. Addition of 1-bit numbers. Carry-out 1 1 + 0 1 1 0 1 + 0 0 0 + 1 0 1 +
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
N 2 - N 1 - 0 1 2 (a) Circle representation of integers mod  N 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 1 + 1 - 2 + 3 + 4 + 5 + 6 + 7 + 2 - 3 - 4 - 5 - 6 - 7 - 8 - 0 (b) Mod 16 system for 2 ' s-complement numbers Figure 2.3. Modular number systems and the 2's-complement system.
Background image of page 4
1 0 1 1 1 1 1 0 1 0 0 1 1 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 0 0 1 0 0 0 1 0 0 1 0 1 1 0 1 1 1 1 0 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 1 5 - ( 29 2 + ( ) 3 + ( ) 5 + ( ) 2 + ( ) 4 + ( ) 2 - ( 29 7 - ( 29 3 - ( 29 7 - ( 29 6 + ( ) 3 + ( ) 1 + ( ) 7 - ( 29 5 - ( 29 7 - ( 29 2 + ( ) 3 - ( 29 6 - ( 29 2 - ( 29 4 + ( ) 3 - ( 29 4 + ( ) 7 + ( ) 4 + ( ) 2 - ( 29 3 + ( ) 2 - ( 29 8 - ( 29 5 + ( ) + + + + + + + + + + - - - - - - (a) (c) (b) (d) (e) (f) (g) (h) (i) (j) Figure 2.4. 2's-complement Add and Subtract operations.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
0010 (+2) + 0011 (+3) 0101 (+5)
Background image of page 6
0100 (+4) + 1010 (- 6) 1110 (- 2)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1101 (- 3) - 1001 (- 7) 1101 (- 3) + 0111 (- -7) 0100 (+4) for subtraction, replace subtrahend with its 2’s complement
Background image of page 8
second word first word Figure 2.5. Memory words. n bits last word i th word
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Figure 2.6. Examples of encoded information in a 32-bit word. (b) Four characters character character character character (a) A signed integer Sign bit: for positive numbers for negative numbers ASCII ASCII ASCII ASCII 32 bits 8 bits 8 bits 8 bits 8 bits b 31 b 30 b 1 b 0 b 31 0 = b 31 1 =
Background image of page 10
2 k 4 - 2 k 3 - 2 k 2 - 2 k 1 - 2 k 4 - 2 k 4 - 0 1 2 3 4 5 6 7 0 0 4 2 k 1 - 2 k 2 - 2 k 3 - 2 k 4 - 3 2 1 0 7 6 5 4 Byte address Byte address (a) Big-endian assignment (b) Little-endian assignment 4 Word address Figure 2.7. Byte and word addressing.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Register Transfer Notation [ ] means “content of” [R2] means “content of register R2” [A] means “content of memory location A” means “transfer content” R1 [R2] means “transfer content of register R2 to register R1”
Background image of page 12
Register Transfer Notation R1 [LOC] Transfer the content of memory location LOC to register R1 R3 [R1] + [R2] Sum the contents of registers R1 and R2 and transfer the result to R3
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Assembly Language Notation MOVE LOC, R1 ADD R1, R2 SUB R1, R2, R3 Mnemonic op codes Symbolic addresses
Background image of page 14
R0, C B, R0 A, R0 Move i + 8 Begin execution here Move i Contents Address C B A the program Data for segment program 3-instruction Add i + 4 Figure 2.8. A program for C ←[Α] + [Β].
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
NUM n NUM2 NUM1 R0,SUM NUM n ,R0 NUM3,R0 NUM2,R0 NUM1,R0 Figure 2.9. A straight-line program for adding n numbers. Add Add Move SUM i Move Add i 4 n + i 4 n 4 - + i 8 + i 4 + n-1 ADD instructions
Background image of page 16
N,R1 Move NUM n NUM2 NUM1 R0,SUM R1 "Next" number to R0 Figure 2.10. Using a loop to add n numbers.
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 18
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 63

Machine Instructions and Programs - Chapter 2 B b3 b2b1b0 0...

This preview shows document pages 1 - 18. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online