PDA

Просмотр полной версии : компилятор sdcc.



Leff
27.12.2013, 19:17
http://sdcc.sourceforge.net/doc/sdccman.pdf
"SDCC Manual (pdf)"

http://sdcc.sourceforge.net/mediawiki/index.php/Main_Page
"SDCC - Small Device C Compiler"

http://www.ibm.com/developerworks/ru/library/l-codeblocks_and_sdcc/
"Разработка приложений для встраиваемых устройств : Часть 4. Применение Code::Blocks для разработки SDCC-приложений"
"Знакомство с разработкой приложений для микроконтроллеров семейства 8051 с использованием интегрированной среды Code::Blocks и компилятора SDCC"

http://povarblog.ru/2010/01/21/razrabotka-prilozhenij-dlya-vstraivaemyx-ustrojstv-chast-3-primenenie-eclipse-dlya-razrabotki-sdcc-prilozhenij.html
"Разработка приложений для встраиваемых устройств: Часть 3. Применение Eclipse для разработки SDCC-приложений"

"Free IDE for SDCC"
http://www.bipom.com/products/us/319513.html

"The SDCC Open Knowledge Resource"
http://sdccokr.dl9sec.de/resources.htm

"Code::Blocks Plugins"
http://wiki.codeblocks.org/index.php?title=Code::Blocks_Plugins

"Мини-руководство по созданию Makefile-ов"
http://sys.dmitrow.com/node/209

"EmBlocks — IDE для STM32"
"Это IDE на основе Code::Blocks — кросс-платформенной быстрой среды разработки со встроенным скриптовым языком и очень гибкой настройкой, ориентированной под С/С++ разработку."
http://habrahabr.ru/post/191468/

"Первый проект в IDE Code::Blocks"
http://cxemotexnika.org/2012/12/быстрый-старт-c-микроконтроллерами-stm32f10x/

"Настройка CodeBlocks для SCCC"
http://ecee.colorado.edu/~mcclurel/CodeBlocks-SDCC_Tutorial.pdf

"Code::Blocks 12.11 – настройка Wizard"
http://we.easyelectronics.ru/CADSoft/codeblocks-1211-nastroyka-wizard-dlya-raboty-s-platami-stm32f3discovery-i-stm32f4discovery.html
Тут пишут: аналогично можно создавать конфигурации для любых других МК
Кстати, в EmBlokcs есть драйвер для программатора J-Link.
"Загрузка и установка IDE и GCC для ARM"
http://c4arm.blogspot.ru/2012/11/stm32-codeblocks.html

Вот эта сборка КодеБлокс вполне разумно выглядит:
http://arduinodev.com/codeblocks/

"нотация макропеременных codeblocks"
http://wiki.codeblocks.org/index.php?title=Variable_expansion

Leff
10.05.2014, 15:58
"Русификация программы Code::Blocks."
http://iguania.ru/forum-programmistov-316.html
"Создать каталог "locale\ru_RU" в каталоге "C:\Program Files\CodeBlocks\share\CodeBlocks\"

В указанную папку нужно положить файл "codeblocks.mo" русификатора.

Friendly
12.05.2014, 16:29
Запустился Code::Blocks с компилятором SDCC.
Пользовался этим документом для настройки: "CodeBlocks-SDCC_Tutorial.pdf"
Тестовые программы нормально компилируются, конечно есть особенности и их не мало, но в принципе можно пользоваться.
Нет смысла делать свое IDE - очень сложно, и пользы мало.
Хотел тут выложить доку, почему то не получается?

Leff
12.05.2014, 16:32
У меня получается :)

Friendly
12.05.2014, 16:38
Использовал версию Code::Blocks 12.11.
http://arduinodev.com/codeblocks/
Она запускается с Рабочего стола и не портит реестр винды.
Из папки CodeBlocks выкинул все лишнее, оставил только эти файлы:
share
CodeBlocks
codeblocks.dll
wxmsw28u_gcc_cb.dll
wxpropgrid.dll

Friendly
12.05.2014, 17:02
Code::Blocks 12.11 хорош тем, что на нем можно работать с STM32.

Friendly
12.05.2014, 17:17
Вчера обнаружил "что не все йогурты одинаково полезны".
Функции компилятора SDCC библиотеки стандартного ввода-вывода:

extern void printf_small (char *,...) _REENTRANT;
extern int printf (const char *,...);
extern int vprintf (const char *, va_list);
extern int sprintf (char *, const char *, ...);
extern int vsprintf (char *, const char *, va_list);
extern int puts(const char *);

Тоже для Keil:

extern char _getkey (void);
extern char getchar (void);
extern char ungetchar (char);
extern char putchar (char);
extern int printf (const char *, ...);
extern int sprintf (char *, const char *, ...);
extern int vprintf (const char *, char *);
extern int vsprintf (char *, const char *, char *);
extern char *gets (char *, int n);
extern int scanf (const char *, ...);
extern int sscanf (char *, const char *, ...);
extern int puts (const char *);

В SDCC нет scanf и sscanf.
Есть одна идея как ее написать свою, но нужно пробовать. Ну или искать где то полные библиотеки. :)

Friendly
13.05.2014, 21:01
https://code.google.com/p/minilib-c/source/browse/trunk/stdio/scanf.c?r=8

Один хороший человек дал ссылку на исходники этой функции. Спасибо ему за это.
Нужно ее как то "всунуть" в библиотеку stdio.

Leff
13.05.2014, 21:04
У меня сегодня перестал запускаться CodeBlocks.
Это фича или что это?

Leff
15.05.2014, 15:06
https://code.google.com/p/minilib-c/source/browse/trunk/stdio/scanf.c?r=8

Один хороший человек дал ссылку на исходники этой функции. Спасибо ему за это.
Нужно ее как то "всунуть" в библиотеку stdio.

Не нужно ее вставлять в стандартную библиотеку - лишние хлопоты.
Просто сделать обычной функцией и все.

Leff
16.05.2014, 16:08
Удобная таблица нахождения библиотечных функций языка Си.

http://www.java2s.com/Code/C/CatalogC.htm

Leff
16.05.2014, 21:07
http://www.ethernut.de/api/sscanf__p_8c_source.html
sscanf из пакета Nut/OS

Leff
17.05.2014, 13:23
http://tigcc.ticalc.org/doc/stdio.html#sscanf
Описание стандартных библиотек.

"sscanf
short sscanf (const char *buffer, const char *format, ...);

String parsing function.

sscanf scans the string buffer for the formats in the format string format and assigns the input to pointers passed as varargs. Returns:


the number of pointers filled in (the number of matches done) if it is non-0


0 if no pointers were filled in because of a format matching error


EOF (-1) if the input ended before any pointers were filled in

Formats accepted:


any non-whitespace character other than '%': matches a literal character, assigns nothing


whitespace characters: match any whitespace characters, even if they are a different kind of whitespace, assign nothing


'%%': matches a literal '%', assigns nothing


Any formats of the type '%' + flags + width + type (or '%' + width + flags + type, the order isn't actually checked, you can even put the flags in the middle of the width):

Flags accepted:


'*': skip the matched data (don't assign it to a pointer, and don't count it)


'h': if an integer type follows, it will be a short integer, otherwise the flag is ignored. (This is the default if neither 'h' nor 'l' are specified.)


'l': if an integer type follows, it will be a long integer, otherwise the flag is ignored


Warning: "%h" or "%l" alone is not accepted. Always write "%li", "%ld", ... explicitely.

Width: Maximum number of bytes to read in for data matching. The maximum is 65535. Any larger number will be truncated modulo 65536. If the width is 0 or omitted, the default width for the format is used.

Types accepted:


'u': matches an unsigned decimal integer
default width: 65536
required pointer: 'unsigned short *' for '%hu', 'unsigned long *' for '%lu'
automatically skips leading whitespace


'd': matches a signed decimal integer (both [-] and [(-)] are accepted)
default width: 65536
required pointer: 'short *' for '%hd', 'long *' for '%ld'
automatically skips leading whitespace


'o': matches an unsigned octal integer
default width: 65536
required pointer: 'unsigned short *' for '%ho', 'unsigned long *' for '%lo'
automatically skips leading whitespace


'x' or 'X': matches an unsigned hexadecimal integer (0-9 and both a-f and A-F are accepted)
default width: 65536
required pointer: 'unsigned short *' for '%hx', '%hX', 'unsigned long *' for '%lx', '%lX'
automatically skips leading whitespace


'p': same as '%lx' (even if '%hp' or just '%p' is specified)


'i': matches an integer in C syntax: may contain a negative sign ([-] or [(-)]), is hexadecimal if started with 0x, octal if started with 0, and decimal otherwise
default width: 65536
required pointer: 'short *' or 'unsigned short *' for '%hi', 'long *' or 'unsigned long *' for '%li'
automatically skips leading whitespace


'f', 'g', 'e' or 'E': matches a floating-point number. (This number will be parsed by push_parse_text (through atof), so it has to use the calculator '-' and 'E'.)
default and maximum width: 29. This limitation is because we need to allocate a buffer for atof on the stack, and we didn't want to waste too much stack space.
required pointer: 'float *'
automatically skips leading whitespace


's': matches a non-whitespace string, and null-terminates it when copying it to the buffer (so make sure you have a buffer of size width + 1)
default width: 65536
required pointer: 'char *'
automatically skips leading whitespace


'c': matches a fixed number of characters (the given width). Does NOT null-terminate the string when copying it to the buffer.
default width: 1 (NOT the maximum width like for the other formats)
required pointer: 'char *'
does NOT skip leading whitespace (put a space before '%c' if you want to skip it)


'[': matches a regexp-style set of characters:


']' terminates the set unless it immediately follows the leading '[' or the leading '[^'


if '^' is the first character, matches the characters which are NOT in the set


'-' specifies a range of characters (as in '0-9') unless it immediately precedes the terminating ']'


any other characters (including ']' right at the beginning or '-' right at the end): match the corresponding literal characters

copies characters until either the input ends, or the specified width is reached, or a character which is not in the specified set (when using '^': which is in the specified set) is encountered
null-terminates the copied string (so make sure you have a buffer of size width + 1)
default width: 65536
required pointer: 'char *'
does not skip leading whitespace (put a space before '%[' if you want to skip it)


'n': does not read anything from the input, but assigns the number of characters already read in to the given pointer
default width: N/A (the width is ignored, and no characters are read in)
required pointer: 'short *'
does not skip any whitespace in the input"

Leff
17.05.2014, 14:20
"float atof (const char *s);

Converts a string to a floating point.

atof converts a string pointed to by s to floating point value. It recognizes the character representation of a floating point number, made up of the following:

an optional string of spaces;

an optional minus sign;

a string of digits and an optional decimal point (the digits can be on both sides of the decimal point);

an optional exponent followed by a (optionally signed) integer.

It is important to say that this implementation of atof requires that an optional minus sign and an optional exponent must be TI Basic characters for minus sign and exponent, (characters with codes 0xAD and 0x95 instead of ordinary '-' and 'e' or 'E' characters). This limitation is caused by using some TIOS calls which needs such number format. Anyway, it is very easy to "preprocess" any string to satisfy this convention before calling to atof by routine like the following (assuming that c is a char variable, and i is an integer variable):
for (i = 0; (c = s[i]); i++)
// Yes, the second '=' is really '=', not '=='...
{
if (c == '-') s[i] = 0xAD;
if ((c|32) == 'e') s[i] = 0x95;
}

atof returns the converted value of the input string. It returns NAN if the input string cannot be converted (i.e. if it is not in a correct format). This is not the same as in ANSI C: atof in ANSI C returns 0 if the conversion was not successful. I decided to return NAN instead, so the user can check whether the conversion was successful (which is not possible with ANSI atof). See is_nan for a good method to check whether the result is NAN.

Note: This function is not part of TIOS, and it is implemented using the TIOS function push_parse_text.

Leff
21.05.2014, 16:43
Мэйкфайл для SDCC.
http://www.ecse.rpi.edu/courses/CStudio/SDCC%20Compiler/sdcc-src-2.8.0/sdcc-src-2.8.0/sdcc/Makefile.in

И еще Мэйкфайл
http://code.metager.de/source/xref/sdcc/sdcc/device/examples/Makefile

compiler.h
http://www.ecse.rpi.edu/courses/CStudio/SDCC%20Compiler/sdcc-src-2.8.0/sdcc-src-2.8.0/sdcc/device/include/mcs51/compiler.h

Функция ftoa
http://www.microchip.com/forums/m183763.aspx
http://stackoverflow.com/questions/2302969/how-to-implement-char-ftoafloat-num-without-sprintf-library-function-i

Агоритм преобразования float в строку
http://iprog.pp.ru/forum/read.php?f=1&i=15184&t=15167

Leff
22.05.2014, 19:43
По ссылке
http://iprog.pp.ru/forum/read.php?f=1&i=15184&t=15167
лежит программа _itoa_ преобразует int в текстовую строку.

подправил в _ltoa_ - стала преобразовывать long в строку.

//********************************************
char* _ltoa_(long value, char* buf)
{
char* ptrs = (char*)&buf[15];
bit sign = 0;
*ptrs-- = 0;
if(value < 0 ) {
sign = 1;
value = -value; }
do {
*ptrs-- = value % 10 + '0';
value /= 10;
} while(value);
if(sign == 1) *ptrs = '-';
else ptrs++;
strcpy(buf, ptrs);
return buf;
}

Leff
24.05.2014, 14:46
http://manlib.org/sdcc1/
Расшифровка опций компилятора.

Leff
24.05.2014, 16:52
Исходники компилятора SDCC
http://code.metager.de/source/xref/sdcc/sdcc/device/lib/_fslt.c
http://code.metager.de/source/xref/sdcc/sdcc/device/

Leff
24.05.2014, 17:24
http://www.bipom.com/products/us/212.html
Отладчики BiPom за $69

Leff
24.05.2014, 17:59
Файл для ИАРа, с настройками ADuC847.
Можно применять эти настройки для компилятора SDCC. :)
Формат команд, естественно, нужно менять.




// Analog Devices ADu847.

-D_IDATA_END=0xFF // Last address of Idata memory (0xFF for 8052 and 0x7F for 8051)

-D_PDATA_START=0x0401 // First address for PDATA memory.
-D_PDATA_END=0x04FF // Last address for PDATA memory.
-D_IXDATA_START=0001 // First address of xdata memory.
-D_IXDATA_END=07FF
-D_XDATA_START=_IXDATA_START // First address of on chip XDATA memory.
-D_XDATA_END=_IXDATA_END // Last address of on chip XDATA memory.
-D_CODE_START=0x0100 // First address for code
-D_CODE_END=0xDFFF // Last address for code.
-D_NEAR_CODE_END=_CODE_END // Last address for near code.
-D_FAR_DATA_NR_OF_BANKS=0x0E // Number of banks in far data memory.
-D_FAR_DATA_START=_XDATA_START // First address of far memory.
-D_FAR_DATA_END=_XDATA_END // Last address of far memory.
-D_FAR_CODE_START=_CODE_START // First address for far code.
-D_FAR_CODE_END=_CODE_END // Last address for far code.
-D?REGISTER_BANK=0 // Default register bank (0,1,2,3).
-D_REGISTER_BANK_START=0 // Start address for default register bank (00,08,10,18).
-D?PBANK_NUMBER=04 // Bank number to be used in PDATA area
-D?PBANK=A0 // SFR control register holding bank number (0xA0 is sfr P2)
-D?PBANK_EXT=0x00 // SFR control register holding bank number for 24 bit devices
-D_BREG_START=0x00 // The bit address where the BREG segments starts.
// Must be placed on: _BREG_START%8=0 where _BREG_START <= 0x78.
-D?VB=0x20 // ?VB is used when referencing BREG as whole byte.
// Must be placed on: ?VB=0x20+_BREG_START/8
-D_FIRST_BANK_ADDR=0

Leff
24.05.2014, 18:32
Тоже для 8051F410


// C8051F3410-411

-D_IDATA_END=0xFF // Last address of Idata memory (0xFF for 8052 and 0x7F for 8051)

-D_PDATA_START=0x0701 // First address for PDATA memory.
-D_PDATA_END=0x07FF // Last address for PDATA memory.

-D_IXDATA_START=0x0001 // First address of on chip XDATA memory.
-D_IXDATA_END=0x7FF // Last address of on chip XDATA memory.

-D_XDATA_START=_IXDATA_START // First address of XDATA memory.
-D_XDATA_END=_IXDATA_END // Last address of XDATA memory.

// Silicon Laboratories F32x chip has 16kb flash memory in the range
// - CODE:0x0000-0x4000
// In this application flash used for data begins at address
// FIRST_FLASH_FILE and ends at address FIRST_FLASH_FILE + 0x2A00.
//
// FIRST_FLASH_FILE is a symbol that is defined in USB_MAIN.c
//
-D_CODE_START=0x0000 // First address for CODE.
-D_CODE_END=0x7DFF // Last address for CODE.
//
-D_NEAR_CODE_END=0x7DFF // Last address for near code.
//
-D_FAR_DATA_NR_OF_BANKS=0 // Number of banks in far data memory.
-D_FAR_DATA_START=0 // First address of far memory.
-D_FAR_DATA_END=_XDATA_END // Last address of far memory.
//
-D_FAR_CODE_START=_CODE_START // First address for far code.
-D_FAR_CODE_END=_CODE_END // Last address for far code.
//
//
-D?REGISTER_BANK=0 // Default register bank (0,1,2,3).
-D_REGISTER_BANK_START=0 // Start address for default register bank (00,08,10,18).
//
-D?PBANK_NUMBER=0F // high byte of 16-bit address to the PDATA area
-D?PBANK=A0 // Most significant byte in MOVX A,@R0. (0xA0 is sfr P2)
-D?PBANK_EXT=0xEA // Most significant byte in MOVX A,@R0. (0xEA is for Dallas DS80C390)
//
-D_BREG_START=0x00 // The bit address where the BREG segments starts.
// Must be placed on: _BREG_START%8=0 where _BREG_START <= 0x78.
-D?VB=0x20 // ?VB is used when referencing BREG as whole byte.

-D_FIRST_BANK_ADDR=0

Leff
24.05.2014, 19:00
Функция atoi();

http://stackoverflow.com/questions/5710091/how-does-atoi-function-in-c-work

Leff
30.05.2014, 14:44
Рекомендации по применению SDCC

http://www.maximintegrated.com/en/app-notes/index.mvp/id/3477
http://www.actel.com/download/software/softconsole/sc21.aspx

Leff
30.05.2014, 14:56
SDCC and Keil Compatibility Issues

Many developers accustomed to the use of the Keil development tools for 8051 targets may not have had exposure to the free SDCC tools. SoftConsole uses SDCC for compiling and linking your Core8051s projects. As you develop your programs, or port your existing Keil-compatible code to use under SoftConsole for a Core8051s target, there are some fundamental differences you will want to keep in mind.

The SDCC compiler's User Manual (available under the Start menu entry for SoftConsole) covers such differences in detail. Some of the more important differences are highlighted here.
Syntax Differences
In your code developed with Keil, you can use
#pragma NOEXTEND
to make sure you've weeded out exactly what compiler-specific keywords exist.
SFR declarations
The Keil syntax with

sfr IOA = 0x80;

looks slightly different with SDCC, using either of

sfr at 0x80 IOA;
__sfr __at 0x80 IOA;

The SDCC "at" and "__at" keywords are used in place of an initialization-style statement. In the interests of pointing out possible compatibility issues, many users opt to choose the leading "__" version of these keywords to make their use more clear.

Also, SDCC does not require the bytes to be adjacent in memory for sfr or sfr16.
SBIT declarations
Also the case with SBIT, you use the "at" keyword. Instead of

sbit SEL = 0x86+0;

you should have one of

sbit at 0x86+0 SEL;
__sbit __at 0x86+0 SEL;

External Registers
The Keil compiler looks for "_at_" in the declaration of an external register, such as
extern xdata volatile unsigned char GPIO_LED_REG _at_ 0xF200;
Instead, the SDCC style is
extern xdata at 0xF200 volatile unsigned char GPIO_LED_REG;
Printf Functionality

The SDCC compiler does support the use of printf(); however, you will need to create your own putc() function to implement the actual emitting of bytes to a specific device for stdout.
Macro Workarounds
Some users elect to take advantage of macro text substitution in their source code to make the creation of more compatible code less labour-intensive. For example, you can employ:

#define SFR(a,b) __sfr __at(a) b
#define SBIT(a,c) __sbit __at(a) c
#define SBIT(a,b,c) __sbit __at(a+b) c
#define SFR16(a,b) __sfr16 __at(((b+1)<<8) | b) a

This will enable you to use "SFR(0x80, IOA)" regardless of which specific syntax they're using.
Assembly Language Programming

If you are writing a program in assembly language rather than in C, you should be aware of some differences between the asx8051 assembler and Keil's A51. As noted by Daniel Clemente in his description of using SDCC with a particular development board:
Global symbols (tags accessible from outside) are specified with .globl (or with tag::). Then you don't need the -g when compiling.
Files are included with .include
Constants (equ) are done with NAME = value
You must use .area CSEG (CODE) before the code.
The hexadecimal values are written with 0xVALUE, and binary with 0bVALUE. In A51 they have the letter at the end.
You don't need the end instruction at the bottom of each file.
Keil ignores everything about upper/lower case, and even when in your code you're calling EZUSB_Delay1ms, for instance, at the assembler there's only defined the symbol EZUSB_DELAY1MS.
Symbols created by asx8051 must have the prefix _ (it means external symbol). sdcc adds it automatically when compiling C.
ISO/ANSI Compliance

There are some traits of the SDCC compiler that are not in full compliance with the ISO standard for the C programming language. Users who would like to know the specifics are encouraged to consult section 8.2, "ANSI-Compliance", in the SDCC User Manual (available in HTML and PDF format under the Start menu entry for SoftConsole).

Leff
04.06.2014, 12:24
Программа преобразует строку в переменную long.
Ссылка на исходник выкладывал ранее в этой теме.
Поддерживает числа до 10 цифр со знаком, вида LNG=-1234567890;


//*******************************************
long _atol_( const char *c ) {
long value = 0;
bit sign = 0;
if( *c == '+' || *c == '-' ) {
if( *c == '-' ) sign = 1;
c++;
}
while ( isdigit( *c ) ) {
value *= 10;
value += (long) (*c - '0');
c++;
}
if(sign)value=-value;
return value;
}

Leff
05.06.2014, 10:17
Программа для преобразования переменной типа float в строку.
Взята по ссылке выложенной в начале темы, и была немного подправлена.
Переменная вида f=-12.123456;
Всего максимально (суммарно) 8 разрядов, разделенных точкой.
Переменная w - количество знаков после запятой.



///************************************************** *************
char* _ftoa_(float pn, char* buffer, char ww) {
char* ptr = buffer;
char sst, js;
float fract;
long rest;
if(pn < 0) {
*ptr++ = '-';
pn = -pn; }
else *ptr++ = ' ';
if(ww>6) ww=6;
rest = (long)pn;
fract = (pn - rest); //
_ltoa_(rest, ptr);
js=strlen(ptr);
ptr = ptr + js;
*ptr++ = '.';
if(ww > (8-js)) ww = 8-js;
while(ww--){
fract = fract * 10;
sst = (char)fract;
fract = fract - sst;
*ptr++ = sst + 0x30;
}
*ptr = 0;
return buffer;
}

Leff
05.06.2014, 10:18
Программа аналогичная предыдущей, с функцией восстановления переменной float из строки.
Взята по ссылке, немного подправлена.



//**************************************
float _atof_(char * s) {
float value, fraction;
long iexp;
bit sign;
while (isspace(*s)) s++;
if (*s == '-') {
sign=1;
s++; }
else { sign=0;
// if (*s == '+') s++;
}
for (value=0.0; isdigit(*s); s++) {
value=10.0*value+(*s-'0'); }

if (*s == '.') {
s++;
for (fraction=0.1; isdigit(*s); s++) {
value+=(*s-'0')*fraction;
fraction*=0.1; }
} if (toupper(*s)=='E') {
s++;
iexp=(long)_atol_(s);
while(iexp!=0)
{
if(iexp<0) {
value*=0.1;
iexp++; }
else {
value*=10.0;
iexp--; }
}
}
if(sign) value*=-1.0;
return (value);
}

Leff
05.06.2014, 18:07
По ссылке лежит исходник программы - sprintf.c
http://www.opensource.apple.com/source/ruby/ruby-12/ruby/sprintf.c

Leff
06.06.2014, 12:29
Программа выводит текстовую строку в буфер и вставляет значение переменной F (float) в строку. После точки по умолчанию 2 знака.
_sprintf_( buffer, " R=%f Ohm ", F);
Если вставить цифру до символа "f" - то количество знаков после запятой будет равно этому значению (суммарно, до запятой и после, также не более 8).
_sprintf_( buffer, " R=%4f Ohm ", F);



///******* _sprintf_ *************************************************
void _sprintf_( char* ptr, const char *fmt, float pnf) {
char w=2, j, ibuf[16];
char* ptrS = ibuf;
while (*fmt != 0)
{
if (*fmt == '%') {
fmt++;
while (*fmt != 'f') if(isdigit(*fmt)) { w=*fmt-'0'; fmt++; }
fmt++;
_ftoa_(pnf, ptrS, w);
j=strlen(ptrS)+1;
strncpy(ptr, ptrS,j);
ptr = ptr + j;
}
else *ptr++ = *fmt++;
}
}



Если переменная F=-123.123456;
то будет напечатано в первом случае: " R=-123.12 Ohm "
и во втором: " R=-123.1234 Ohm "

Leff
06.06.2014, 12:56
Описание библиотечных функций на русском языке
http://cppstudio.com/post/726/

Leff
06.06.2014, 17:09
Для вывода двух переменных в строку можно использовать функцию - strcat.
R=999.1;
I=1.123;

_sprintf_ (bufA, "R=%1f ", R);
_sprintf_ (bufB, " I=%3f ", I);
strcat(bufA, bufB);

Набор функций печатает строку: "R=999.1 I=1.123"

Leff
09.06.2014, 12:45
Rationale for International Standard— Programming Languages— C
http://www.open-std.org/jtc1/sc22/wg14/www/docs/C99RationaleV5.10.pdf

Leff
11.06.2014, 12:38
Статья автора SDCC - Sandeep Dutta.

http://embedded.ifmo.ru/sdk/sdk11/soft/sdcc/Dutta-121.pdf
A Retargetable ANSI-C Compiler

Friendly
11.06.2014, 14:36
Этот Sandeep Dutta, похоже, руководитель департамента фирмы IBM в Индии.

Leff
15.06.2014, 19:54
Операции, операторы и выражения в языке Си (C)
http://www.itstan.ru/programmirovanie/operacii-operatory-i-vyrazhenija-v-jazyke-si-c.html

Friendly
15.10.2014, 12:09
Запускал CodeBlocks который лежит по ссылке - http://arduinodev.com/codeblocks/
Версия 12.11
Через некоторое время слетает - т.е. перестает запускаться.
Выяснилось, что портится файл "default.conf", который лежит в папке CodeBlocks.
Что бы устранить это, сохраняем этот файл с "левым" названием, например, так: "default_.conf"
Когда CodeBlocks слетает, то восстанавливаем файл "default.conf" из "default_.conf" - и все опять работает. :)

Leff
18.04.2015, 16:56
Компилятор прикольно работает.

В какой то момент пишет ошибку

"?ASlink-Error-Could not get 5 consecutive bytes in internal RAM for area DSEG.
?ASlink-Error-Could not get 4 consecutive bytes in internal RAM for area OSEG."

Беру в строке программы:

result = nt.massiv[5] / result;

пишу так:

if(result>0) result = nt.massiv[5] / result;

в результате и памяти хватает и ошибки нет. :)

Friendly
19.04.2015, 10:00
Похоже на работу двух различных подпрограмм деления.

Friendly
15.01.2016, 14:08
Запускал CodeBlocks который лежит по ссылке - http://arduinodev.com/codeblocks/
Версия 12.11
Через некоторое время слетает - т.е. перестает запускаться.
Выяснилось, что портится файл "default.conf", который лежит в папке CodeBlocks.
Что бы устранить это, сохраняем этот файл с "левым" названием, например, так: "default_.conf"
Когда CodeBlocks слетает, то восстанавливаем файл "default.conf" из "default_.conf" - и все опять работает. :)

Файл default.conf сделал в свойствах "только для чтения". Перестал портиться!
Ругается, что не может туда что то записать, при этом - но мне и не надо чтобы он туда что то писал... :)

Leff
18.12.2018, 21:01
Описание языка программирования ANSI C.
http://cpp.com.ru/ansi_c/index.html

Описание языка программирования ANSI C.
http://www.opennet.ru/docs/RUS/ansi-c/