Guide To Assembly Language: A Concise Introduction
Book information
Description
This concise guide is designed to enable the reader to learn how to program in assembly language as quickly as possible. Through a hands-on programming approach, readers will also learn about the architecture of the Intel processor, and the relationship between high-level and low-level languages. This updated second edition has been expanded with additional exercises, and enhanced with new material on floating-point numbers and 64-bit processing. Topics and features: provides guidance on simplified register usage, simplified input/output using C-like statements, and the use of high-level control structures; describes the implementation of control structures, without the use of high-level structures, and often with related C program code; illustrates concepts with one or more complete program; presents review summaries in each chapter, together with a variety of exercises, from short-answer questions to programming assignments; covers selection and iteration structures, logic, shift, arithmetic shift, rotate, and stack instructions, procedures and macros, arrays, and strings; includes an introduction to floating-point instructions and 64-bit processing; examines machine language from a discovery perspective, introducing the principles of computer organization. A must-have resource for undergraduate students seeking to learn the fundamentals necessary to begin writing logically correct programs in a minimal amount of time, this work will serve as an ideal textbook for an assembly language course, or as a supplementary text for courses on computer organization and architecture. The presentation assumes prior knowledge of the basics of programming in a high-level language such as C, C++, or Java. Importance of Assembly Language......Page 6 Features of This Text......Page 7 Brief Overview of the Chapters and Appendices......Page 8 Acknowledgements......Page 10 Feedback......Page 11 Contents......Page 12 1.1 Introduction......Page 17 1.2 The First Program......Page 18 1.3 Variable Declaration......Page 20 1.4 Immediate Data......Page 22 1.5 Registers......Page 23 1.6 Data Movement......Page 26 1.7 Character Data......Page 27 1.9 Complete Program: Implementing Inline Assembly in C......Page 29 1.11 Exercises (Items Marked with an t Have Solutions in Appendix D)......Page 31 2.2 Hello World......Page 33 2.3 Integer Output......Page 35 2.4 Integer Input......Page 37 2.5 Complete Program: Using Input, Data Transfer, and Output......Page 40 2.7 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 41 3.1 Addition and Subtraction......Page 45 3.2 Multiplication and Division......Page 48 3.3 Implementing Unary Operators: Increment, Decrement, and Negation......Page 52 3.4 Order of Operations with Binary and Unary Operators......Page 55 3.5 Complete Program: Implementing I/O and Arithmetic......Page 58 3.6 Summary......Page 59 3.7 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 60 4.1 Introduction......Page 63 4.2 If-Then Structure......Page 64 4.3 If-Then-Else Structure......Page 69 4.4 Nested If Structures......Page 70 4.5 Case Structure......Page 74 4.6 Characters and Logical Operations......Page 75 4.7 Arithmetic Expressions in High-Level Directives......Page 80 4.8 Complete Program: Using Selection Structures and I/O......Page 83 4.10 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 86 5.1 Pre-test Loop Structure......Page 88 5.2 Post-test Loop Structures......Page 91 5.3 Fixed-Iteration Loop Structures......Page 93 5.4 Loops and Input/Output......Page 96 5.5 Nested Loops......Page 100 5.6 Complete Program: Implementing the Power Function......Page 102 5.8 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 105 6.1 Introduction......Page 109 6.2 Logic Instructions......Page 110 6.3 Logical Shift Instructions......Page 114 6.4 Arithmetic Shift Instructions......Page 119 6.5 Rotate Instructions......Page 122 6.6 Stack Operations......Page 125 6.7 Swapping Using Registers, the Stack, and the xchg Instruction......Page 127 6.8 Complete Program: Simulating an OCR Machine......Page 129 6.9 Summary......Page 133 6.10 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 134 7.1 Procedures......Page 136 7.2 Complete Program: Implementing the Power Function in a Procedure......Page 140 7.3 Saving and Restoring Registers......Page 143 7.4 Macros......Page 145 7.5 Conditional Assembly......Page 151 7.6 Swap Macro Revisited Using Conditional Assembly......Page 154 7.7 Power Function Macro Using Conditional Assembly......Page 158 7.8 Complete Program: Implementing a Macro Calculator......Page 161 7.9 Summary......Page 168 7.10 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 169 8.1 Array Declaration and Addressing......Page 171 8.2 Indexing Using the Base Register......Page 174 8.3 Searching......Page 178 8.4 Indexing Using the esi and edi Registers......Page 180 8.5 Lengthof and Sizeof Operators......Page 185 8.6 Complete Program: Implementing a Queue......Page 187 8.7 Complete Program: Implementing the Selection Sort......Page 192 8.9 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 197 9.1 Introduction......Page 200 9.2 String Instructions: Moving Strings (movsb)......Page 202 9.3 String Instructions: Scanning (scasb), Storing (stosb), and Loading (lodsb)......Page 205 9.4 Array of Strings......Page 207 9.5 String Instructions: Comparing Strings (cmpsb)......Page 209 9.6 Complete Program: Searching an Array of Strings......Page 215 9.7 Summary......Page 217 9.8 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 218 10.1 Memory Storage......Page 220 10.3 Pushing and Popping......Page 221 10.4 Simple Arithmetic Expressions......Page 224 10.5 Complex Arithmetic Expressions......Page 226 10.6 Mixing Floating-Point and Integers......Page 230 10.7 Input/Output......Page 232 10.7.1 float and real4......Page 233 10.7.2 double and real8......Page 234 10.7.4 Inline Assembly......Page 236 10.8 Comparisons and Selection Structures......Page 237 10.9 Complete Program: Implementing an Iteration Structure......Page 240 10.10 Complete Program: Implementing an Array......Page 243 10.11 Summary......Page 245 10.12 Exercises (Items Marked with an * Have Solutions in Appendix D)......Page 246 11.1 Four General Purpose Registers......Page 248 11.2 Other 64-Bit Registers......Page 251 11.3 64-Bit Integer Output......Page 252 11.4 64-Bit Integer Input......Page 256 11.5.1 Shift and Rotate......Page 258 11.5.2 Logic......Page 260 11.5.3 Arithmetic......Page 261 11.6 Control Structures......Page 262 11.8 Procedures and Macros......Page 265 11.8.1 Calling 64-Bit Procedures......Page 266 11.8.2 Using a Macro to Call printf......Page 267 11.9 Complete Program: Reversing an Array......Page 269 11.10 Summary......Page 271 11.11 Exercises (Items Marked with an * Have Solutions in Appendix D)......Page 272 12.1 Introduction......Page 274 12.2 inc and dec Instructions......Page 275 12.3 mov Instruction......Page 277 12.4 add and sub Instructions......Page 282 12.5 mov offset and lea Instructions......Page 283 12.6 jmp Instructions......Page 285 12.7 Instruction Timings......Page 286 12.8 Floating-Point and 64-Bit Instructions......Page 287 12.8.2 64-Bit Instructions......Page 288 12.8.3 Memory Addressing......Page 291 12.9 Complete Program: 32-Bit Assembly Listing......Page 292 12.10 Complete Program: Floating-Point and 64-Bit Assembly Listing......Page 294 12.11 Summary......Page 295 12.12 Exercises (Items Marked with an ∗ Have Solutions in Appendix D)......Page 296 References......Page 347 Index......Page 348
Similar books
Pro ASP.NET 2.0 in C# 2005
2005 · PDF
Expert Oracle JDBC Programming
2005 · PDF
PHP Objects, Patterns, and Practice
2008 · PDF
Programming Language Concepts
2012 · PDF
Guide to ILDJIT
2011 · PDF
Accelerated C# 2010
2010 · PDF
PHP for Absolute Beginners
2010 · PDF
Beginning XNA 3.0 Game Programming: From Novice to Professional
2009 · PDF