Assembly Programming and Computer
Architecture for Software Engineers
Brian R. Hall
Champlain College, Burlington, VT
Kevin J. Slonka
Pennsylvania Highlands Community College, Johnstown, PA
Copyright © 2018 Prospect Press, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States
Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy
fee to the Copyright Clearance Center, Inc. 222 Rosewood Drive, Danvers, MA 01923, website www.copyright.com. Requests to the
Publisher for permission should be addressed to the Permissions Department, Prospect Press, 47 Prospect Parkway, Burlington, VT
05401 or emailed to Beth.Golub@ProspectPressVT.com.
Founded in 2014, Prospect Press serves the academic disciplines of Computer and Information Systems by publishing innovative
textbooks across the curriculum including introductory, emerging, and upper level courses. Prospect Press offers reasonable prices by
selling directly to students. Prospect Press provides tight relationships between authors, publisher, and adopters that many larger
publishers are unable to offer in today’s publishing environment. Based in Burlington, Vermont, Prospect Press distributes titles
worldwide. We welcome new authors to send proposals or inquiries to Beth.Golub@ProspectPressVT.com.
Editor: Beth Lang Golub
Production Management: Kathy Bond Borie
Cover Design: Annie Clark
Cover Illustration: Hanah Leo
eTextbook ISBN: 978-1-943153-31-2
• Available from Redshelf.com and VitalSource.com
Printed Paperback ISBN: 978-1-943153-32-9
• Available from Redshelf.com and CreateSpace.com
For more information, visit
http://prospectpressvt.com/titles/hall-assembly-programming/
About the cover
Why the mountains on the cover? Mountains are both beautiful and forbidding, much like the two foundational topics addressed
throughout this book: Assembly Programming and Computer Architecture. They are the source of a challenging journey that opens your
eyes to a heightened view of computing. Why the metallic waterfall on the cover? That is just a metaphor for the deep dive into the
content that awaits.
Contents
Preface
Chapter 1 Language and Data Fundamentals
Welcome
Introduction
Computing Languages
Data Representation
Boolean Expressions
3-bit Computer Example
Summary
Key Terms
Code Review
Questions
Assignments
Chapter 2 Processor and System Architecture
Introduction
Architecture Overview
Processors
Input and Output
Summary
Key Terms
Questions
Assignments
Chapters 1 and 2 Supplement More Architecture Details
Program Loading
Memory Access Improvements
Support Processors
Pipelining and Multi-unit Processing
Input/Output System
Chapter 3 Assembly and Syntax Fundamentals
Introduction
Basic Elements
Data Definition
Working Examples
Summary
Key Terms
Code Review
Questions
Assignments
Chapter 4 Basic Instructions
Introduction
Data Movement and Arithmetic
Data Addressing and Transfer
Summary
Key Terms
Code Review
Questions
Assignments
Chapter 5 Intermediate Instructions
Introduction
Boolean Bitwise Operations
Branching
Repetition
Summary
Key Terms
Code Review
Questions
Assignments
Chapter 6 Functions
Introduction
Stack Memory Primer
x86 and x86_64 Calling Conventions
Implementations
Summary
Key Terms
Key Registers (32-bit, 64-bit)
Code Review
Platform Specific Notes
Questions
Assignments
Chapter 6 Supplement Program 6.3 x86_64 Implementation
Chapter 7 String Instructions and Structures
Introduction
Accessory Instructions
String Primitive Instructions
Structures
Summary
Key Terms
Code Review
Questions
Assignments
Chapter 8 Floating-Point Operations
Introduction
Floating-Point Representation
Floating-Point Implementations
Summary
Key Terms
Key Registers (32-bit, 64-bit)
Code Review
Questions
Assignments
Chapter 8 Supplement Chapter 8 Programs
Investment Calculator
Chapter 9 Inline Assembly and Macros
Introduction
Inline Assembly
Macros
Summary
Key Terms
Questions
Assignments
Chapter 10 Advanced Processor and System Architecture
Introduction
Processor and System Capabilities
Interrupts and System Calls
Summary
Key Terms
Code Review
Questions
Assignments
Chapter 10 Supplement Chapter 10 Programs and Resources
Programs
Resources
Chapter 11 Other Architectures
Introduction
CISC versus RISC
More Architectures
Quantum Architecture
Summary
Key Terms
Questions
Assignments
Chapter 12 Hardware and Electrical Components
Introduction
Foundations of Electricity
Electrical Components
Integrated Circuits
Popular Implementations
Summary
Key Terms
Questions
Assignments
Introduction to the Appendices
Welcome and Objective
Lost and Found
Appendix A Assembly Syntax Translation
Appendix B Environment Setup for Assembly Programming
Appendix C Disassembly
Appendix D Command-Line Debugging Assembly with GDB
Appendix E Linking Assembly and C++
Appendix F Functions and Stack