Skip to main content

2011 | Buch

Guide to Assembly Language

A Concise Introduction

insite
SUCHEN

Über dieses Buch

This book will enable the reader to very quickly begin programming in assembly language. Through this hands-on programming, readers will also learn more about the computer architecture of the Intel 32-bit processor, as well as the relationship between high-level and low-level languages. Topics: presents an overview of assembly language, and an introduction to general purpose registers; illustrates the key concepts of each chapter with complete programs, chapter summaries, and exercises; covers input/output, basic arithmetic instructions, selection structures, and iteration structures; introduces logic, shift, arithmetic shift, rotate, and stack instructions; discusses procedures and macros, and examines arrays and strings; investigates machine language from a discovery perspective. This textbook is an ideal introduction to programming in assembly language for undergraduate students, and a concise guide for professionals wishing to learn how to write logically correct programs in a minimal amount of time.

Inhaltsverzeichnis

Frontmatter
1. Variables, Registers, and Data Movement
Abstract
High-level languages, such as C, C++, and Java, are more like natural languages and thus make programs easier to read and write. Low-level languages are closer to the machine and there is a one-to-many relationship between high-level languages and low-level languages, where language translators such as compilers and interpreters convert each high-level instruction into many low-level instructions. The native language of a particular machine is a low-level language known as machine language and is coded in ones and zeros. Further, the machine language of an Intel microprocessor is different than that of other microprocessors or mainframes, thus machine language is not transferable from one type of machine to another.
James T. Streib
2. Input/Output
Abstract
As mentioned in Chapter 1, input and output (I/O) in assembly language can be quite difficult and complicated. Although the exploration of I/O at the assembly language level is a subject worthy of study, it often times gets in the way of many of the other important topics and reasons for studying assembly language. The result is that it is helpful to have a simplified form of input/output. To that end, it is possible to access the input/output capabilities that are available in the C programming language, and of the various high-level languages that MASM can interface with, C is probably the easiest. If one has studied C before, then the following will seem fairly straightforward. If one has not studied C previously, but rather has experience with other languages like C++ or Java, the transition to the C language I/O should not be too difficult. Although all the fundamentals of I/O in C that are necessary for this text will be presented in this chapter, the reader can always refer to any number of C programming language texts to explore some of the other options available.
James T. Streib
3. Arithmetic Instructions
Abstract
After learning how to load a register, transfer data between memory locations, and perform I/O, the next step is to learn how to perform various arithmetic operations. One of the simplest ways to learn how to perform arithmetic in assembly language is to first write the equation as a high-level statement. Assuming the integer variables num1 and num2 already contain values, then how could one implement the following C statement in assembly language?
James T. Streib
4. Selection Structures
Abstract
As one should have learned in Computer Science I, there are two basic types of control structures available regardless of the language used. These two types of control structures are selection structures and iteration structures, also commonly known as ifs and loops.
James T. Streib
5. Iteration Structures
Abstract
As should be recalled from previous courses, there are many different types of iteration structures available to a programmer in a high-level programming language. Just as there are many structures in a high-level language, there are corresponding structures in assembly language, such as the pre-test, post-test, and fixed-iteration loop structures. Depending on the circumstances, one should use the best structure for the task at hand.
James T. Streib
6. Logic, Shifting, Rotating, and Stacks
Abstract
As introduced in most first semester computer science courses and previously discussed in Chapter 4, various relationals in an if statement can be connected via the use of logical operators such as “and” (&&), “or” (∥), and “not” (!), where these operators in assembly language work with comparisons between variables, registers, and literals. However, sometimes it is necessary to not just compare the contents of variables or registers but check the individual bits within a memory location or a register. These types of operations are known as bit-wise operations. An example of this is when interfacing with an external device, when often only a single bit is needed to be checked or set on the external device.
James T. Streib
7. Procedures and Macros
Abstract
This chapter will first show the reader how procedures are implemented in assembly language. The implementation of macros is introduced next which is probably a new topic to most readers. Both procedures and macros are tools that allow programmers to save time by not having to rekey the same code over and over again, but there are important differences between the two mechanisms. The chapter then continues with the introduction of conditional assembly which can be a difficult concept for new assembly language programmers. Lastly, this chapter shows the beginning of the implementation of what might be called a macro calculator which simulates a one register (accumulator) computer.
James T. Streib
8. Arrays
Abstract
Up until this point, arrays have not been needed in the examples shown. However, this chapter will introduce the declaration of arrays, array access, indexing arrays, and how to input, process, and output arrays. Although there are many ways one can index an array, this text will present only two of them. This chapter will be concerned with the declaration of arrays of signed double words (sdword), while the declaration of an array of bytes will be introduced in the next chapter on strings. Lastly, this chapter will illustrate the use of arrays in a number of examples.
James T. Streib
9. Strings
Abstract
This chapter concerns string processing. Specifically it examines various string processing instructions that are available in MASM. Continuing on with the last chapter, it also examines the manipulation of arrays of strings.
James T. Streib
10. Selected Machine Language Instructions
Abstract
As may have been learned from a computer organization text, there are many considerations that need to be taken into account and many different formats that can be used for machine language instructions. One of the first considerations is the size of the instruction. With a larger the instruction, more opcodes can be included, more registers can be referenced, and more memory locations can be addressed. Also, how a particular instruction is divided up indicates how many of each of the above can be included. For example, assume a 16-bit word is divided up as follows: bits 15-13 for the opcode, 12–11 for referencing registers, and 10-0 for addressing memory locations, as shown in Fig. 10.1.
James T. Streib
Erratum
James T. Streib
Backmatter
Metadaten
Titel
Guide to Assembly Language
verfasst von
Professor James T. Streib
Copyright-Jahr
2011
Verlag
Springer London
Electronic ISBN
978-0-85729-271-1
Print ISBN
978-0-85729-270-4
DOI
https://doi.org/10.1007/978-0-85729-271-1