From f2b214b0dff95d6bb79cbb5b6ff5ba9d90f655c9 Mon Sep 17 00:00:00 2001 From: oharboe Date: Wed, 2 Jan 2008 21:52:27 +0000 Subject: Initial import from www.ecosforge.net --- zpu/roadshow/roadshow/codesize/index.html | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 zpu/roadshow/roadshow/codesize/index.html (limited to 'zpu/roadshow/roadshow/codesize/index.html') diff --git a/zpu/roadshow/roadshow/codesize/index.html b/zpu/roadshow/roadshow/codesize/index.html new file mode 100644 index 0000000..3f61b4e --- /dev/null +++ b/zpu/roadshow/roadshow/codesize/index.html @@ -0,0 +1,58 @@ + + +

Compiling hello world program with the ZPU GCC toolchain

+The ZPU comes with a standard GCC toolchain and an instruction set simulator. This allows compiling, running & debugging simple test programs. The Simulator has +some very basic peripherals defined: counter, timer interrupt and a debug output port. +

Installation

+
    +
  1. Install Cygwin. http://www.cygwin.com +
  2. Start Cygwin bash +
  3. unzip zputoolchain.zip +
  4. Add install/bin from zputoolchain.zip to PATH.
    +export PATH=$PATH:/install/bin +
+

Hello world example

+The ZPU toolchain comes with newlib & libstdc++ support which means that many C/C++ programs can be compiled without modification. +

+ +zpu-elf-gcc -Os -zeta hello.c -o hello.elf -Wl,--relax -Wl,--gc-sections
+zpu-elf-size hello.elf
+
+

Optimizing for size

+The ZPU toolchain produces highly compact code. +
    +
  1. Since the ZPU GCC toolchain supports standard ANSI C, it is easy to stumble across +functionality that takes up a lot of space. E.g. the standard printf() function is a beast. Some compilers drop e.g. floating point support +from the printf() function and thus boast a "smaller" printf() when in fact they have a non-standard printf(). newlib has a standard printf() function +and an alternative iprintf() function that works only on integers. +
  2. The ZPU ships with default startup code that works across various configurations of the ZPU, so be warned that there is some overhead that will +not occurr in the final application(anywhere between 1-4kBytes). +
  3. Compilation and linker options matter. The ZPU benefits greatly from the "-Wl,--relax -Wl,--gc-sections" options which is not used by +all architectures(e.g. GCC ARM does not implement/need -Wl,--relax). +
+

Small code example

+ +zpu-elf-gcc -Os -abel smallstd.c -o smallstd.elf -Wl,--relax -Wl,--gc-sections
+zpu-elf-size small.elf
+
+$ zpu-elf-size small.elf
+ text data bss dec hex filename
+ 2845 952 36 3833 ef9 small.elf
+
+
+ +

Even smaller code example

+If the ZPU implements the optional instructions, the RAM overhead can be reduced significantly. +

+ +zpu-elf-gcc -Os -abel crt0_phi.S small.c -o small.elf -Wl,--relax -Wl,--gc-sections -nostdlib
+zpu-elf-size small.elf
+
+$ zpu-elf-size small.elf
+ text data bss dec hex filename
+ 56 8 0 64 40 small.elf
+
+
+ + + -- cgit v1.1