Microcontrollers

Stack Index Addressing, Reentrancy, and Recursion (Microcontrollers)

3.4 The stack pointer may be used with all the index addressing modes, but its uses have special meaning. These uses correspond to pushing and pulling, and they support reentrancy and recursion. Also, the index registers X and Y may be used as auxiliary stack pointers. This section shows these variations of index addressing. The […]

Examples (Microcontrollers)

3.5 We now tie together some of the ideas that were introduced above using some examples. These examples give you some experience with addressing modes and loops. One of the most common operations is to clear a block of memory. The program segment in Figure 3.17 clears 39 bytes starting at location $910. This example […]

Architectural Notions of Addressing (Microcontrollers)

3.6 The particular computer that we are studying, the 6812, is a one-address computer. Have you thought, perhaps, that a computer that has instructions with two addresses may be better than a one-address computer? In some cases, it would be, and a three-address computer would be even better; but in other cases, it would not. […]

Summary (Microcontrollers)

3.7 In this topic we looked at the addressing modes in the 6812. We saw four genera! themes: the use of page zero, the use of index registers, the use of relative addressing for position independence, and the use of stack addressing for reentrancy and recursion. With the first theme, we saw inherent and page […]

Assembly Language Programming (Microcontrollers)

In the examples presented so far, you have probably noticed some real programming inconveniences, such as finding the operation code bytes, computing the addresses (particularly relative addresses), and associating the variable names with their memory locations. Furthermore, if you change the program, much of this routine work may have to be done again. What we […]

Introductory Example and Assembler Printout (Microcontrollers)

4.1 We now consider a simple example to introduce you to assembly-language programs. Consider a program that obtains the maximum of a sequence of numbers. We will assume that this sequence consists of 16-bit unsigned numbers stored consecutively in memory, high byte first for each number. This data structure is called a vector or (one-dimensional) […]

Assembler Directives (Microcontrollers)

4.2 Before looking more closely at how the assembler works, we describe the simplest assembler directives. These are instructions to the assembler that do not result in any actual executable machine coded instructions but are, nevertheless, essential to providing information to the assembler. A number of these will be introduced in this section and are […]

Mechanics of a Two-Pass Assembler (Microcontrollers)

4.3 Some questions will soon arise about how symbolic addresses can be used without error. These questions have to be answered in terms of forward references, and their answers have to be understood in terms of how an assembler generates its output in two passes. Although we do not study how to write an assembler […]

Character String Operations (Microcontrollers)

4.4 Before we look into an assembler, we will study some operations that copy, search, and manipulate character strings. These operations make it easier to understand how an assembler works, which we cover in the next section. They also provide an opportunity to show how assembly-language source code is written, in order to simplify your […]

A Simplified Two-Pass Assembler (Microcontrollers)

4.5 An assembler is really a simple program. To illustrate how it works and to gain valuable experience in assembly-language techniques, we write parts of a “Simple Assembler” SA1 for a simple computer, with the overall specifications shown in Figure 4.14. Figure 4.13a shows SAl’s machine code for a program to add two numbers (like […]