Страница 2 из 4 ПерваяПервая 1234 ПоследняяПоследняя
Показано с 11 по 20 из 40

Тема: компилятор sdcc.

  1. #11
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    Удобная таблица нахождения библиотечных функций языка Си.

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

  2. #12
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    http://www.ethernut.de/api/sscanf__p_8c_source.html
    sscanf из пакета Nut/OS

  3. #13
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    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 в 13:46.

  4. #14
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    "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):

    [I]for (i = 0; (c = s[i]); i++)
    // Yes, the second '=' is really '=', not '=='...
    {
    if (c == '-') s[i] = 0xAD;
    if ((c|32) == 'e') s = 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.

  5. #15
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    Последний раз редактировалось Leff; 24.05.2014 в 18:27.

  6. #16
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    По ссылке
    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 в 18:33.

  7. #17
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    http://manlib.org/sdcc1/
    Расшифровка опций компилятора.

  8. #18
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761

  9. #19
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    http://www.bipom.com/products/us/212.html
    Отладчики BiPom за $69

  10. #20
    Moderator Аватар для Leff
    Регистрация
    26.04.2012
    Адрес
    Царевококшайск, Россия.
    Сообщений
    6,761
    Файл для ИАРа, с настройками 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; 31.05.2014 в 11:00.

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •