1 / 16

GNU GCC Assembler

GNU GCC Assembler. and C/C++ compiler. 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. AVRStudio has two Assemblers.

olinda
Télécharger la présentation

GNU GCC Assembler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GNU GCC Assembler and C/C++ compiler 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 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 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 CE-2810 Dr. Mark L. Hornick

  5. Differences between AVR and GNU assemblers Atmel • .include “m32def.inc” • .cseg • .dseg • .db “hello”, 0 • LOW() • HIGH() • <file>.asm • .org 0x2A • GCC • #include <avr/io.h> • .section .text • . section .data • .asciz “hello” • lo8() • hi8() • <file>.s • automatic CE-2810 Dr. Mark L. Hornick

  6. Every .s file should contain the following GCC directives #include <avr/io.h> • 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 CE-2810 Dr. Mark L. Hornick

  7. Where is the Stack? CS-280 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. 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. CS-1030 Dr. Mark L. Hornick

  10. Java Edit-Compile-Run Cycle • A sample source file and its bytecode file. 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 statementpublic static void main() 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. 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. 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. 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. 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. CS-1030 Dr. Mark L. Hornick

More Related