LMM Floating Point Demo
Here's a small floating point program that fits in LMM memory.
It is using double precision variables and the 64 bit library which is default code generation.
For some reason using the -m32bit-doubles option makes the program to big for LMM.
Here's the code:
It is using double precision variables and the 64 bit library which is default code generation.
For some reason using the -m32bit-doubles option makes the program to big for LMM.
propeller-elf-gcc -o fpdemo.elf -Os -m64bit-doubles -Wall fpdemo.c -lm propeller-elf-strip fpdemo.elf ls -al fpdemo.elf -rwxr-xr-x 1 steve sudo 30656 Nov 8 15:35 fpdemo.elf Propeller Version 1 on /dev/ttyUSB0 Writing 30432 bytes to Propeller RAM. Verifying ... Upload OK! [ Entering terminal mode. Type ESC or Control-C to exit. ] Simple Floating Point Demo 1.000000 * 1.000000 = 1.000000 1.010000 * 1.100000 = 1.111000 1.020000 * 1.200000 = 1.224000 1.030000 * 1.300000 = 1.339000 1.040000 * 1.400000 = 1.456000 1.050000 * 1.500000 = 1.575000 1.060000 * 1.600000 = 1.696000 1.070000 * 1.700000 = 1.819000 1.080000 * 1.800000 = 1.944000 1.090000 * 1.900000 = 2.071000 1.100000 * 2.000000 = 2.200000 1.110000 * 2.100000 = 2.331000 1.120000 * 2.200000 = 2.464000 1.130000 * 2.300000 = 2.599000 1.140000 * 2.400000 = 2.736000 1.150000 * 2.500000 = 2.875000 1.160000 * 2.600000 = 3.016000 1.170000 * 2.700000 = 3.159000 1.180000 * 2.800000 = 3.304000 1.190000 * 2.900000 = 3.451000 1.200000 * 3.000000 = 3.600000 1.210000 * 3.100000 = 3.751000 1.220000 * 3.200000 = 3.904000 1.230000 * 3.300000 = 4.059000 1.240000 * 3.400000 = 4.216000 1.250000 * 3.500000 = 4.375000 1.260000 * 3.600000 = 4.536000 1.270000 * 3.700000 = 4.699000 1.280000 * 3.800000 = 4.864000 1.290000 * 3.900000 = 5.031000
Here's the code:
/**
* @file fpdemo.c
* Simple floating point demo.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double v1 = 1; // assign to supress uninitialized warnings
double v2 = 1;
printf("Simple Floating Point Demo\n");
while(v2 < 4)
{
printf("%f * %f = %f\n",v1,v2,v1*v2);
v1 += 0.01;
v2 += 0.1;
}
return 0;
}

Comments
Larger with 32 bit floats? That doesn't make any sense - there must be another compiler option you need to add.
By the way, how do you find out with GCC how big the actual C program is? 30k seems very large for such a small program, but presumably that 30k includes all the drivers, the libraries, the kernel etc?
Here is an example of the results of objdump on fibo.elf:
fibo.elf: file format elf32-propeller Sections: Idx Name Size VMA LMA File off Algn 0 .xmmkernel 0000065c 00000000 e0000000 00002f78 2**2 CONTENTS, ALLOC, LOAD, CODE 1 .header 0000000c 30000000 30000000 000000b8 2**0 CONTENTS, ALLOC, LOAD, DATA 2 .init 000000ac 3000000c 3000000c 000000c4 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE 3 .text 00002674 300000b8 300000b8 00000170 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 4 .fini 00000038 3000272c 3000272c 000027e4 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE 5 .hub 0000074c 00000000 30002764 0000281c 2**2 CONTENTS, ALLOC, LOAD, CODE 6 .ctors 00000008 0000074c 30002eb0 00002f68 2**2 CONTENTS, ALLOC, LOAD, CODE 7 .dtors 00000008 00000754 30002eb8 00002f70 2**2 CONTENTS, ALLOC, LOAD, CODE 8 .bss 00000220 0000075c 30002ec0 00002f78 2**2 ALLOC 9 .heap 00000004 0000097c 0000097c 000000b4 2**0 CONTENTS, ALLOC, LOAD, DATA 10 .debug_aranges 00000040 00000000 00000000 000035d4 2**0 CONTENTS, READONLY, DEBUGGING 11 .debug_info 000012bc 00000000 00000000 00003614 2**0 CONTENTS, READONLY, DEBUGGING 12 .debug_abbrev 00000338 00000000 00000000 000048d0 2**0 CONTENTS, READONLY, DEBUGGING 13 .debug_line 00000254 00000000 00000000 00004c08 2**0 CONTENTS, READONLY, DEBUGGING 14 .debug_frame 00000048 00000000 00000000 00004e5c 2**2 CONTENTS, READONLY, DEBUGGING 15 .debug_str 00000018 00000000 00000000 00004ea4 2**0 CONTENTS, READONLY, DEBUGGING 16 .debug_loc 0000154c 00000000 00000000 00004ebc 2**0 CONTENTS, READONLY, DEBUGGING 17 .debug_ranges 00000178 00000000 00000000 00006408 2**0 CONTENTS, READONLY, DEBUGGINGThe stuff you care about is:1) .xmmkernel which contains the COG image of the XMM kernel needed to run the program.
2) .header is a small header I put on all XMM programs that gives a tiny subset of the information from the ELF file. It is primarily used to find the start address and in flash/eeprom programs the address in flash/eeprom of the SRAM and hub initializers.
3) .init contains the C startup code
4) .text contains the program code and possibly constant data. We can also place COG images here that will later be loaded into a COG using coginit or cognew.
5) .fini contains the C finalization code
6) .hub contains data to be loaded into hub memory
7) .ctors contains C++ constructors and any other code that should run before main()
8) .dtors contains C++ destructors and any other code that should run after main() exits
9) .bss contains uninitialized data and doesn't take up any space in the object file. It is initialized to zero by the startup code
10) .heap is just the address where the heap will start.
This program was compiled with -mxmmc (similar to Catalina's SMALL memory model) so all data goes in hub memory. If it had been compiled with -mxmm (similar to Catalina's LARGE memory model) there would also be a .data section containing initialized data to be loaded into external RAM.
Thanks for the explanation David.