SOLUTIONS 5-1 SOLUTIONS 6-1
CHAPTER 5 SOLUTIONS 5-1
The important point in making the translation to SPARC is how to manipulate the stack frame. Prior to the function call, the calling routine places the parameters on the stack. When the called routine min is invoked, its first task should be to save the return address on the stack. There is no need to do it here since min makes no nested calls. So, the stack pointer currently points to j, and i is one word deeper into the stack: addcc r14, -4, r14 Push m onto stack frame ld r14, 8, r1 r1 - i ld r14, 4, r2 r2 - j orncc r2, r0, r3 r3 - ~r2 addcc r3, 1, r3 r3 - r3+1 2s comp of j addcc r1, r3, r4 r4 - i - j bneg J_GT_I branch if ij ji actually st r2, r14 m - j ba DONE J_GT_I: st r1, r14 m - i DONE: jmpl r15, 4, r0 Return value m is on stack. 5-2 10 00010 100110 00010 1 0000000001010 5-3 be 3 5-4 Symbol Value All numbers are given in base 10 K EQU 77 P EQU 1 ORG 32 JUMP MAIN PMUL: SUB 2,R0 LOAD A,R1 BZERO ANOTZ LOAD 0,R1 JUMP DONE ANOTZ: LOAD B,R3 BZERO BNOTZ LOAD 0,R3 JUMP DONE BNOTZ: LOAD 0,R1 STORE R1,A BZERO PMUL DONE: JUMP DONE A: 12 B: 15 K 77 P 1 MAIN X PMUL 36 A 88 ANOTZ 56 DONE 84 B 92 BNOTZ 72 5-5 .macro mov arg1,arg2 orcc r0, arg1, arg2 .endmacro 5-6 The program would still work correctly, but the return would go to the nop instruction that follows the call, thus wasting an instruction cycle. 5-7 When the code finishes execution: 1 A is incremented by 2; 2 B has the original value of A; 3 The stack is restored to its original state.CHAPTER 6 SOLUTIONS 6-1
Note that r1 goes in the rd field for an st instruction: 11 00001 000100 00010 0 00000000 00011 op rd op3 rs1 i rs2 DECODE: 1 11 000100 00 = 1808 Microinstructions: 0, 1, 1808, 1809, 40, 41, 42, 43, 44, 2047 6-2 1615: 000000 1 000000 0 100010 0 0 0 0001 110 00000010101 21: 100001 0 100001 0 100011 0 0 0 0010 000 00000000000 6-3 00000000 00000000 0 00 00000000 0 00000111 00000011 0 01 00010101 0 11111111 11111111 1 11 11111110 1CHAPTER 7 SOLUTIONS 7-1
Parts
» Organisasi Komputer (T. Informatika)
» Overview 1.2 A Brief History
» Overview 3.2 Fixed Point Addition and Subtraction
» The Compilation Process 5.2 The Assembly Process
» Basics of the Microarchitecture 6.2 A Microarchitecture for the ARC
» The Memory Hierarchy 7.2 Random Access Memory
» Simple Bus Architectures 8.2 Bridge-Based Bus Architectures
» Interleave Factor MBsec 33 MBsec
» Modems 9.2 Transmission Media Communication
» Quantitative Analyses of Program Execution 10.2 From CISC to RISC
» PROBLEMS 1-1 PROBLEMS 2-1 The binary representation of the hexadecimal number 3B7F is choose one:
» PROBLEMS 4-1 Organisasi Komputer (T. Informatika)
» PROBLEMS 5-1 Organisasi Komputer (T. Informatika)
» Introduction Data Representation Arithmetic T he Instruction Set Architecture
» Languages and the Machine Datapath and Control Memory Input and Output Communication
» The Von Neumann M odel The System Bus M odel
» A Typical Computer System Organization of the Book
» Case Study: W hat Happened to Supercomputers?
» Introduction Trends in Computer Architecture
» Fixed Point Numbers Trends in Computer Architecture
» Floating Point Numbers Trends in Computer Architecture
» Case Study: Patriot M issile Defense Failure Caused by Loss of Precision
» Character Codes Trends in Computer Architecture
» Overview Fixed Point Addition and Subtraction
» Fixed Point M ultiplication and Division
» Floating Point Arithmetic Trends in Computer Architecture
» High Performance Arithmetic Trends in Computer Architecture
» Case Study: Calculator Arithmetic Using Binary Coded Decimal
» Hardw are Components of the Instruction Set Architecture
» Pseudo-Ops Trends in Computer Architecture
» Examples of Assembly Language Programs
» Accessing Data in M emory— Addressing M odes
» Subroutine Linkage and Stacks
» Input and Output in Assembly Language
» The Compilation Process Trends in Computer Architecture
» The Assembly Process Trends in Computer Architecture
» Linking and Loading Trends in Computer Architecture
» M acros Trends in Computer Architecture
» Case Study: Extensions to the Instruction Set – The Intel M M X
» Basics of the M icroarchitecture A M icroarchitecture for the ARC
» Hardw ired Control Trends in Computer Architecture
» Case Study: The VHDL Hardw are Description Language
» The M emory Hierarchy Random Access M emory
» Chip Organization Trends in Computer Architecture
» Commercial M emory M odules Read-Only M emory
» Virtual M emory Trends in Computer Architecture
» Advanced Topics Trends in Computer Architecture
» Case Study: The Intel Pentium M emory System
» Simple Bus Architectures Trends in Computer Architecture
» Bridge-Based Bus Architectures Trends in Computer Architecture
» MBsec 33 MBsec Communication M ethodologies
» Case Study: Communication on the Intel Pentium Architecture
» M ass Storage Trends in Computer Architecture
» Input Devices Trends in Computer Architecture
» Output Devices Trends in Computer Architecture
» M odems Trends in Computer Architecture
» Transmission M edia Trends in Computer Architecture
» Netw ork Architecture: Local Area Netw orks
» Communication Errors and Error Correcting Codes
» Netw ork Architecture: The Internet
» Case Study: Asynchronous Transfer M ode
» Quantitative Analyses of Program Execution
» Pipelining the Datapath Trends in Computer Architecture
» Overlapping Register W indow s
» VLIW M achines Case Study: The Intel IA-64 M erced Architecture
Show more