Addressing Modes g
Addressing modes define how machine language i t ti l instructions id tif th operand of identify the d f each instruction. An dd A addressing mode specifies h i d ifi how t calculate to l l t the effective memory address of an operand by using information held in registers and/or constants contained within an instruction. Different computer architectures vary greatly as to the number of addressing modes they provide.
Addressing Modes
The 8085 provides FIVE different modes for address data: 1. Direct Addressing 2. Register Addressing 3. Register Indirect Addressing 4. Immediate Addressing 5. 5 Implied Addressing
Direct Addressing
In direct addressing mode, the address of the data is specified in the instruction. This mode creates instructions 3 bytes long. y g The first byte contains the operation to be p performed. The second (low order byte) and third bytes (high order byte) contain the address in memory where the data byte may be found. Ex. LDA 1050H - Load the data available in memory location 1050H in to accumulator
Register Addressing
In register addressing mode, the instruction specifies the name of the register in which the data is available. This mode results in single-byte instructions. The byte contains bits which specify a register or register pair in which the data is located. Ex MOV A, B - Move the content of B Ex. A register to A register
Immediate Addressing
In immediate addressing mode, the data is specified in g , p the instruction itself. The data will be a part of the program instruction. Thi mode results in a two or three byte instruction. This d lt i t th b t i t ti The first byte contains the instruction itself. The second and third bytes contain the immediate data data, either as a single 8-bit value, or as a 16-bit value. If the 16-bit value is used, the bytes are reversed, with the second byte containing the low order byte, and the third byte containing the high order byte. EX MVI B 3EH - Move the data 3EH given in the EX. B, instruction to B register; LXI SP, 2700H.
Implied Addressing
In implied addressing mode the mode, instruction itself specifies the data to be operated. operated Ex. CMA - Complement the content of accumulator; RAL
1. Definition of Problem
Clarify Programming Needs. Knowing the objective is the first consideration. Is it a payroll or editing program? Knowing who the end user will be is also important. Determining the inputs and outputs is next. How will the program operate and what data is needed to make it happen. After this has been decided feasability is the next consideration. How many programmers will it take, is the project within budget, does the project have a realistic outline outline. Finally, if the project is a go, then one must take measures to ensure the proect is properly documented and analyzed. Six mini steps:
Clarify objectives and users Clarify desired outputs Clarify desired inputs Clarify desired Cl if d i d processing i Double - check feasibility of implementing the program Document the analysis
2. Logic Design
Design the program. Programs use algorithms which are like equations that tell the computer what task to perform. The aim of the programmer is to create algorithms that are clear and p g g simple. Algorithms are expressed first in logical hierarhical form known as modularzation. Using modules or (a complete thought) the programmer creates a logical thought process for the computer to follow. After that the program is broken down in greater detail using psuedocode. Psudocode uses terms like if, else, and, then to relate the programs rules to the computer computer.
3. Programming
Code the program. After the program has been designed it must the be coded or p g g written. Using the psudocode and logic requirements from step two an appropriate p g pp p programming language must be selected. g g g As stated in the introduction, coding languages differ in specifications and usability. Once the appropriate code language has been chosen, it is imperative that the programmer follow the , p p g sytax rules with as little deviation as possible.
5. Documentation
Documentation should be ongoing from the very g g y beginning because it is needed for those involved with program now and future. U Upon completion U l ti User D Documentation f commercial t ti for i l use, Operator Documentation for people who run computer systems, and Programmer Documentation for programmers charged with maintenancing the program are all issued. Four mini steps:
Write user documentation Write operator documentation Write programmer documentation Mantain the program
The application of a structure design methodology greatly increases the probability of completing a successful design with a minimum amount of time and expense. By using a structured design methodology, the likelihood methodology of finding design flaws early improves considerably. Finding design flaws early in the design process greatly reduces the cost of fixing those flaws flaws. Structured design methods also improve the ability to modify programs at a later date since the techniques make the production of clear and complete documentation much easier. Structured designs can also be more easily broken up into modules to improve testing and to allow development by multiple design teams with a reasonable assurance that the resulting products will be compatible with each other.
Basic Blocks
A terminator marks the beginning or end of the flowchart. A process symbol indicates an operation that changes or manipulates data in some way (e.g., arithmetic, move, or copy). A data symbol (a parallelogram) indicates an operation that inputs or outputs data data. A diamond indicates a decision. A connector (a small circle) means that the logic is continued at another place on the same page. An off page connector (home plate) indicates that the logic is continued on another page off-page page. A rectangle within a rectangle indicates a predefined process (or subroutine).
subroutine
The Sequence Structure implies that the logic is executed in simple sequence, one block after another. Note that each block might represent one or more actual instructions.
In a Decision/ Branch Structure, a condition is tested. If the condition is true, the logic associated with the THEN branch is executed and the ELSE block is skipped. If the condition is false the ELSE logic is executed and the THEN logic is skipped. Note that the THEN and ELSE blocks might represent one or more actual instructions. Note also that a given THEN or ELSE block might incorporate an additional decision block, yielding nested decision logic.
There are two basic patterns for showing repetitive/loop structure. In a DO WHILE block, the test is performed first and the associated instructions are performed only if (while) the test condition is true true. In a DO UNTIL block, the associated instructions are executed first and then the exit condition is tested. Note that the logic block associated with a DO WHILE or DO UNTIL might represent one or more actual instructions.
A subroutine structure functions as a self-contained block of code. However, it is embedded in a large block , g of code and must interact with the calling program. A flowchart for a routine calls another subroutine that perform another operations that the detailed logic is flowcharted elsewhere. In effect, using predefined processes allows the designer to decompose the logic.
Example