109 questions
2
votes
1
answer
58
views
Assistance with inline Assembly porting to SDCC
I am porting the GetCurrentMicro function in the Arduino Core STM8 to my SDCC code and I noticed the Cosmic C Compiler _asm function allows me to return a result as well as an input in a C var.
Is ...
1
vote
0
answers
27
views
How is LCD_RW defined in sdcc [duplicate]
I'm trying to compile a 51 microcontroller (STC 89C52RC) on the Linux platform using PlatformIO and the sdcc compiler. Currently, I'm attempting to display characters on an LCD1602. The specific ...
0
votes
1
answer
102
views
SDCC can't syntax sbit of LCD1602 [closed]
I started learning the 51 single-chip microcomputer, but encountered a problem when trying to use the Lcd1602. I referred to a code for an LCD1602 debugging tool written in Keil5 on the Windows ...
0
votes
1
answer
92
views
What is the equivalent of __attribute__((section)) in SDCC?
It's actually a very simple question so I don't know what else to put as an example:
file: gcc.c
int a __attribute__((section(".custom_section"))) = 0;
int inc_a(void)
{
return ++a;
}
...
0
votes
0
answers
173
views
SDCC problem with function return on 8051
So, I was writing some code for the 8051, and as I needed a delay, I implemented it through a timer (in mode 1):
volatile void delay_1ms(void)
{
TMOD = 0x01; // Set Timer 0 to Mode ...
0
votes
1
answer
178
views
SDCC dependency generation
I'm trying to generate header file dependencies with SDCC on Windows, the command line is
sdcc -c -mmcs51 --model-small --xram-size 0x0100 --xram-loc 0x0100 --code-size 0x2800 -Iinclude/ -oobj/ -...
0
votes
1
answer
116
views
Makefile: no rule to make target (sdcc)
I'm trying to do my first Makefile for a sdcc C program I start.
For now, I get this error:
make: *** No rule to make target 'out/main.rel', needed by 'a.bin'. Stop.
This is my Makefile:
SRC = src/...
1
vote
1
answer
263
views
STM8 Assembly startup code: Access Core registers to initialize stack pointer
I am currently trying to write startup code in assembly for an STM8 without any vendor libraries. More specifically, I am using an STM8S103f3p6. I am still inexperienced in assembly and with startup ...
2
votes
1
answer
568
views
sdcc code location - how to get file without padding when using start address greater than zero
using the SDCC compiler, I am looking to create a z80 file to load into a particular address in ram 0x8000) at a later stage. I have used for example the compiler line:
sdcc -mz80 --no-std-crt0 --code-...
2
votes
1
answer
154
views
Is this a possible bug in SDCC?
The following code works as expected when compiled with gcc, however when compiled with sdcc (4.2.0) the conditional test (x2 + y2 >= 800) doesn't ever appear to be evaluated as true (as only ...
3
votes
2
answers
457
views
SDCC assign memory address to pointer, no effect
I've been mulling over this for the last couple of days, and i cant see what is wrong with my code.
Really just looking to assign two memory addresses to two pointers. ROM at 0x0000 and RAM at 0x7000....
0
votes
1
answer
246
views
SDCC produces elf output with sections of NULL type
I am using SDCC to produce an ELF file. I then convert this ELF file to a binary file. Sadly the output is not as expected. The output is not positioned correctly and there are strange zero length ...
2
votes
1
answer
446
views
Binary Injection into ELF File
I have an ELF file generated through the SDCC compiler using the —out-fmt-elf and —debug options. I need to inject data into the actual binary (this will be loaded to an STM8 microcontroller). Doing ...
0
votes
1
answer
216
views
sdcc compiler wrong machine code generation
the sdcc compiler generate a unexpected instruction output after compilation, I rechecked this code in ChatGPT, at the source level all is fine to my knowledge.
this is the code:
#include <stdio.h&...
0
votes
0
answers
530
views
MCU 8051 IDE with SDCC stuck at compiling
I am a student and have been instructed by the college to use MCU 8051 IDE with SDCC for learning microcontroller programming. I installed this software successfully on many HP devices in college but ...
0
votes
1
answer
270
views
SDCC compile warning 88: cast of LITERAL value to 'generic' pointer
I got Warning at code "CT_PD->bank = PDbank",
Warning happens as long as "CT_PD->...",
I have no idea to solve it. Can anyone know what to do?
warning message::
warning 88: ...
3
votes
1
answer
425
views
VScode: Disable syntax highlighting for a range of lines
I'm using SDCC's inline assembly syntax for my project:
void delay_ms(uint16_t ms) {
_ms = ms;
__asm
ldw y, __ms ; Load ms counter into y register: 2 cycles
0000$:
...
0
votes
1
answer
1k
views
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)...
0
votes
1
answer
171
views
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++ ...
0
votes
0
answers
108
views
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....
0
votes
0
answers
885
views
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 ...
-1
votes
1
answer
491
views
Compiling with SDCC fails with -Wall option
I'm compiling a 8051 project with SDCC but has a problem with Makefile, the following sources:
TARGET = test
CC = sdcc
CFLAGS = -Wall -I.
RM = rm -rf
SRCS = $(wildcard *.c)
RELS = $(...
0
votes
2
answers
1k
views
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.
...
2
votes
2
answers
2k
views
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 ...
2
votes
0
answers
249
views
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 ...
0
votes
1
answer
550
views
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 ...
0
votes
1
answer
225
views
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() ...
0
votes
2
answers
4k
views
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 ...
4
votes
2
answers
361
views
How does C programming work with no headers?
I'm familiar with the C programming language and z80 assembly and I have made a simple z80 "computer" with just the cpu with 32k of ram, 32k of rom, and an 8255 pia for io control. I have ...
0
votes
1
answer
192
views
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 ...
0
votes
2
answers
160
views
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
...
-2
votes
1
answer
862
views
How to create packed arrays of bit fields with SDCC?
I have a nested data structure containing arrays of bit fields which I need to compile with SDCC for the MCS-51 target.
This is a simplified example:
example.c
struct data {
unsigned char a : 1;
...
-3
votes
1
answer
2k
views
MCU 8051 IDE 'Small Device C Compiler' (SDCC) compiler with C language is not compiling
I have a problem with an MCU 8051 IDE simulator. When using the C language it was outputting the message "no sdcc compiler". After I installed the SDCC compiler on my PC, this part worked.
...
0
votes
1
answer
314
views
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 ...
3
votes
3
answers
2k
views
Floating point numbers and the effect on 8-bit microcontrollers memory
I am currently working on a project that includes bare-metal programming on an stm-8 micro-controller using the SDCC compiler in linux. The memory in the chip is quite low so I'm trying to keep things ...
0
votes
1
answer
1k
views
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 ...
1
vote
1
answer
156
views
can SDCC override operators?
I've been trying to use SDCC to compile extremely lightweight C programs to run on a TI83 calculator (yes, you can do that). Being an old calculator, it doesn't have much RAM to store the program, and ...
0
votes
1
answer
2k
views
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 '...
0
votes
0
answers
660
views
I2C is not able to start
I am using stm8s controller and SDCC compiler. I am interfacing SD130S7 I2C based RTC with controller. I am facing a problem during communication. I think the problem is I2C itself is not started.
I ...
1
vote
0
answers
640
views
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 ...
0
votes
1
answer
2k
views
STM8 TIM1 (or TIM2) - one 5s tick after external interrupt event
I'm trying to implement this logic in STM8S103F3:
1) Controller wait for external interurpts on GPIOC (high by default) after initialization.
2.1) external interrupt triggered: if PIN5 of GPIOC is low,...
0
votes
1
answer
775
views
SDCC / GBDK, Passing array of structs to function
I am attempting to pass a pair of arrays of structures to a function in C.
I must use the SDCC compiler as I am compiling for Gameboy using GBDK.
When I pass the array of structures I get an error ...
3
votes
4
answers
848
views
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 ...
3
votes
3
answers
1k
views
Why and when malloc() will not be available in C?
I've been given a 8051 based board with an embedded in-house operating system. I am using SDCC to create applications above the OS. And malloc is not available so I have to allocate memory statically. ...
2
votes
1
answer
2k
views
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 ...
3
votes
0
answers
577
views
Compiling for PIC16F with SDCC: on RPi: libsdcc.lib: no such file or directory
I've compiled SDCC 3.7.0 on a Raspberry Pi 2. But I'm having diffuculty with the next step: compiling a blink.c with SDCC:
sdcc -mpic14 -p16f887 blink.c --use-non-free
It just returns "libsdcc.lib: ...
2
votes
0
answers
177
views
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 ...
-1
votes
1
answer
2k
views
Syntax error on pointer definition that seems valid (from a working library) SDCC
I'm trying to compile a firmware for Crazyradio PA (but the issue is not specific to it), in which I added a library I needed from Nordic Semiconductor's SDK.
The library is initially meant to be ...
1
vote
1
answer
3k
views
Interrupt STM8s issue with SDCC compiler
I want to use interrupts on the SMT8S003K3 (STM8SVL-DISCOVERY) and somehow it does not get recognized when I use the interrupt on a other file where my main() is located.
I made two tests:
- first ...
4
votes
1
answer
1k
views
Can't figure out how to write interrupt handler for Z80 using SDCC
I'm developing a program in C for the Z80 and compiling using SDCC. I can't figure out how to create interrupt handlers for the NMI interrupt that starts at 0x0066 and the IM1 interrupt that starts ...