Home > Store

SPARC Architecture, Assembly Language Programming, and C, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

SPARC Architecture, Assembly Language Programming, and C, 2nd Edition


  • Your Price: $169.99
  • List Price: $199.99
  • Usually ships in 24 hours.



  • NEW - Includes the latest material on the new ULTRA SPARC architecture.
  • NEW - Examines the complexity and cost of using various data and control structures in high-level languages.
  • NEW - Frequent references to C and C++ language constructs and their translation into SPARC assembly language.
  • NEW - Offers optional material on floating point, traps, memory management, and other architectures.
  • NEW - A Companion Website—Supplements the text with updates and code examples at: www.prenhall.com/paul.
  • Teaches how to evaluate compilers, data structures, and control structures in order to write efficient programs in a high-level language.


  • Copyright 2000
  • Dimensions: 7" x 9-1/4"
  • Pages: 528
  • Edition: 2nd
  • Book
  • ISBN-10: 0-13-025596-3
  • ISBN-13: 978-0-13-025596-9

Written from a programmer's perspective, this book introduces the SPARC assembly language to readers early on. Other introductory material encompasses making use of UNIX® tools (the m4 macro processor, the assembler, the gnu emacs editor, and the gdb debugger). Further coverage includes a formal definition of the von Neumann machine, its relationship to programmable calculators, and to the JAVA™ bytecode and JAVA virtual machine. This book's loyal audience has been anticipating a revision of a very successful book for this growing market. Not only is this book suitable for introductory computer architecture courses, but for programmers who will be programming SPARC architecture machine in languages such as C and C++.

  • Provides reader understanding of the complexity and cost of using various data and control structures in high-level languages
  • Includes the latest material on the new Ultra SPARC architecture
  • Frequent references to C and C++ language constructs and their translation into SPARC assembly language
  • Offers optional material on floating point, traps, memory management, and other architectures
  • Companion Website supplements the text with updates and code examples at http://www.prenhall.com/paul

Sample Content

Table of Contents

 1. The Computer.

 2. SPARC Architecture.

 3. Digital Logic and Binary Numbers.

 4. Binary Arithmetic.

 5. The Stack.

 6. Data Structures.

 7. Subroutines.

 8. Machine Instructions.

 9. External Data and Text.

10. Input/Output.

11. Floating-Point.

12. Traps and Exceptions.

13. Memory Management.

14. Other Architectures.

15. Ultra Sparc.

Appendix A: Macro Definitions.

Appendix B: Multiplication by Constants.

Appendix C: User Mode Machine Instructions.

Appendix D: Synthetic Instructions and Pseudo-Ops.

Appendix E: Instructions Sorted Alphabetically.

Appendix F: Powers of 2.

Appendix G: Macro Language Processor m4.



Preface to the First Edition

This book is written as an introductory text in computer architecture for the SPARC reduced instruction set architecture. It is assumed that readers have a working knowledge of C and UNIX. The GNU compiler gcc and the gdb debugger are used.

Computer architecture is closely related to assembly language programming, as it is through assembly language programs that the architecture of a machine is made apparent. The presentation of the material breaks from the tradition of computer architecture texts in which assembly language programming was presented as a language in which one might write programs; with a knowledge of the computer architecture, there are, today, a number of high-level languages, such as C, which provide most of the capabilities of assembly language programming. The use of high-level languages results in much higher programmer efficiency and level of representation. It is, however, important to understand the machine at the assembly language level in order to write high-level programs intelligently: to decide between competing data and control structures, the use of global variables and function parameters, the use of recursion, nested procedures, etc. While many of these choices are influenced by high-level factors, the machine architecture has a profound effect on the computational efficiency of the resulting choice.

Although the machine language of a computer is easy to understand, its use results in vast quantities of numeric data that have little meaning. Related to the very heart of computer science is the use of symbol manipulation to simplify and to bring to a clear level of understanding the manipulation and generation of low-level numeric codes. Therefore, symbol manipulation is introduced in the first chapter in the form of the m4 macro processor. Throughout the remainder of the book macros are used to simplify and clarify what is being programmed. The generation of reams of assembly language code is discouraged in favor of the highest level of representation possible.

The computer is introduced by way of the calculator, as most students are familiar with calculators. We make use of the Hewlett-Packard programmable calculator, which reveals many details of machine architectures. The HP calculators have a natural machine language. Assembly language programming is introduced to generate calculator programs making use of m4. A more formal introduction to the machine is presented in the latter half of the first chapter. Stack, accumulator, and load/store machine architectures are also introduced in the first chapter.

The second chapter introduces the SPARC architecture so that students may start programming as early as possible. Like swimming, assembly language programming is not learned in a library! Making use of the machine registers for variable storage, students may start writing short programs by the end of the chapter. The assembler, as, is introduced along with gdb, the debugger. Formatted output is deferred until very late in the book to prevent students from developing the "insert a print statement" mode of program debugging. Instead, gdb is introduced as a natural way to examine memory and registers, and to execute programs. The assembler, as, lacks a macro expansion capability, as it was only designed to be an efficient final pass for the compiler, which has its own macro facilities. In general, we will use the assembler as a second pass to m4, which provides a macro facility. Branching is introduced in the second chapter, as it is difficult to write very interesting programs without branches. Together with branching, pipelining is introduced with the resulting need for delay slot instructions. As the initial specification of the SPARC architecture did not have a multiplication or division instruction, calls to the system routines .mul and .div, etc., are introduced in the second chapter without discussing what happens when the call is made.

As each of the architectural features of the machine is introduced it is related as closely as possible to C language constructs so that students learn the relationship between C and the resulting machine language structures. In the second chapter the control structures of C are introduced in assembly language form. In general, algorithms are written in C and then hand-coded into assembly language. Frequently, optimizations are then seen and the assembly language code optimized. However, we then return to C to learn how the optimized code might have been generated directly from C or why it could not. In this way students learn the problems that compiler writers must face and the reasons why many programs are written the way they are.

Once students are able to write and execute simple assembly language programs, binary logic and arithmetic are introduced. Chapter 3 introduces binary storage devices and number systems: binary, octal, and hexadecimal and their conversions. Bitwise logic operations are introduced and the use of the register %g0, which always yields a zero when used as a source register, effectively increasing the instruction set of the machine. Chapter 4 introduces modulus arithmetic and binary multiplication and division. The treatment of multiplication is fairly extensive, as it is needed to understand the multiply-step instruction of the SPARC architecture. Signed and unsigned comparisons are discussed. The chapter concludes with extended precision arithmetic.

Chapter 5 introduces the stack for the storage of variables. Frames are introduced to provide local storage for functions. The definition of variable offsets is discussed and problems of memory alignment and the load and store instructions. Macros are made use of in the definition of stack offsets and the adjustment of the stack pointer to provide storage. Variables are addressed relative to the frame pointer, which is natural for this architecture. We defer the use of static data until Chapter 9, as their use is clumsy with the SPARC architecture and is not representative of current programming practice.

Chapter 6 introduces multidimensional arrays and structures. Problems of array bound checking and lower bounds differing from zero are discussed along with the problems of dynamic arrays so that students understand the reasons for array addressing restrictions in C. Multiplication by constants for array subscripting is introduced and macros for the automatic generation of multiplication sequences developed in Appendix C. The simplicity of structure addressing is presented so that students understand that arrays, while conceptually simple, are usually a poor choice when structures may be used in their place. Macros are developed for the definition of structure fields and storage allocation.

Functions are then introduced, with discussion of the following: register sets, subroutine linkage, arguments, and return values. Examples are given of simple function calls and of function calls with many arguments or that return aggregates. Finally, leaf routines are presented with their limited register usage.

Chapter 8 introduces the machine language of the SPARC architecture and presents the concepts of instruction decoding and operand access. The handling of 32-bit constants is presented together with program counter relative addressing.

In Chapter 9, global data, initialized data, and addressing methods are discussed. ASCII strings are introduced and formatted output discussed. The switch C statement's translation into assembly language is introduced in this chapter. The handling of C command line arguments is presented along with linking with other code.

Chapter 10 discusses input/output from character devices up through I/O processors. The chapter concludes with a section on system input/output using traps.

It is not until Chapter 11 that floating-point is introduced. Floating-point may be left out of a course without affecting the other material. The concept of additional processors with multiple functional units is discussed as well as the interlocking of the floating-point processor with the integer unit. Single, double, and extended precision number formats are described along with NaN's (not a number) and subnormal numbers.

Chapter 12 discusses supervisor mode, processor state registers, and traps. Register window saving by means of traps is discussed in detail. Interrupts are introduced together with hardware traps. This chapter may also be left out of a course without detracting from the other material.

Chapter 13 introduces sharing of the processor between many users and the mechanisms for so doing. Sharing memory is of primary importance and the SPARC virtual memory mapping, translation lookaside buffer, and cache memory system are presented. The chapter concludes with a discussion of context switching.

Chapter 14 presents some alternative architectures, the PDP-11 for historical interest, the VAX as an example of a CISC machine, and the MIPS RISC machine as a contemporary architecture. This chapter may also be left out of a course without detracting from the other material.

Appendices include the macro definitions used in the book, the use of macros to generate an open subroutine for integer multiplication by constants, the user mode instruction set, a table of powers of 2, and the description of m4.

In an introductory course for students, Chapters 1 through 9 would logically be followed in order. Additional material could then be selected by the instructor: system I/O, floating-point, traps, virtual memory, other architectures; each of these chapters is independent and may be covered in any order.

For the professional reader, Chapter 2 provides an introduction, followed by the discussion of multiplication on the SPARC at the end of Chapter 4. This should then be followed by Chapters 5 through 13. The appendices provide all the necessary reference material for those interested in user mode programming. The text should be supplemented by the SPARC architecture manual for the professional programmer.

The book was produced by the Latex document preparation system 13 and postscript files were generated by Textures. Figures were drawn using the xfig program.

Mark Foster helped with gdb and the UNIX operating system and provided extensive proofreading corrections. Craig Sayers assisted with the interpretation of the architecture and with technical aspects of the presentation. Angela Lai corrected the Instruction Set Appendix. Doug Nelson provided almost instant responses to my many questions relating to Sun. Horst Hogenkamp assisted with a very careful proofreading and suggestions for clarifying the presentation. Carl Bredlau offered support and thoughtful comments, suggestions, and corrections. Rina Ramamurthy and John Turner assisted with careful reviews and comments. Mel Paul assisted with revisions and editorial changes. Raymond McKendall was extremely helpful with the formatting of the final version of the book. My thanks to all the above. I also wish to thank Tom McElwee, Bill Zobrist, and Jennifer Wenzel at Prentice Hall, who made publication of the book such a pleasant and straightforward matter. Appendix D, Appendix E, and Appendix H are printed with permission from Sun Microsystems, Inc.

Preface to the Second Edition

Since the first edition of the book Sun has announced both a superscalar version of the architecture and an increase in the memory address size from 32 bits to 64 - the Ultra SPARC. The architecture remains binary compatible with the original, which is discussed in detail in the book. A new chapter has been added to describe the new Ultra SPARC architecture, its additional instructions, its compatibility with the existing architecture, and changes to the supervisor mode.

A number of other changes have been made throughout the book to keep it current. The description of the Burroughs B5000, as an example of a stack architecture, has been replaced by a description of a version of the Java virtual machine to support the integer bytecode instructions together with a simulator written in C. New tools are provided for debugging double-precision programs. An extended discussion and example of tagged arithmetic has been added. New exercises have been included. The description of pipelining has been rewritten with a more detailed example. The example of division has been brought into line with the description of multiplication.

A number of people have helped with the preparation of the second edition. Raymond McKendall provided vital Latex support. Jorgen Wahlsten, Dave Reed, and Kostas Daniilidis helped with errors in the book. Joe Bissell provides corrections and pointed out that m4 now includes bitwise operators. Petra Recter, Barbara Till, and Alan Apt of Prentice Hall made the publication of the second edition as straightforward as the first. I also wish to thank reviewers Carl Bredlau and Peter Jones for their helpful insights. Alex Malex helped with Unix system problems and Sean Sheridan with the Web pages. Mel Paul helped with revisions and editorial changes.

Richard P. Paul

Availability of Software

Latest updates to the book may be obtained from the following Web site:


At this site you will also find all the software to accompany this text, macro definition files, and all example programs in the text. The example programs and files may be downloaded together or accessed individually from the Web. To obtain an instructors manual, which includes the originals for all figures and tables suitable for making slides and solutions to exercises, you should contact your Prentice Hall sales representative.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020