Questions tagged [sdcc]

SDCC is a retargettable, optimizing ANSI - C compiler suite that targets the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08) and Zilog Z80 based MCUs (Z80, Z180, GBZ80, Rabbit 2000/3000, and Rabbit 3000A). Work is in progress on supporting the Microchip PIC16 and PIC18 targets. It can be retargeted for other microprocessors.

SDCC is a retargettable, optimizing ANSI - C compiler suite that targets the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08) and Zilog Z80 based MCUs (Z80, Z180, GBZ80, Rabbit 2000/3000, and Rabbit 3000A). Work is in progress on supporting the Microchip PIC16 and PIC18 targets. It can be retargeted for other microprocessors.

The SDCC suite is a collection of several components derived from different sources with different FOSS licenses. The SDCC compiler suite includes:

  • sdas and sdld, a retargettable assembler and linker, based on ASXXXX, written by Alan Baldwin; (GPL).
  • sdcpp preprocessor, based on GCC cpp; (GPL).
  • ucsim simulators, originally written by Daniel Drotos; (GPL).
  • sdcdb source level debugger, originally written by Sandeep Dutta; (GPL).
  • sdbinutils library archive utilities, including sdar, sdranlib and sdnm, derived from GNU Binutils; (GPL)
  • SDCC run-time libraries; (GPL+LE). PIC device libraries and header files are derived from Microchip header (.inc) and linker script (.lkr) files. Microchip requires that "The header files should state that they are only to be used with authentic Microchip devices" which makes them incompatible with the GPL.
  • gcc-test regression tests, derived from gcc-testsuite; (no license explicitely specified, but since it is a part of GCC is probably GPL licensed)
  • packihx; (public domain)
  • makebin; (zlib/libpng License)
  • sdcc C compiler, originally written by Sandeep Dutta; (GPL). Some of the features include: extensive MCU specific language extensions, allowing effective use of the underlying hardware. a host of standard optimizations such as global sub expression elimination, loop optimizations (loop invariant, strength reduction of induction variables and loop reversing), constant folding and propagation, copy propagation, dead code elimination and jump tables for 'switch' statements. MCU specific optimizations, including a global register allocator. Adaptable MCU specific backend that should be well suited for other 8 bit MCUs. Independent rule based peep hole optimizer. A full range of data types: char (8 bits, 1 byte), short (16 bits, 2 bytes), int (16 bits, 2 bytes), long (32 bit, 4 bytes), float (4 byte IEEE) and _Bool/bool; Basic (no integer constants) support for long long (64 bit, 8 bytes) data types for the z80, z180, r2k, r3ka, gbz80, hc08 and s08 targets. The ability to add inline assembler code anywhere in a function. The ability to report on the complexity of a function to help decide what should be re-written in assembler. A good selection of automated regression tests.

SDCC was written by Sandeep Dutta and released under a GPL license. Since its initial release there have been numerous bug fixes and improvements. As of December 1999, the code was moved to SourceForge where all the "users turned developers" can access the same source tree. SDCC is constantly being updated with all the users' and developers' input.

100 questions
3
votes
4 answers

How to escape a # in a macro

I need to write a macro which needs to inline assembly #define create_me(name) \ __asm\ mov name,#0x1021\ __endasm\ The # however isn't compiling. I have tried passing it in as a parameter however that doesn't work too. It says invalid…
losang
  • 85
  • 1
  • 5
3
votes
1 answer

How to upload program to STC 51 in OS X

I used Arduino IDE to program Arduino. But now I have a develop board with STC(51). I have no idea about how to program it in OSX. I found there has a lot of GUI tools in the Windows, but it's hard to find some for OSX. I found some information…
emj365
  • 2,028
  • 2
  • 19
  • 24
3
votes
2 answers

sdcc inline asm() not working

I'm using GCC (correction) SDCC with the Eclipse IDE to compile C code for an 8051 architecture embedded target. I need to insert a few NOPs for timing, and I can't get the compiler to accept inline assembly code. With __asm__ ("; This is a…
CarpeCimex
  • 135
  • 2
  • 10
3
votes
4 answers

Do all C compilers allow functions to return structures?

I am working on a program in C and using the SDCC compiler for a 8051 architecture device. I am trying to write a function called GetName that will read 8 characters from Flash Memory and return the character array in some form. I know that it is…
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136
3
votes
2 answers

How to burn .hex intel format file on cc2530 EB

Hello there I am a newbie working on the SMARTRF-05EB - Evaluation Board, I have installed SDCC and Contiki-2.6 in the Linux Virtual Machine. I am able to build all the examples present in this directory contiki-2.6/contiki/examples/cc2530dk , but…
linuxstack
  • 757
  • 8
  • 19
2
votes
1 answer

Embedded C Compiler Source include Vs linking

I have a bunch of source files for my application, should I just source include create one object file or let them be separate and let the linker do the job. Which one is more efficient?.
dasman
  • 237
  • 1
  • 2
  • 10
2
votes
1 answer

Compiler warnings with SDCC

Using SDCC 3.0.0. Compiling this code #include < pic16f84.h> void main(void) { TRISA0=0; RA0=1; } and receive these warnings. daedalus@Eurydice:~/Projects/PIC$ sdcc -I /usr/share/sdcc/include/pic -p16f84…
Michael
  • 281
  • 1
  • 5
  • 12
2
votes
2 answers

How to put a variable at a specific memory location in SDCC

For low-level programming, sometimes it's necessary to say, at a given memory location, this is where my address is. For this post, the example is the PIR1 register in the PIC16F886 and related microcontrollers. It's always found at address…
Lorraine
  • 1,189
  • 14
  • 30
2
votes
0 answers

SDCC Z80: Avoid addresses

Can I exclude certain addresses inside the code segment in SDCC? For example if my code segment spans from addr. 0x0000 to 0x4000, can I somehow tell the linker/compiler to avoid addr. from 0x2000 to 0x2100 and not place any code there? The two…
Tomaz Stih
  • 529
  • 3
  • 10
2
votes
0 answers

Getting low and high parts of the 16-bit word

Learning SDCC compiler, its Z80 part (sdasz80). In native versions of assembler I use: ld (hl),LOW BUF inc hl ld (hl),HIGH BUF to store 16-bit value BUF in two 8-bit parts (high and low). I can not find how to do it in SDCC, it seems this ld …
Anonymous
  • 561
  • 3
  • 7
  • 24
2
votes
3 answers

Can't get .define working with sdasz80 (sdcc assembler)

SDCC's assembler is derived from ASxxxx where manual describes the .define command here: http://shop-pdp.net/ashtml/asxs02.htm#define Since it's a derivation it's possible not everything works the same way, but since the command line argument help…
Jari Komppa
  • 584
  • 4
  • 20
2
votes
1 answer

How can I declare a function by memory address with SDCC

(Non-native speaker here, I apologize for the vague title) I am using the compiler suite sdcc (3.7.0) to compile C code for the TI-82 STATS calculator. Its processor is a Z80. The OS provides several functions to interact with the device, for…
kangalio
  • 652
  • 8
  • 16
2
votes
0 answers

C Left shift unexpected behavior

I have this code: void GPIO_InitPortPin(uint8* PortControl, uint8 Pin, uint8 PinDir){ *PortControl &= (~(1U << Pin)); *PortControl |= (PinDir << Pin); } If the PortControl register is 11111111, the first line should clear the bit of…
Mosaaleb
  • 1,028
  • 1
  • 9
  • 23
2
votes
1 answer

How do I use the Silicon Laboratories IDE with SDCC?

I'm thinking about using a microcontroller with an 8051 core from Silicon Laboratories. I hope that I can use C rather than assembly language, so I installed SDCC. I installed the "Silicon Laboratories IDE" to download the executable binaries to the…
David Cary
  • 5,250
  • 6
  • 53
  • 66
2
votes
1 answer

What causes object files to vary between compilations even when the source and compiler flags are unmodified?

If you clicked on this because you thought that this can't be possible, I thought the same thing until I ran into it. I was working on a project, written in C for a PIC, that is built with a Makefile. The Makefile was very disorganized, so I wanted…
EchoLynx
  • 410
  • 5
  • 11