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
0
votes
1 answer

Use Makefile and sdcc to build a perfect automation for MCS-51 development

Since sdcc have some limitations, like compiling one file at a time, I've tried hard to write a Makefile to perfect the automation of MCS-51 development, which have some requirements: Source file (.c) expect main.c are stored in…
user19681631
0
votes
1 answer

Can not create 8051 project in Eclipse on Mac

I'm using macOS. I have downloaded sdcc for Mac and installed it followed INSTALL.txt inside the downloaded folder (simply copy it to Developer folder), and have Eclipse IDE for Embedded C/C++ Developer installed. Then I installed eclipseSDCC (I…
Yiming Designer
  • 423
  • 3
  • 10
0
votes
2 answers

How do I get an hex file generated by SDCC to be simulated in Pic Simulator IDE?

I have been searching workarounds for many days with no luck. PIC Simulator keeps telling me that the checksum of the hex file is wrong. I already tried changing SDCC‘s hex file output format many times and tried all of them but it is the same error…
user1598585
0
votes
0 answers

With SDCC, how to access word pointer from another file

I'm using SDCC compiler for a microcontroller. In tunes.c, I declare an integer table: __code unsigned int Beep1[] = {4, 0, 1500, 750, 375}; void PlayTune(unsigned int Addr[]) { /* code */ } In main.c, I play the tune: PlayTune(Beep1) In tunes.h,…
user3635160
0
votes
0 answers

How to use SDCC to build 8051

I have a project with mc96f8316(ABOV), it's a 8051 core. My sdcc has version like this: SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/TININative/ds400/hc08/s08/stm8 3.8.0 #10562 (Linux) published under GNU General Public License (GPL) My…
0
votes
1 answer

sdcc giving syntax error on code that works in keil

I was trying to understand this code. It was in a tutorial, and I was following along the tutorial, and so I tried this code. I compiled it using sdcc, but it is giving me a syntax error on column 7. The tutorial shows that the code works in keil.…
Hole
  • 36
  • 5
0
votes
1 answer

Different appearance between SDCC and Keil with the same code in 8051

I write a delay function: void delay(a){ for (int i=a;i>0;i--) for (int j=0; j<200;j++) } But when I compiled this code by sdcc and keil, and run in 8051 chip. The result is that the delay function compiled by sdcc runs much more…
Jack
  • 227
  • 3
  • 8
0
votes
1 answer

SDCC generates unnecessary division by zero

I'm using SDCC to compile for a STM8 microcontroller. Compiling the following file results in a seemingly unnecessary div instruction - which is very slow on the STM8. char a[1]; char b; void foo() __interrupt(1) { char c = a[0]; b = c >>…
user2248702
  • 2,741
  • 7
  • 41
  • 69
0
votes
2 answers

Why is the toolchain file executed a few times in CMake?

In an attempt to create a cross-compilation CMake toolchain template with the SDCC compiler, I have come across a very weird issue. As described in this link, if the toolchain.cmake file defines a CMAKE_SYSTEM_NAME, CMake will look for the file with…
Mat Gomes
  • 435
  • 1
  • 8
  • 22
0
votes
2 answers

How to better read a value from an address that points to an address

I am wondering if there is a better way to write this: void readtcp_c(unsigned char c) { volatile char *a; volatile int *p; volatile int *q; a = (char *)APPLE_REG_A; // a = memory mapped address for REG A *a = c + 128; …
datajerk
  • 185
  • 7
0
votes
1 answer

Ignore SDCC compiler language extensions when compiling with GCC

I'm trying to compile some c-code that was originally written for SDCC using GCC to run some unit tests on a host computer. There are some language extensions for SDCC like __xdata or __pdata (for memory control) which should remain for SDCC but…
Imael
  • 1
  • 1
0
votes
2 answers

Why is this function called with no body before being declared, and what exactly is the '2' doing?

void on_low_interrupt(void) __interrupt 2; void on_low_interrupt(void) __interrupt 2 { #ifdef CONFIG_ENABLE_I2C i2c_handle_interrupt(); #endif #ifdef CONFIG_ENABLE_SERIAL serial_handle_interrupt(); #endif } I'm adapting some code to run…
0
votes
1 answer

STM8L051F3 GPIO Initial Config

I am programming the STM8L051F3 processor for a simple application in which it is only necessary to control all GPIO. The problem is that I can't control the GPIOC pin 0. I just configured the GPIO registers. Is any other startup necessary? I also…
Ilidam
  • 73
  • 6
0
votes
1 answer

How 8051 XDATA memory spaces are handled in pointers?

I am developing for the Cypress EZ-USB FX2LP which contains a 8051 core and I use SDCC for compilation. I noticed that I can (sometimes?) omit the __xdata annotation for pointers and my firmware will still run fine even when using pointer to a XDATA…
DurandA
  • 1,095
  • 1
  • 17
  • 35
0
votes
1 answer

How to push variable in sdcc inline assembly?

I have this code in ThreadCreate(): int tmpPSW = newThID << 3; __asm PUSH A PUSH _tmpPSW __endasm; This results in: ?ASlink-Warning-Undefined Global '_tmpPSW' referenced by module 'cooperative' I don't get why. tmpPSW is clearly defined,…
johan
  • 1,664
  • 2
  • 14
  • 30