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...

40
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 V alues represented Figure 2.1. Binary, signed-integer representations.

Transcript of 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...

Page 1: 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+

0000000011111111

00000000

1111

1111

1100110000110011

1010101001010101

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-

b3 b2b1b0

Sign andmagnitude 1's complement 2's complement

B Values represented

Figure 2.1. Binary, signed-integer representations.

Page 2: 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+

Figure 2.2. Addition of 1-bit numbers.

Carry-out

1

1

+

011

0

1+

0

0

0

+

1

0

1

+

Page 3: 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+

Please see “portrait orientation” PowerPoint file for Chapter 2

Figure 2.3. Modular number systems and the 2's-complement system.

Page 4: 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+

Figure 2.4. 2's-complement Add and Subtract operations.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 5: 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+

Figure 2.5. Memory words.

Please see “portrait orientation” PowerPoint file for Chapter 3

Page 6: 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+

Figure 2.6. Examples of encoded information in a 32-bit word.

(b) Four characters

charactercharactercharacter character

(a) A signed integer

Sign bit: for positive numbers for negative numbers

ASCIIASCIIASCIIASCII

32 bits

8 bits 8 bits 8 bits 8 bits

b31 b30 b1 b0

b31 0=

b31 1=

• • •

Page 7: 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+

2k

4- 2k

3- 2k

2- 2k

1- 2k

4-2k

4-

0 1 2 3

4 5 6 7

0 0

4

2k

1- 2k

2- 2k

3- 2k

4-

3 2 1 0

7 6 5 4

Byte addressByte address

(a) Big-endian assignment (b) Little-endian assignment

4

Wordaddress

•••

•••

Figure 2.7. Byte and word addressing.

Page 8: 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+

Figure 2.8.. A program for C +

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 9: 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+

Figure 2.9. A straight-line program for adding n numbers.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 10: 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+

Figure 2.10. Using a loop to add n numbers.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 11: 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+

R1

Add (R1),R0 Add (A),R0

Figure 2.11. Indirect addressing.

RegisterB B Operand

memoryMain

(a) Through a general-purpose register (b) Through a memory location

A BOperandB

Page 12: 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+

Clear R0

Contents

Move

Add

DecrementAdd

LOOP

Initialization

LOOP

Address

Figure 2.12. Use of indirect addressing in the program of Figure 2.10.

(R2),R0#4,R2R1

R0,SUM

MoveMove N,R1

#NUM1,R2

Branch>0

Page 13: 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+

Figure 2.13. Indexed addressing.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 14: 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+

Figure 2.14. A list of students' marks.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 15: 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+

Move #LIST,R0

Add

Move

Add

12(R0),R3

LOOP

Figure 2.15. Indexed addressing used in accessing test scores in the list in Figure 2.14.

#16,R0

Clear R1

Clear R3

4(R0),R1

Clear R2

Add 8(R0),R2

N,R4

Add

Decrement R4

LOOP

Move R1,SUM1

Move R2,SUM2

Move R3,SUM3

Branch>0

Page 16: 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+

R0Clear

R0,SUM

R1(R2)+,R0

Figure 2.16. The Autoincrement addressing mode used in the program of Figure 2.12.

Initialization

Move

LOOP AddDecrement

LOOP

#NUM1,R2N,R1Move

Move

Branch>0

Page 17: 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+

Figure 2.17. Memory arrangement for the program in Figure 2.12.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 18: 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+

Memory Addressingaddress ordatalabel Operation information

Assemblerdirectives SUM EQU 200ORIGIN 204

N DATAWORD 100NUM1 RESERVE 400

ORIGIN 100Statementsthat START MOVE N,R1

generate MOVE #NUM1,R2machine CLR R0instructions LOOP ADD (R2),R0

ADD #4,R2DEC R1BGTZ LOOPMOVE R0,SUM

Assemblerdirectives RETURNEND START

Figure 2.18. Assembly language representation for the program in Figure 2.17.

Page 19: 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+

DATAIN DATAOUT

SIN SOUT

Keyboard Display

Bus

Figure 2.19 Bus connection for processor, keyboard, and display.

Processor

Page 20: 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+

Move #LOC,R0 InitializepointerregisterR0topoint totheaddressofthefirstlocationinmemorywherethecharactersareto bestored.

READ TestBit #3,INSTATUS Wait for a characterto beenteredBranch=0 READ in thekeyboardbufferDATAIN.MoveByte DATAIN,(R0) Transferthecharacterfrom DATAIN into

thememory(thisclearsSIN to 0).ECHO TestBit #3,OUTSTATUS Waitforthedisplay to becomeready.

Branch=0 ECHOMoveByte (R0),DATAOUT Movethecharacterjustreadtothedisplay

bufferregister(thisclearsSOUT to 0).Compare #CR,(R0)+ Check if thecharacterjustread is CR

(carriagereturn). If it isnotCR,thenBranch0 READ branch back andreadanothercharacter.

Also,increment thepointertostorethenextcharacter.

Figure 2.20. A program that reads a line of characters and displays it.

Page 21: 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+

Figure 2.21. A stack of words in the memory.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 22: 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+

Figure 2.22. Effect of stack operations on the stack in Figure 2.21.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 23: 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+

SAFEPOP Compare #2000,SP Check toseeif thestack pointercontainsBranch>0 EMPTYERROR anaddressvaluegreaterthan2000. If it

does,thestack isempty. Branch totheroutineEMPTYERROR forappropriateaction.

Move (SP)+,ITEM Otherwise,popthetopofthestack intomemorylocationITEM.

SAFEPUSH Compare #1500,SP Check tosee if thestack pointerBranch 0 FULLERROR contains anaddressvalueequal

to orlessthan1500. If it does,thestack is full.Branch totheroutineFULLERROR forappropriateaction.

Move NEWITEM, (SP) Otherwise,pushtheelement inmemorylocation NEWITEMontothestack.

Figure 2.23. Checking for empty and full errors in pop and push operations.

(b) Routine for a safe push operation

(a) Routine for a safe pop operation

Page 24: 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+

Figure 2.24. Subroutine linkage using a link register.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 25: 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+

Callingprogram

Move N,R1 R1servesasacounter.Move #NUM1,R2 R2 pointstothelist.Call LISTADD Callsubroutine.Move R0,SUM Save result....

Subroutine

LISTADD Clear R0 Initializesumto0.LOOP Add (R2)+,R0 Add entryfromlist.

Decrement R1Branch>0 LOOPReturn Returntocallingprogram.

Figure 2.25. Program of Figure 2.16 written as a subroutine; parameters passed through registers.

Page 26: 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+

Figure 2.26. Program of Figure 2.16 written as a subroutine; parameters passed on the stack.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 27: 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+

Figure 2.27. A subroutine stack frame example.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 28: 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+

Figure 2.28. Nested subroutines.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 29: 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+

Figure 2.29. Stack frames for Figure 2.28.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 30: 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+

Figure 2.30. Logical and arithmetic shift instructions.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 31: 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+

Move #LOC,R0 R0pointstodata.MoveByte (R0)+,R1 Loadfirstbyte intoR1.

LShiftL #4,R1 Shiftleftby 4 bit positions.MoveByte (R0),R2 Loadsecondbyte intoR2.And #$F,R2 Eliminatehigh-orderbits.Or R1,R2 ConcatenatetheBCDdigits.MoveByte R2,PACKED Storetheresult.

Figure 2.31. A routine that packs two BCD digits.

Page 32: 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+

Figure 2.32. Rotate instructions.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 33: 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+

Move #AVEC,R1 R1 pointstovectorA.Move #BVEC,R2 R2 pointsto vectorB.Move N,R3 R3serves asacounter.Clear R0 R0accumulatesthedotproduct.

LOOP Move (R1)+,R4 ComputetheproductofMultiply (R2)+,R4 nextcomponents.Add R4,R0 Addtoprevioussum.

Decrement R3 Decrementthecounter.Branch>0 LOOP Loopagainif notdone.Move R0,DOTPROD Storedotproductinmemory.

Figure 2.33. A program for computing the dot product of two vectors.

Page 34: 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+

Figure 2.34. A byte-sorting program using a straight-selection sort.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 35: 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+

Record 1

(a) Linking structure

Record 2 Record k

Link address

Head Tail

0

Record 2Record 1

Ne w record

(b) Inserting a new record between Record 1 and Record 2

Figure 2.35. Linked-list data structure.

Page 36: 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+

Figure 2.36. A list of student test scores organized as a linked list in memory.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 37: 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+

Figure 2.37. A subroutine for inserting a new record into a linked list.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 38: 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+

DELETION Compare (RHEAD), RIDNUMBranch>0 SEARCH

Move 4(RHEAD), RHEADReturnMove RHEAD, RCURRENT

Move 4(RCURRENT), RNEXTCompare (RNEXT), RIDNUMBranch=0 DELETE

Move RNEXT , RCURRENTBranchMove 4(RNEXT), RTEMP

RTEMP , 4(RCURRENT)

Return

LOOP

Move

not the head record

SEARCH

LOOP

DELETE

Figure 2.38. A subroutine for deleting a record from a linked list.

Page 39: 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+

Figure 2.39. Encoding instructions into 32-bit words.

Please see “portrait orientation” PowerPoint file for Chapter 2

Page 40: 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+

Table 2.1. Generic addressing modes.

Please see “portrait orientation” PowerPoint file for Chapter 2