Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/2015 1 ECE265.

Similar presentations


Presentation on theme: "ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/2015 1 ECE265."— Presentation transcript:

1 ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/2015 1 ECE265

2 Lecture Overview  Program Design  General Overview  Program Design Methodology  Assembler Language  Assembler Directives  REF: Chapter 4 8/12/2015 2 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. 8/12/2015ECE265 3

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. 8/12/2015ECE265 4

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. 8/12/2015ECE265 5

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. 8/12/2015ECE265 6

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. 8/12/2015ECE265 7

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. 8/12/2015ECE265 8

9 An example of the methodology  Example 4.2 from the Text. 8/12/2015ECE265 9

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. 8/12/2015ECE265 10

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. 8/12/2015ECE265 11

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 8/12/2015ECE265 12

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 ‘ ’ 8/12/2015ECE265 13

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 8/12/2015ECE265 14

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 8/12/2015ECE265 15

16 Assembler directives  These are direction to the assembler to perform a particular task or set up a specific condition.  The assembler directives are 8/12/2015ECE265 16

17 NAM directive  Give the program a name.  Documentation only. There is no impact on the machine code generated.  NAM Pressure Monitoring 8/12/2015ECE265 17

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  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 8/12/2015ECE265 18

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.  EQU [ ]  EX  ADCTL EQU $1030 Location of the A/D control  register. 8/12/2015ECE265 19

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. 8/12/2015ECE265 20

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.  [ ] FCC ‘ ’  Note the use of single ’s  Example  MYLAB FCC ‘my ASCII string’ 8/12/2015ECE265 21

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 RMB1 Reserve 1 byte  TREG1RMB2Reserve 2 bytes  TEBUFFRMB 12Reserve 12 bytes 8/12/2015ECE265 22

23 SET directive  The SET directive established the value for a label being used in the assembler code.  SET  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. 8/12/2015ECE265 23

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 8/12/2015ECE265 24

25 Lecture summary 8/12/2015ECE265 25  Program Design  General Overview of software  Program Design Methodology  Assembler Language in general  Assembler Directives for the 68HC11

26 Assignment 8/12/2015ECE265 26  Problems : Chapter 4 page 127 – Prob 7


Download ppt "ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/2015 1 ECE265."

Similar presentations


Ads by Google