{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Machine Instructions and Programs

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

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

Chapter 2

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

View Full Document
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.
Figure 2.2. Addition of 1-bit numbers. Carry-out 1 1 + 0 1 1 0 1 + 0 0 0 + 1 0 1 +

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

View Full Document
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.
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.

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

View Full Document
0010 (+2) + 0011 (+3) 0101 (+5)
0100 (+4) + 1010 (- 6) 1110 (- 2)

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

View Full Document
1101 (- 3) - 1001 (- 7) 1101 (- 3) + 0111 (- -7) 0100 (+4) for subtraction, replace subtrahend with its 2’s complement
second word first word Figure 2.5. Memory words. n bits last word i th word

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

View Full Document
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 =
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.

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

View Full Document
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”
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

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

View Full Document
Assembly Language Notation MOVE LOC, R1 ADD R1, R2 SUB R1, R2, R3 Mnemonic op codes Symbolic addresses
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 ←[Α] + [Β].

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

View Full Document
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
N,R1 Move NUM n NUM2 NUM1 R0,SUM R1 "Next" number to R0 Figure 2.10. Using a loop to add n numbers.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online