Download presentation
Presentation is loading. Please wait.
Published byDarlene Riley Modified over 9 years ago
1
CE-2810 Dr. Mark L. Hornick 1 GNU GCC Assembler and C/C++ compiler
2
CE-2810 Dr. Mark L. Hornick 2 The Development System is basically the same Same old AVRStudio: Editor AVR Assembler Simulator/Debugger But in CE2810, instead of the AVR Assembler, we’ll be using: GCC Assembler GCC C compiler
3
CE-2810 Dr. Mark L. Hornick 3 AVRStudio has two Assemblers Built-in Atmel AVR Assembler This is the one you’ve been using so far Each project creates a single.hex file from a single.asm file Other.asm files have to be.included in the main.asm file
4
CE-2810 Dr. Mark L. Hornick 4 The GNU GCC Assembler/Compiler Projects can consist of one or more.s (assembly language) files.c (C language) files.cpp (C++ language) files
5
CE-2810 Dr. Mark L. Hornick 5 Differences between AVR and GNU assemblers Atmel.include “m32def.inc”.cseg.dseg.db “hello”, 0 LOW() HIGH().asm.org 0x2A GCC #include.section.text. section.data.asciz “hello” lo8() hi8().s automatic
6
CE-2810 Dr. Mark L. Hornick 6 Every.s file should contain the following GCC directives #include Definitions for PORTB, SPL, etc. #define _SFR_ASM_COMPAT 1 #define __SFR_OFFSET 0 Without this, aliases like PORTB are resolved to their data space address values (0x38) With this, PORTB is resolved to its corresponding I/O space address value (0x18) i.e. subtracts 0x20 from the data space address
7
Where is the Stack? CS-280 Dr. Mark L. Hornick 7
8
CS-1030 Dr. Mark L. Hornick 8 Review: Java Edit-Compile-Run Cycle Step One: Edit the program. Type in the program, using a text editor, and save the program to a file. Use the name of the main class and the suffix.java for the filename. This file is called a source file.
9
CS-1030 Dr. Mark L. Hornick 9 Review: Java Edit-Compile-Run Cycle Step 2: Compile the source file. The process of compiling the source file creates the bytecode file. The name of the compiler-generated bytecode file will have the suffix.class while its prefix is the same as the source file’s.
10
CS-1030 Dr. Mark L. Hornick 10 Java Edit-Compile-Run Cycle A sample source file and its bytecode file.
11
CS-1030 Dr. Mark L. Hornick 11 Review: Java Edit-Compile-Run Cycle Step 3: Execute the bytecode file. A java interpreter (VM) will go through the bytecode file and execute the instructions in it. If an error occurs while running the program, the interpreter will catch it and stop its execution. The VM starts execution at the bytecode instructions that correspond to the Java statement public static void main()
12
CS-1030 Dr. Mark L. Hornick 12 Review: Java Edit-Compile-Run Cycle The result after the interpreter executes the instructions in the bytecode file.
13
CS-1030 Dr. Mark L. Hornick 13 C Edit-Compile-Link-Run Cycle An additional step – Link Step One: Edit the program. Type in the program, using a text editor, and save the program to a file. Use the name of the main class and the suffix.c for the filename. This file is called a source file.
14
CS-1030 Dr. Mark L. Hornick 14 C Edit-Compile-Run Cycle Step 2: Compile the source file. The process of compiling the source file creates the object file. The name of the compiler-generated object file will have the suffix.o while its prefix is the same as the source file’s. The object file contains low-level processor- specific instructions, as well as references to functions in other object files or object libraries. It is not executable; i.e. you cannot run an object file.
15
CS-1030 Dr. Mark L. Hornick 15 C Edit-Compile-Link-Run Cycle Step 3: Link the object file(s). The process of linking the object file(s) creates the executable file. The name of the linker-generated executable file will have the suffix.hex while its prefix is the same as the primary source file’s. The executable file contains low-level processor- specific instructions; calls to other object libraries are resolved by the linking process. The executable file is downloadable to the Atmega32.
16
CS-1030 Dr. Mark L. Hornick 16 C Edit-Compile-Link-Run Cycle Step 4: Download the hex file. The Atmel bootloader loads the machine instructions from the hex file and writes them to Flash memory. The CPU’s Program Counter is set to the beginning of the program corresponding to main after some initialization code is executed.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.