Practical Computer Architecture with Python and ARM

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Learn computer architecture with Python and ARM, simulating assembly program execution and designing a computer simulator Purchase of the print or Kindle book includes a free PDF eBook Key Features Build a computer simulator with Python: Learn computer architecture by designing and constructing a simulator Python for architecture: Use Python to simulate and execute assembly language instructions ARM programming on Raspberry Pi: Explore ARM assembly language and run programs on Raspberry Pi Book Description This comprehensive guide offers a unique and immersive learning experience by combining Python programming with ARM architecture. Starting with an introduction to computer architecture and the flow of data within a computer system, you’ll progress to building your own interpreter using Python. You’ll see how this foundation enables the simulation of computer operations and learn ways to enhance a simulator by adding new instructions and displaying improved results. As you advance, you’ll explore the TC1 Assembler and Simulator Program to gain insights into instruction analysis and explore practical examples of simulators. This will help you build essential skills in understanding complex computer instructions, strengthening your grasp of computer architecture. Moreover, you’ll be introduced to the Raspberry Pi operating system, preparing you to delve into the detailed language of the ARM computer. This includes exploring the ARM instruction set architecture, data-processing instructions, subroutines, and the stack. With clear explanations, practical examples, and coding exercises, this resource will enable you to design and construct your own computer simulator, simulate assembly language programs, and leverage the Raspberry Pi for ARM programming. What you will learn Master the core principles of computer architecture Understand the role of registers, memory, and data flow in computers Discover how to design and implement a computer simulator using Python Simulate and execute assembly language programs on the simulator Enhance the simulator using new instructions for improved output Analyze complex computer instructions for deeper architectural understanding Explore the ARM instruction set and data processing on the Raspberry Pi Develop proficiency in writing, assembling, and running ARM code on the Raspberry Pi Who this book is for This book is for university students studying computer science, particularly those enrolled in a computer architecture module. With its practical approach and succinct explanations, it is also suitable for hobbyists, enthusiasts, and self-learners seeking a deeper understanding of computer systems. The book assumes foundational knowledge of number bases, binary arithmetic, and Boolean logic concepts. While it primarily caters to the computer science field, this book is less geared toward electrical or electronics engineering.

Author(s): Alan Clements
Edition: 1
Publisher: Packt Publishing
Year: 2023

Language: English
Pages: 412

Practical Computer Architecture with Python and ARM
Contributors
About the author
About the reviewers
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Share Your Thoughts
Download a free PDF copy of this book
Part 1: Using Python to Simulate a Computer
Chapter 1: From Finite State Machines to Computers
Technical requirements
The finite state machine
Traffic lights example
Solving a simple problem algorithmically
Constructing an algorithm
Summary
Chapter 2: High-Speed Introduction to Python
Technical requirements
Reading programs
Getting started with Python
Python’s data types
Mathematical operators
Names, values, and variables
Comments
The list – a Python key data structure
Slicing lists and strings
Functions in Python
Conditional operations and decision-making
Using a conditional expression in Python
Python’s if … else
Reading data from a file
Computer memory
Register transfer language
Summary
Chapter 3: Data Flow in a Computer
Technical requirements
The Instruction Architecture Level (ISA)
ISAs – the Naming of Parts
The von Neumann architecture
The address path
Reading the instruction
The CPU’s data paths
Typical data movement instructions
Data processing instructions
Another look at the data flow
An assembly-level program
Executing conditional instructions
Dealing with literal operands
The machine-level instruction
Instruction types and formats
CISC and RISC
Two ways of representing literals
Summary
Chapter 4: Crafting an Interpreter – First Steps
Technical Requirements
Building a simple computer interpreter in Python
Python code for a primitive simulator
The TC1 instruction set
Bit-handling in Python
Operator precedence in Python
Decoding and executing an instruction
Arithmetic and logical operations
Functions in Python
Branches and flow control
Summary
Chapter 5: A Little More Python
Technical requirements
More string features
String processing
Example – text Input
List comprehensions
The tuple
Repetition and looping
Repetition and Iterables
Lists of lists
Indenting in python
The dictionary
Functions revisited
Imports
Summary
Chapter 6: TC1 Assembler and Simulator Design
Technical requirements
Analyzing instructions
Processing the input
Dealing with assembler directives
Using the dictionary
Labels
Building the binary instruction
Extracting the instruction and its parameters
Intermission: The Pre-TC1
The Simulator
The TC1 simulator program
Single-stepping
File input
Example of a TC1 assembly language program
Testing the assembler
Testing flow control operations
Testing shift operations
TC1 postscript
The classDecode function
The testLine function
The testIndex() function
General comments
The TC1tiny code listing
TC1 postscript mark II
Summary
Chapter 7: Extending the TC1
Technical requirements
Another look at python’s input and output
Displaying data
Input validation
Validating data
Adding new instructions
First example – putting two memory locations in ascending order
Second example – adding a bit-reversal instruction
A new comparison operation
Variable-length instructions
A variable-length instruction machine
Summary
Chapter 8: Simulators for Other Architectures
Technical requirements
TC0: A stack-based calculator
TC0: A python stack machine
TC2: A one-address accumulator machine
Enhancing the TC2 Simulator
TC3: A CISC machine with a register-to-memory architecture
The TC3 instruction set architecture
Features of the simulator
The complete TC3 code
A sample run of TC3
Arithmetic and Logic Unit (ALU)
Testing the ALU
A final example: TC4
Comments on TC4
Summary
Part 2: Using Raspberry Pi to Study a Real Computer Architecture
Chapter 9: Raspberry Pi: An Introduction
Technical requirements
Raspberry Pi basics
Basics of the Raspberry Pi operating system
Directory navigation
File operations
Installing and updating programs and packages
Creating and editing an assembly language program
Assembling ARM code
Debugging assembly language
Using the Raspberry Pi debugger
Accessing memory
Features of the GCC ARM assembler
Dealing with 32-bit literals
A note on endianism
Bringing everything together – a final example
Summary
Chapter 10: A Closer Look at the ARM
Technical requirements
Introducing the ARM
Overview of the ARM’s architecture
Arm register set
Arithmetic instructions
Flow control instructions
Unconditional branches
Conditional branch
Conditional executions
Sequential conditional execution
Summary
Chapter 11: ARM Addressing Modes
Literal addressing
Scaled literals
Register indirect addressing
Pointer-based addressing with an offset
Two pointers are better than one
Automatic indexing of pointer registers
Example of string-copying
Program counter-relative addressing
Demonstration of program counter relative addressing
Summary
Chapter 12: Subroutines and the Stack
The Branch with link instruction
The stack
A subroutine call and return
Block move instructions
Disassembling the code
Block moves and stack operations
Summary
Appendices – Summary of Key Concepts
Using IDLE
Instructions and commands
Running an ARM program
Common confusions
Vocabulary
Index
Why subscribe?
Other Books You May Enjoy
Packt is searching for authors like you
Share Your Thoughts
Download a free PDF copy of this book