George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.

Slides:



Advertisements
Similar presentations
Programming 68HC11.
Advertisements

Cpe 252: Computer Organization1 Lo’ai Tawalbeh Programming The Basic Computer Chapter 6:
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
The Assembly Language Level
Lab6 – Debug Assembly Language Lab
Assembler Programming Chapter 6. EEL-4746 Best Practices.
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
8051 ASSEMBLY LANGUAGE PROGRAMMING
EET 2261 Unit 2 HCS12 Architecture
MIPS Instruction Set Advantages
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
© 2010 Kettering University, All rights reserved..
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
A Simple Two-Pass Assembler
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
Machine Instruction Characteristics
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Eng.Samra Essalaimeh Philadelphia University 2013/ nd Semester PIC Microcontrollers.
Objectives Implement pointers using indexed addressing modes Use pointers to access arrays, strings, structures, tables, and matrices Present finite-state.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
Ass. Prof. Dr Masri Ayob TK 6123 Lecture 13: Assembly Language Level (Level 4)
6-1 EE 319K Introduction to Microcontrollers Lecture 6: Indexed Addressing Mode and Variants, Functional Debugging, Arrays, Strings.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
1 Segments and Pseudo Operations Program Development.
Assembly Language ELEC 330 Digital Systems Engineering Dr. Ron Hayne.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Ch.2 Intro. To Assembly Language Programming
ECE Lecture 21 Typical Assembly Language Program Bugs.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
Advanced Assembly Language Programming
© 2010 Kettering University, All rights reserved..
Embedded Systems Lecture 5 January 25 th, 2016.
Subroutines and Stacks. Stack The stack is a special area in memory used by the CPU to store register information or general data information during program.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
ECE 3430 – Intro to Microcomputer Systems
Addressing Modes in Microprocessors
ECE 3430 – Intro to Microcomputer Systems
Wed. Sept 6 Announcements
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 3430 – Intro to Microcomputer Systems
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
8051 ASSEMBLY LANGUAGE PROGRAMMING
The .ASCII and .END Assembler Input ;Stan Warford ;January 13, 2005
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
Part I Data Representation and 8086 Microprocessors
Presentation transcript:

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume Lecture #11

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/ Write an assembly language program to clear the usable internal RAM in the MC9S12C32 [$0800 to $0DFF] Solution: Clear Locations $ $0DFF. ORG$1000 LDX#$0800 LOOPCLR$00,X INX CPX#$0E00 BNELOOP SWI END (NOTE: You should hand-assemble this program.) Homework Set #1 Solution

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Set #1 Solution 2. Write a program to add even/odd numbers located in addresses $0000 through $00FE. Solution: (for adding odd numbers) ORG$1000 LDY#$ CD0000 LDX#$ CE0000 INDLDAA#$FF100686FF LDAB$00,X1008E600 BITB #$01100AC501 BEQEVEN100C2702 ABY100E19ED EVENINX STX$ E2000 EORA $ B82001 BNE IND101726ED SWI10193F END OR DECA 4A If you use this, then IND should be moved down to the next line st Time $2001: Acc A:

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Set #1 Solution 2. Write a program to add even/odd numbers located in addresses $0800 through $0900. Solution: (for adding odd numbers) ORG$1000 LDY#$ CD0000 LDX#$ CE0800 INDLDAB$00,X1006E600 BITB #$011008C501 BEQEVEN100A2702 ABY100C19ED EVENINX 100E08 CPX#$ F8E0901 BNE IND101226ED SWI10143F END

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Write an assembly language program to find the largest signed number in a list of numbers stored in address $0020 thru $0029, and store it in $2000. Repeat for unsigned number. FIRSTEQU$0020 LASTEQU$002A ANSWREQU$2000 ORG$1000 LDX#FIRST LDAAFIRST STAAANSWR INXGoes with DECB. If DECB is removed, then LDAB#$0A LDAB must be removed NUBLDAA$00,X CMPAANSWR(A - ANSWR) BLENEXT; (signed)* *(Branches if 2's complement number in register A is less than or ORequal to the 2's complement number represented by ANSWR) BLSNEXT; (unsigned)****(Branch if lower or same, i.e, Branch if register A was lower or same as ANSWR) STAAANSWR NEXTINX CPX#LAST OR DECB BNENUB SWI END Homework Set #2 Solution

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Set #2 Solution Continued Signed Example: #$3F (positive) #$F4 (negative) Convert Numbers to Decimal: #$F4 = % 's Comp#$0B = % 's Comp#$0C = % #$F4 = #$3F = % #$3F = #$3F is larger than #$F4 since is larger than Un-Signed Example: #$3F (positive) #$F4 (positive) Convert Numbers to Decimal: #$F4 = % #$F4 = #$3F = % #$3F = #$F4 is larger than #$3F since is larger than 63 10

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Set #3 Solution 1. Write a subroutine to save the first 5 odd (8-bit) numbers pointed to by the x-register (passed in) onto the stack. Solution: SUB1LDAA#$05 PULY NEXTBRSET$00,X #$01 ODD INX BRANEXT ODDLDAB$00,X PSHB INX DECA BNENEXT PSHY RTS Note: For subroutine to execute in main program, a BSR or JSR command must be used in main program.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Set #3 solution 2. Write a program to output a square wave thru port S pin The output can be observed on the scope, and the period T of the wave should be measured. More than one period wave should be generated. The machine cycle time of the MC9S12C32 should be estimated. Draw the square wave.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Solution Cont’d Solution: ORG $2000 FCB$XX FCB$04 ORG$1000 LDAA#$04 STAA$024A LDAB#$04 CYCLELDAA$20013 STAA$02483 EORA#$041 STAA$20013 LDAA$20003 NEXTDECA1 BNENEXT3/1 DECB1 BEQ EXIT3/1 JMPCYCLE3 EXITSWI END OpcodePostbyteOperandAddress A024A 1005C B A7A D F7A B FD B E3F Configures PS2 as output. Outputs signal from PS2 T/2=Machine Cycle Time*[ COUNT*(1)+(COUNT-1)* ] (Note: Count = #$XX) Switch $2001(toggle) Delay Helps us to output two periods. (Note: BNE and BEQ take 3 machine cycles to execute if the branch is taken and one machine cycle if it is not taken)

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405

ME4447/6405 ASCII Character Codes ASCII – American Standard Code for Information Interchange ASCII assigns a hexadecimal ‘code’ to individual characters Examples: CharacterASCII ‘A$41 ‘E$45 ‘e$65(Note: Different codes for lower and upper case) ‘1$31 BS$08(Note: BS is Backspace. ) A microcontroller must send these codes to a display terminal in order for the terminal to display these characters.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ASCII Character Codes (continued) Hex to ASCII Conversion table from Programming Reference Guide Page 58

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ASCII Character Codes An array of characters is called a string Example: character arrayStringASCII Representation ‘H ‘e ‘l ‘l ‘o “Hello”$48 $65 $6C $6C $6F (Note: CharacterASCII ‘H$48 ‘e$65 ‘l$6C ‘o$6F )

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405

ME4447/6405 Assembly Directive Types Assembly Control ORG, END Symbol Definition EQU Data Definition/Storage Allocation FCC, FCB, FDB, RMB, ZMB, BSZ, FILL Listing Control PAGE, OPT

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Assembly Control

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG and END ORG : Store translated machine language instructions in sequence starting at given address for any mnemonic instructions that follow END: Stop translating mnemonics instructions until another ORG is encountered (Note: These were already discussed in Lecture 7)

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Symbol Definition

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 EQU EQU lets you refer to a number or an address as a variable name. Example: VALAEQU $10*LABEL VALA USED TO REFER TO $10 ORG $1000 LDAA #VALA*LOAD HEX NUMBER $10 IN ACCUMULATOR A LDAB VALA*LOAD CONTENT OF MEMORY LOCATION $10 *IN ACC. B SWI END Same As: VALAEQU $10*LABEL VALA USED TO REFER TO $10 ORG $1000 LDAA #$10*LOAD HEX NUMBER $10 IN ACCUMULATOR A LDAB $10*LOAD CONTENT OF MEMORY *LOCATION $10 IN ACC. B SWI END

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Data Definition/Storage Allocation

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FCC FCC – Form Constant Character string FCC stores ASCII characters into consecutive bytes of memory. Any printable ASCII characters can be contained in the string. String is specified between two identical delimiters, which can be any printable ASCII character. First non-blank character after the string is used as a delimiter.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FCC Cont’d $0400 $0401 $0402 $0403 $0404 Address PrebyteOpcode Operand Example: ORG $0400 FCC “12345” Result

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FCB FCB – Form Constant Byte FCB has one or more operands. Value of each operand is truncated to eight bits, and is stored in single byte of object program. Operand may be a numeric constant, character constant, a symbol or an expression. Multiple operands are separated by commas, and are stored in successive memory bytes.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FCB Cont’d Example: VALA EQU $10 ORG $0400 FCB $34,’A, $28AC, $0A,VALA $0400 $0401 $0402 $0403 Address PrebyteOpcode Operand AC 0A Result $040410

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FDB FDB – Form Constant Double Byte FDB stores a double (two byte) word. May have one or more operands separated by commas. Operand may be a numeric constant, a character constant, a symbol, or an expression.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FDB Cont’d Example: ORG $0400 FDB $1234,’&,’G Note: ASCII value for & is $26 ASCII value for G is $47 $0400 $0401 $0402 $0403 $0404 Address PrebyteOpcode Operand $0405 Result

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 RMB RMB – Reserve Memory Byte RMB saves a place in memory for a number. Example: ORG $0400 XVAR RMB 2 *TWO MEMORY *LOCATIONS $0400 *and $0401 ARE *RESERVED FOR XVAR ORG $1000 LDD #$FFAA STD XVAR SWI END $0400 $0401 Address PrebyteOpcode Operand FF AA Result

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Question a student asked: What happens if you change the previous example to "XVAR RMB 3" instead of "XVAR RMB 2" ? What happens to the 3rd reserved byte when a 2 byte number is stored in XVAR? Modified Program: ORG $0400 XVARRMB 3 ORG $1000 LDD #$FFAA STD XVAR SWI END Answer: Remains unchanged

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ZMB, BSZ ZMB – Zero Memory Byte and BSZ – Block Storage of Zero These directives fill a given number of memory locations with zero. Causes assembler to allocate a block of memory bytes, and each memory byte is assigned a value of zero. Both directives do the same thing. Number of bytes allocated is given in the operand field. Example: ORG $0400 ZMB #$02 BSZ #$02 $00 $01 Address PrebyteOpcode Operand 00 $02 $03 00 Result

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 FILL Fill given number of memory locations with any number. (Note: Fill uses one byte. If two bytes are specified, then it will truncate it and use LS Byte.) Example: ORG $0400 FILL #$FF, #$02 $00 $01 Address PrebyteOpcode Operand FF Result

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Question a student asked: What happens when the previous example is changed to "FILL #$9ABC, #$02" instead of "FILL #$FF,#$02"? What happens if you fill memory with a 2 byte number? Answer: FILL will just use the LS Byte Modified Example: ORG $0400 FILL #$9ABC,#$02 END (Note: There is no ”go 1000” on the screen since these are just assembly directives and not a program)

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Listing Control

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 PAGE The PAGE directive causes a page break in the list file. If no source listing is being produced, the PAGE directive will have no effect. The directive is not printed on the source listing.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 OPT Allows for various options in assembly of a program, including generating a listing and counting instruction cycles. Options: nol-no output listing (default) l-do an output listing noc-no cycle number count (default) c-turn on cycle count using zero initial value contc-turn cycle count on, begin with last value cre-create a cross reference table (default anyway) RMB s-create a symbol table (default anyway) EQU Example: OPT l – Print source listing from this point

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework 3 Solution Write a subroutine to save the first 5 odd (8-bit) numbers pointed to by the x-register (passed in) onto the stack. Solution: SUB1LDAA#$05 PULY NEXTBRSET$00,X #$01 ODD INX BRANEXT ODDLDAB$00,X PSHB INX DECA BNENEXT PSHY RTS Note: For subroutine to execute in main program, a BSR or JSR command must be used in main program.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework 4 solution Write a program to output a square wave thru port S pin 2. The output can be observed on the scope, and the period T of the wave should be measured. More than one period wave should be generated. The machine cycle time of the MC9S12C32 should be estimated. Draw the square wave.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework 4 Solution Cont’d Solution: ORG $2000 FCB$XX FCB$04 ORG$1000 LDAA#$04 STAA$024A LDAB#$04 CYCLELDAA$20013 STAA$02483 EORA#$041 STAA$20013 LDAA$20003 NEXTDECA1 BNENEXT3/1 DECB1 BEQ EXIT3/1 JMPCYCLE3 EXITSWI END OpcodePostbyteOperandAddress A024A 1005C B A7A D F7A B FD B E3F Configures PS2 as output. Outputs signal from PS2 T/2=Machine Cycle Time*[ COUNT*(1)+(COUNT-1)* ] (Note: Count = #$XX) Switch $2001(toggle) Delay Helps us to output two periods. (Note: BNE and BEQ take 3 machine cycles to execute if the branch is taken and one machine cycle if it is not taken)

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 QUESTIONS???