EE357Unit5_ColdfireAssembly

EE357Unit5_ColdfireAssembly - 8/26/10 Assembler Syntax An...

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

View Full Document Right Arrow Icon
8/26/10 1 © Mark Redekopp, Al rights reserved EE 357 Unit 5 Assembler Directives and Programming © Mark Redekopp, Al rights reserved Assembler Syntax • An assembler takes a source code file and builds a memory image (binary) executable file – Specifies the location in memory (either relative or absolute) of data and instructions • In Coldfire assembler each line of the assembly program may be one of three possible options – Comment – Instruction – Assembler Directive © Mark Redekopp, Al rights reserved Comments • In Codewarrior for CF an entire line can be marked as a comment by starting it with an asterisk (*) character or the C-style comments of // or /* */: • Example: * This line will be ignored by the assembler // This line will be ignored too /* As will this one */ MOVE.L D2,D3 ADD.L (A0),D3 ... © Mark Redekopp, Al rights reserved Instructions In Codewarrior each instruction is written on a separate line and has the following syntax: (Label:) Instruc. Op. Operands Comment Example: START: MOVE.L D3,D2 ; Initialize D2 Notes: Label is optional and is a text identifier for the address where the instruction is placed in memory. (These are normally used to identify the target of a branch or jump instruction.) Everything after the semicolon (;) will be treated as a comment
Background image of page 1

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

View Full DocumentRight Arrow Icon
8/26/10 2 © Mark Redekopp, Al rights reserved Labels Labels are text placeholders for a location in your code The optional label in front of an instruction or other directive evaluates to the address where the instruction or data starts in memory and can be used in other instructions Can be any alphanumeric string (or start with a ‘.’ or ‘_’) but should be terminated with a colon ‘:’ .text START: MOVE.W #3,D0 .L1: MOVE.B #0xFF,D3 BRA . L1 MOVE.W 0003 MOVE.B 00FF BRA START = 0x1000 0x1002 .L1 = 0x1004 0x1006 0x1008 .text START: MOVE.W #3,D0 .L1: MOVE.B #0xFF,D3 BRA 0x1004 Assembly Source File …and replaces the labels with their corresponding address Assembler finds what address each instruction starts at… Note: The BRA instruc. causes the program to branch (jump) to the instruction at the specified address © Mark Redekopp, Al rights reserved Assembler Directives Direct the assembler in how and where to… – Assemble the actual instructions – Initialize memory before executing the first instruction of the program Similar to pre-processor statements and global variable declarations in C/C++/Java – #DEFINE, etc. – int x = 1; © Mark Redekopp, Al rights reserved Assembler Directive Overview Directive Description .text, .data Section directives for program code or data variables .org Indicates where to place the following code/variables in memory .equ / .set Defines a constant replacement value (like #define in C) .long, .short, .byte
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

EE357Unit5_ColdfireAssembly - 8/26/10 Assembler Syntax An...

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