[GNU M68HC11 HOME]

FAQ for GNU 68HC11&68HC12

Help | FAQ


Overview
Compiler
Documentation
Examples
Misc
Help
IDE & Tools

Download
Install

Links
Projects






This FAQ is intended to list a number of questions that arise quite often.

Note:Feel free to send suggestions and new FAQ entries.

Is S19 format supported?
S19 and Intel Hex records are supported for many many years by the GNU Binutils. They are not the native format because they do not provide all the information that a linker and a debugger need (symbols, relocation, debug information).

How can I generate S19 files?
There are two ways to generate S19 files:
  • By using the m6811-elf-objcopy tool.
    If you have an ELF file file.elf, you can translate it into S19 using the following command:
    m6811-elf-objcopy --output-target=srec --only-section=.text \
    		  --only-section=.rodata --only-section=.vectors \
    		   file.elf file.s19 
    		
  • By using the --oformat=srec linker option.

How can I migrate assembly sources to GNU as?
Use the --mri option of GNU as. This option enables a kind of compatibility mode with Motorola Assembly Language Specification. There are however a few restrictions:
  • The ORG command is not supported. Replace them with a definition of a section (section name).
  • Single quote strings are not supported (CVS Binutils only).

What is the crt0 and how can I remove it?
The startup file crt0 is used to initialize the stack, install the data section (initialized variables), clear the bss section (uninitialized global and static variables), prepare and jump to the main. The startup file is automatically linked at beginning of each program. It is possible to avoid to use the default crt0 by doing the following:
  • Write your own startup code. This can be written in C or in assembly. The entry point should be named _start.
  • Pass the -nostartfiles option to m6811-elf-gcc during the final link. This option suppresses the link with the crt0 file.

How can I inline assembly in C?
Gcc allows you to inline assembly within C source code. The assembly instruction can have input and output parameters to interact with the C code. An inline assembly without arguments is written as follows:
	   asm volatile ("cli");
	
The volatile keyword is optional. It tells Gcc not to optimize the instruction by not removing or changing its place within the code. It is more than recommended to use it.

Input and output parameters are specified by constraints. The constraint is a string that indicates the characteristics of the operand in terms of constant, register, memory and so on. The output operands are listed first and introduced by =. The following instruction:

	   asm volatile ("tpa\n\tsei" : "=d"(mask));
	
defines an output operand that is read from register d and put in the local variable named mask.

A more complete description about the asm mechanisms is presented in the following sections:

What is the memory.x?
This file is used when you use the m68hc11elfb linker script. It defines memory banks that tells the linker where to put the text, data and other sections. A typical memory.x file defines the MEMORY banks as follows:
	MEMORY
	{
	  page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
	  text  (rx)  : ORIGIN = 0xE000, LENGTH = 2048
	  data        : ORIGIN = 0x0, LENGTH = 0
	}
	

How does the linker know where memory.x is?
The memory.x is searched in the current directory and in all the directories specified with the -L option. There is also a default directory which is /usr/m6811-elf/lib or xxx\m6811-elf\lib.
How can I setup an interrupt table for a ROM?
A special section exists for the definition of the interrupt vector table of the 68HC11 or 68HC12. The vectors must be in a section named .vectors.

In assembly, use:

        .sect .vectors
	
With gcc, use:
	__attribute__ ((section (".vectors")))
	
[GNU M68HC11 HOME]
Help | FAQ

    Last modified,
    Sep 29, 2001
[ Copying ]     [ Feedback to Stephane.Carrez@worldnet.fr ]