1 / 26

ECE 265 – Lecture 9

ECE 265 – Lecture 9. PROGRAM DESIGN. Lecture Overview. Program Design General Overview Program Design Methodology Assembler Language Assembler Directives REF: Chapter 4. Program Design. General Overview

nara
Download Presentation

ECE 265 – Lecture 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE265 ECE 265 – Lecture 9 PROGRAM DESIGN

  2. Lecture Overview • Program Design • General Overview • Program Design Methodology • Assembler Language • Assembler Directives • REF: Chapter 4 ECE265

  3. Program Design • General Overview • From the text page 89: “The design of an embedded microcontroller system requires an integrated use of hardware and software.” • Hardware and software provide a natural division of the view of the system. Embedded systems require well designed interaction between these two divisions. • The software design needs to follow established methodologies. ECE265

  4. Software Design Methodology • The software of the system is typically called a Software Program. • A software program is software compiled and assembled into executable code for the target machine. • Window7 is a program designed as the operating system for general purpose PCs and will run on hardware structured to support that OS. ECE265

  5. Top-down design methodology • A popular design methodology for software is Top-Down design and Bottom-up coding. • It starts with a specification of the system at the top level. • This top-level is then broken down into major tasks and subtasks. • Each major task (and subtask) is broken down into smaller subtasks as appropriate. ECE265

  6. Top-Down Design • Graphical illustration of the Top-down design methodology. • The number of levels continues until the subtask is one that can be directly coded. ECE265

  7. Benefits of the top-down method • Each subtask is independent of other subtasks, allowing the programmer to design, write and test each module independently. • Errors can be detected and corrected in a logical manner. • Mentally, the programmer only has to grasp one subtask at a time. • A team of programmer can be used to accomplish the project faster. • Program modules can be used in future applications. For example, your program needs to use a linked list data structure. Most likely the routines to manage and manipulate a linked list are available. ECE265

  8. Statement of the problem • Where it all starts. • The highest level of abstraction • The statement of the problem to be solved • Requires full analysis of the problem to be addressed and the system being designed to address it. ECE265

  9. An example of the methodology • Example 4.2 from the Text. ECE265

  10. Assembler language programming • A good practice is never to program in assembler language directly. • Start with the specification of the module to be coded. • Code it in a Pseudo Design Language or PDL • PDL is much like any high level programming language. ECE265

  11. Assembler Language • Assembler Language is specific to the machine (processor architecture). • Each processor version may have instructions that other versions do not have. • Assembler language has a 1-to-1 relationship with the machine language, i.e., executable code of the processor. • One assembler language statement • = • one executable instruction. ECE265

  12. Assembler language • Usually written line by line where each line is 80 character long. • Within the 80 character line there are fields. Field position can be fixed. For example: • The first 10 characters are a label • The next field is for the operand or assembler directive • This is followed by the operand field • The last filed is for comments ECE265

  13. The 68HC11 format • Each assembler language statement is on one line • Starts in column 1 and has 4 fields • The label field • The op code field • The operand filed • The comment field • THE LABEL FIELD • Starts in column 1 • Can be blank • Label can be up to 15 characters in length • Upper case is distinct from lower case and must start with a character • TDREG1 is valid 1TDREG is not valid • Delimited (ended) by a ‘:’ or a ‘ ’ ECE265

  14. The 68HC11 format (cont) • The operation field • Must start in column 2 or after • Best to start in the same column for the complete program • Contains the instruction mnemonic such a LDAA, OR • an assembler directive OR • a macro call • Operand Field • The field contains the instruction operand or argument for assembler directives • Numbers in this field are identified by some symbols that can precede the number • None A decimal number • $ The number is a hexidecimal number • @ The number is an octal number • % The number is a binary number ECE265

  15. 68HC11 formal continued • The comment field • The last field is a comment field and is separated from the previous filed by at least one space • An optional field • Can have any printable ASCII character as this field is used for documentation • Can be continued (or you can use any line as a comment) by starting the line with a *. These lines are considered as comments and anything on the line is considered a comment, i.e., no assembly takes place. • LABEL: OPCODE OPERAND COMMENT ECE265

  16. Assembler directives • These are direction to the assembler to perform a particular task or set up a specific condition. • The assembler directives are ECE265

  17. NAM directive • Give the program a name. • Documentation only. There is no impact on the machine code generated. • NAM Pressure Monitoring ECE265

  18. ORG directive • Used extensively and common to all assemblers. • Sets the location (physical location) counter to a set value. • Example • ORG $C000 • CNTMAX RMB 2 • This would place the 16-bits for CNTMAX at address $C000 and 2 bytes of memory are set aside. • ORG $D000 • START LDAA #$46 • x • x • Here the ORG place the executable code to start at address $D000 and the label START would have a value of $D000 • Memory address $D000 contains $86, • the op code for LDAA immediate mode ECE265

  19. END directive / EQU directive • END simply indicates that this is the last source code line. • EQU allows a value to be given to label for more readable and understandable code. • <label> EQU <expression> [<comment>] • EX • ADCTL EQU $1030 Location of the A/D control • register. ECE265

  20. FCB directive • Form Constant Byte • This directive can have more than one value in the operand field. • EX • DIGITS FCB 0, 1, 2, 3 Fills a 4-byte memory • buffer labeled with DIGITS • with values 0,1,2, and 3 • MYHEX FCB $32 Fills the location MYHEX • with a value of $32. ECE265

  21. FCC directive • FCC is much like FCB except that now the memory locations are filled with the ASCII code for the characters in the string. • [<label>] FCC ‘<ASCII string>’ • Note the use of single ’s • Example • MYLAB FCC ‘my ASCII string’ ECE265

  22. RMB • RMB with reserve space in memory and attach a label to that location that can be used in the assembler code to refer to the location. Does not affect the value in the location. • EX • MRCNT RMB 1 Reserve 1 byte • TREG1 RMB 2 Reserve 2 bytes • TEBUFF RMB 12 Reserve 12 bytes ECE265

  23. SET directive • The SET directive established the value for a label being used in the assembler code. • <label> SET <expression> • EX • COUNT SET #40 sets the value for the label • COUNT to 40. Any time COUNT • is used it is the same as using 40 • If you later reassign a value to the label, that value will be the new value for the label. ECE265

  24. BTEXT and ETEXT Directives • These directives allows the programmer to insert blocks of text easier than with the other directives. • No need for starting and ending quotes on each line • EXAMPLE • BTEXT • These lines will be ignored • by the assembler • but will appear in the LST file. • ETEXT • A BTEXT must be ended by a ETEXT ECE265

  25. Lecture summary • Program Design • General Overview of software • Program Design Methodology • Assembler Language in general • Assembler Directives for the 68HC11 ECE265

  26. Assignment • Problems : Chapter 4 page 127 – Prob 7 ECE265

More Related