Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Modern Computer Architecture and Organization

You're reading from   Modern Computer Architecture and Organization Learn x86, ARM, and RISC-V architectures and the design of smartphones, PCs, and cloud servers

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher Packt
ISBN-13 9781838984397
Length 560 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Jim Ledin Jim Ledin
Author Profile Icon Jim Ledin
Jim Ledin
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Section 1: Fundamentals of Computer Architecture
2. Chapter 1: Introducing Computer Architecture FREE CHAPTER 3. Chapter 2: Digital Logic 4. Chapter 3: Processor Elements 5. Chapter 4: Computer System Components 6. Chapter 5: Hardware-Software Interface 7. Chapter 6: Specialized Computing Domains 8. Section 2: Processor Architectures and Instruction Sets
9. Chapter 7: Processor and Memory Architectures 10. Chapter 8: Performance-Enhancing Techniques 11. Chapter 9: Specialized Processor Extensions 12. Chapter 10: Modern Processor Architectures and Instruction Sets 13. Chapter 11: The RISC-V Architecture and Instruction Set 14. Section 3: Applications of Computer Architecture
15. Chapter 12: Processor Virtualization 16. Chapter 13: Domain-Specific Computer Architectures 17. Chapter 14: Future Directions in Computer Architectures 18. Answers to Exercises 19. Other Books You May Enjoy

Exercises

  1. Using your favorite programming language, develop a simulation of a single-digit decimal adder that operates in the same manner as in Babbage's Analytical Engine. First, prompt the user for two digits in the range 0-9: the addend and the accumulator. Display the addend, the accumulator, and the carry, which is initially zero. Perform a series of cycles as follows:

    a. If the addend is zero, display the values of the addend, accumulator, and carry and terminate the program.

    b. Decrement the addend by one and increment the accumulator by one.

    c. If the accumulator incremented from nine to zero, increment the carry.

    d. Go back to step a.

    Test your code with these sums: 0+0, 0+1, 1+0, 1+2, 5+5, 9+1, and 9+9.

  2. Create arrays of 40 decimal digits each for the addend, accumulator, and carry. Prompt the user for two decimal integers of up to 40 digits each. Perform the addition digit by digit using the cycles described in Exercise 1, and collect the carry output from each digit position in the carry array. After the cycles are complete, insert carries, and, where necessary, ripple them across digits to complete the addition operation. Display the results after each cycle and at the end. Test with the same sums as in Exercise 1 and test 99+1, 999999+1, 49+50, and 50+50.
  3. Modify the program of Exercise 2 to implement subtraction of 40-digit decimal values. Perform borrowing as required. Test with 0-0, 1-0, 1000000-1, and 0-1. What is the result for 0-1?
  4. 6502 assembly language references data in memory locations using an operand value containing the address (without the # character that indicates an immediate value). For example, the LDA $00 instruction loads the byte at memory address $00 into A. STA $01 stores the byte in A into address $01. Addresses can be any value in the range 0 to $FFFF, assuming memory exists at the address and the address is not already in use for some other purpose. Using your preferred 6502 emulator, write 6502 assembly code to store a 16-bit value into addresses $00-$01, store a second value into addresses $02-$03, then add the two values and store the result in $04-$05. Be sure to propagate any carry between the two bytes. Ignore any carry from the 16-bit result. Test with $0000+$0001, $00FF+$0001, and $1234+$5678.
  5. Write 6502 assembly code to subtract two 16-bit values in a manner similar to Exercise 4. Test with $0001-$0000, $0001-$0001, $0100-$00FF, and $0000-$0001. What is the result for $0000-$0001?
  6. Write 6502 assembly code to store two 32-bit integers to addresses $00-03 and $04-$07, then add them, storing the results in $08-$0B. Use a looping construct, including a label and a branch instruction, to iterate over the bytes of the two values to be added. Search the Internet for the details of the 6502 decrement and branch instructions and the use of labels in assembly language. Hint: The 6502 zero-page indexed addressing mode works well in this application.
You have been reading a chapter from
Modern Computer Architecture and Organization
Published in: Apr 2020
Publisher: Packt
ISBN-13: 9781838984397
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image