addressing modes & programming (2009)

23
Addressing Mode & Programming Basics By  

Upload: biela-nabila

Post on 06-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 1/23

Addressing Mode &Programming Basics

By 

 

Page 2: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 2/23

Addressin Modes• Addressing modes define how machine

anguage nstruct ons ent y t e operan oeach instruction.

• n a ress ng mo e spec es ow o ca cu a ethe effective memory address of an operand

constants contained within an instruction.

•as to the number of addressing modes theyprovide.

Page 3: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 3/23

 

modes for address data:

1. Direct Addressing

 

3. Register Indirect Addressing

4. Immediate Addressing

.

Page 4: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 4/23

 • ,

data is specified in the instruction.• This mode creates instructions 3 b tes lon .

• The first byte contains the operation to be

erformed.

• 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 inmemory location 1050H in to accumulator

Page 5: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 5/23

 • In register addressing mode, the

instruction specifies the name of theregister in which the data is available.

• This mode results in single-byte

instructions.

• The byte contains bits which specify a

located.

. , -

register to A register

Page 6: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 6/23

 • In register indirect addressing mode, the instruction

spec es t e name o t e reg ster n w c t e a ress othe data is available.

• Here the data will be in memory and the address will ben e reg s er pa r.

• This mode results in single-byte instructions.

• The byte contains bits which specify a register pair,which in turn contains the address of the data inmemory.

• The high order byte address is stored in the leftmost of

e reg s er pa r, w e e ow or er y e o e a ressis stored in the rightmost of the register pair. Ex. Address3000H would be stored as 30 in H, and 00 in L.

• x. , - e memory a a a resse y pa r

is moved to A register. LDAX B.

Page 7: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 7/23

 • In immediate addressin mode the data is s ecified in

the instruction itself. The data will be a part of theprogram instruction.

• s mo e resu s n a wo or ree y e ns ruc on.

• The first byte contains the instruction itself.

• ,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 thethird byte containing the high order byte.

. , -

instruction to B register; LXI SP, 2700H.

Page 8: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 8/23

 • ,

instruction itself specifies the data to be.

• Ex. CMA - Complement the content of

Page 9: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 9/23

 

.

2. Logic Design

. rogramm ng

4. Load, Test and Debug5. Documentation

Page 10: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 10/23

.• Clarify Programming Needs.

• Knowing the objective is the first consideration. Is it a payroll or editingprogram?

• 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 havea rea s c ou ne.

• Finally, if the project is a go, then one must take measures to ensure theproect is properly documented and analyzed.

  – Clarify objectives and users

 – Clarify desired outputs

 – Clarify desired inputs

 – Clarify desired processing

 – Double - check feasibility of implementing the program

 – Document the analysis

Page 11: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 11/23

.• Design the program.

• Programs use algorithms which are like equations that tell thecomputer what task to perform.

• The aim of the ro rammer is to create al orithms that are clear andsimple.

• Algorithms are expressed first in logical hierarhical form known asmodularzation.

• Using modules or (a complete thought) the programmer creates alogical thought process for the computer to follow.

•psuedocode .

• Psudocode uses terms like if, else, and, then to relate the programs.

Page 12: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 12/23

  – Determine program logic through top down approach and

modularization, using a heiarchy chart

 – ,

control structure.• A module, a processing step of a program, made up of logically related program statements.

• A hierarchy chart, which represents top-down program desigh, explains the main purpose of the program.

• Pseudocode, a way of desighing a program which uses normal language statements in order to describe the logic and the processing flow.

• Program flowcharts, graphically shows the detailed series of steps 

• Three control structure:

 – Sequence control stucture

 – Selection control structure

 – Loop control structure

Page 13: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 13/23

.• Code the program.

• After the ro ram has been desi ned it must the be coded or

written.• Using the psudocode and logic requirements from step two an

a ro riate ro rammin lan ua e must be selected.

• As stated in the introduction, coding languages differ inspecifications and usability. Once the appropriate code languagehas been chosen it is im erative that the ro rammer follow thesytax rules with as little deviation as possible.

  – Select the appropriate high-level programming language

 – Code the program in that language following the syntax carefully

Page 14: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 14/23

. ,• Testin the ro ram comes in two hases al ha  and

beta .• Alpha testing is the process of reading through the

program n searc o errors n og c. e secon s ep sto run a diagnostic program to search for syntax or input

errors.

• Beta testing involves using the program in the real worldto see if it contains any bugs or other deficiences.

• e ugg ng s a me o ca process o n ng anreducing the number of bugs, or defects, in a computerro ram thus makin it behave as ex ected.

Page 15: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 15/23

.• Documentation should be on oin from the ver

beginning because it is needed for those involved withprogram now and future.

• pon comp e on ser ocumen a on  or commerc ause, Operator Documentation for people who run

computer systems, and Programmer Documentation forprogrammers charged with maintenancing the programare all issued.

  – Write user documentation

 – Write operator documentation

 – Write programmer documentation

 – Mantain the program

Page 16: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 16/23

Structured Design UsingFlowcharts

• Simple programming exercises can often be solved byust s tt ng own an wr t ng co e to mp ement t e

desired problem.• Complex problems, however, can be difficult to write and

mposs e o e ug no mp emen e us ng astructured design process.

• Using a structured design proses leads to the following

 – Early detection of design flaws. – Programs that can be easily modified.

 – Clear and complete documentation. – Modular design to improve testing. – 

sections.

Page 17: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 17/23

• The application of a structure design methodology

successful design with a minimum amount of time andexpense.

,

of finding design flaws early improves considerably.• Finding design flaws early in the design process greatly

.• Structured design methods also improve the ability to

modify programs at a later date since the techniquesdocumentation much easier.

• Structured designs can also be more easily broken upinto modules to im rove testin and to allow 

development by multiple design teams with a reasonableassurance that the resulting products will be compatiblewith each other.

Page 18: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 18/23

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 diamond indicates a decision.• A connector (a small circle) means that the logic is continued at another place on thesame page.

- .• A rectangle within a rectangle indicates a predefined process (or subroutine).

subroutine

Page 19: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 19/23

Program Execution Structures• Structured design using flowcharts generally involves a top-

down analysis of the problem to be solved.•

basic patterns: sequence, decision (branch), repetition andsubroutine.

• A program is composed of combinations of these basicstructures.

• The Sequence Structure impliesthat the logic is executed in simplesequence, one block after another.

represent one or more actualinstructions.

Page 20: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 20/23

• In a Decision/ Branch Structure, acondition is tested.

• If the condition is true the lo ic 

associated with the THEN branch isexecuted and the ELSE block isskipped.

• e con on s a se e og cis executed and the THEN logic is

skipped.• Note that the THEN and ELSE blocks

might represent one or more actualinstructions.

• Note also that a given THEN or ELSE

decision block, yielding nesteddecision logic.

Page 21: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 21/23

• There are two basic patterns for showing repetitive/loop structure.

• In a DO WHILE block, the test is performed first and the associated.

• In a DO UNTIL block, the associated instructions are executed first andthen the exit condition is tested.

• Note that the logic block associated with a DO WHILE or DO UNTILmight represent one or more actual instructions.

Page 22: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 22/23

• A subroutine structure functions as aself-contained block of code.

• However it is embedded in a lar e blockof code and must interact with the calling

program.

• A flowchart for a routine calls anothersubroutine that perform anotheroperations that the detailed logic is

flowcharted elsewhere.• In effect, using predefined processes

allows the designer to decompose thelogic.

Page 23: Addressing Modes & Programming (2009)

8/3/2019 Addressing Modes & Programming (2009)

http://slidepdf.com/reader/full/addressing-modes-programming-2009 23/23