Microcontroller2

Microcontroller2 - 1/13/2011 1 MC9S12 Assembly Language...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1/13/2011 1 MC9S12 Assembly Language Programming (Chapter 2) A.H. Mohsenian-Rad (U of T) 1 Networking and Distributed Systems HCS12 Assembly Instructions Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-2 Each line of an HCS12 assembly program usually includes four parts: The assembler translates the assembly instructions to machine code . For example, the instruction ldaa #$10 becomes: begin ldaa #$10 ; we begin by loading 10 into A. inca ; we increment A bra begin begin ldaa #$10 ; we begin by loading 10 into A. inca ; we increment A bra begin Label Operation Operand Comment $86 $10 HCS12 Assembly Instructions Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-3 Assembler uses the opcode map for asm/machine code translation: Use the following to understand the numbers: b b Assembler Directives Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-4 Besides instructions, a program may also include several assembler directives to guide the assembler in generating the machine code. Assembler directives look like instructions but they are not translated to machine code. Examples: END ORG DB, DC.B, FCB DW, DC.W, FBD FCC EQU 1/13/2011 2 Assembler Directives Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-5 END Ends a program to be processed by an assembler. Any statement following the END directive is ignored by assembler. ORG The assembler uses a location counter to keep track of the memory location where the next machine code byte should be placed . ORG sets a new value for the location counter of the assembler. Assembler Directives Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-6 For example, the following code will be translated to org $1000 begin ldaa #$10 ; we begin by loading 10 into A. jmp begin end org $1000 begin ldaa #$10 ; we begin by loading 10 into A. jmp begin end 86 10 06 $1000 10 00 jmp begin ldaa #$10 $1001 $1002 $1003 $1004 Assembler Directives Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-7 In this course, always use org to put your code and your data somewhere in the RAM between address $1000 and $3FFF . Hex Code Hex Code Hex Code $1000 Hex Code Hex Code $1001 $1002 $1003 $3FFD Hex Code Hex Code $3FFE $3FFF Assembler Directives Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 2-8 DC.B, DB, FCB These three directives define the value of a byte or bytes that will be placed at a given location....
View Full Document

Page1 / 16

Microcontroller2 - 1/13/2011 1 MC9S12 Assembly Language...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online