Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. And, clock() doesn't measure cpu clock cycles.

    And, clock() doesn't measure cpu clock cycles.
  2. Let me understand this: You want to do a GUI...

    Let me understand this: You want to do a GUI application for a keyboard because you want to use the mouse instead of pressing keys?
  3. AND... local objects aren't initialized to zero...

    AND... local objects aren't initialized to zero by default... Only static local objects OR global objects... This:


    int a[10]; // local
    Isn't initialized... This:


    int a[10] = { 0 }; ...
  4. And, NO... this: int f( ... ) { int b = 0;...

    And, NO... this:

    int f( ... )
    {
    int b = 0;
    ...
    }
    Here b is initialized at RUNTIME because it is on stack OR in a register...
    The compiler can discard this object only if the...
  5. I don't get where you are trying to reach......

    I don't get where you are trying to reach... this:

    int f( ... )
    {
    int a[10];
    int n;

    n = g( a );
    if ( ! n )
    return 0;
  6. Replies
    8
    Views
    1,046

    Yep, but it is nice to know that multi byte...

    Yep, but it is nice to know that multi byte charsets can be traced back to Dennis Ritchie and Ken Thompson in the 70's (UNICODE was designed based on experiences made by XEROX in the 80's -- as...
  7. Replies
    8
    Views
    1,046

    There are routines in wchar.h to convert to/from...

    There are routines in wchar.h to convert to/from wchar_t to/from local charset, but you have to set locale properly, typically:


    setlocale( LC_ALL, "" );
  8. Replies
    8
    Views
    1,046

    Well... working with single byte charsets isn't a...

    Well... working with single byte charsets isn't a real problem with portability... nowadays we have a difficult one: In Windows you can work with WINDOWS-1252 charset (a modified ISO-88591-1 charset)...
  9. A small correction: void...

    A small correction:



    void voltage(t_SenseDataRaw *k, float *adv) {
    uint16_t *p = &k->Vbias; // the first member (A pointer!).
    for (int i = 0; i < 4; i++)
    adv[i] = p[i] * 3.3...
  10. Simplier: // Circular single linked list...

    Simplier:



    // Circular single linked list test.

    #include <stdio.h>
    #include <stdlib.h>

    // Macro to initialize a list.
  11. Replies
    5
    Views
    930

    AND... free works (do nothing) if the pointer is...

    AND... free works (do nothing) if the pointer is NULL (ISO 9899 7.20.3.2 2)... But if the pointer isn't NULL and not allocated by the functions above, then the behavior is unspecified (probably a...
  12. Ahhh... yep, I'm talking about x86! x86 uses...

    Ahhh... yep, I'm talking about x86!

    x86 uses the static approach for conditional jumps because they are, mostly, used in loops. And with static behavior it is easy to avoid mispredictions: "if"...
  13. This is talking about "dynamic predictors", not...

    This is talking about "dynamic predictors", not static ones... Instructions as Jcc use "static" branch preditor algorithms. Only indirect jumps use dynamic...
  14. hamster_nz, what you described is valid for...

    hamster_nz, what you described is valid for indirect jumps. For conditional jumps the algorithm is simplier: forward jumps are assumed as NOT taken and backward jumps are assumed as taken.
  15. It helps if you paid attention... The forward...

    It helps if you paid attention... The forward jump (with penalty if taken) is made inverting the condition:


    if ( x < 100 ) f();

    ...
    cmp eax,100
    jge .skip ; JUMPS IF GREATER OR EQUAL...
  16. Replies
    8
    Views
    1,107

    It is good to remember that "signal" on integer...

    It is good to remember that "signal" on integer types are just semantic.


    // with sizeof(int)=4.
    int x = -1;
    unsigned int y == 0xffffffff;
    At binary level, both values are the same if two's...
  17. Yep, I know, I know... the compiler can use...

    Yep, I know, I know... the compiler can use cmovcc instruction to avoid conditional jumps...
  18. It depends... if x < 100 happens most of the time...

    It depends... if x < 100 happens most of the time this code is faster than if doesn't happen most of the time...


    if ( x < 100 )
    return x;
    return 100;
    Will loosely be compiled as

    #...
  19. Maybe some comments would help: .section ...

    Maybe some comments would help:

    .section .rodata

    .LC0:
    .string "%d"
    .LC1:
    .string "val is bigger than val2!"
    .LC2:
    .string "val is smaller than val2!"
  20. The reason why compilers like GCC and CLANG (I...

    The reason why compilers like GCC and CLANG (I don't deal with MSVC. It is a ........ty compiler) chooses to do conditional jumps forward to ELSE block is because it is assumed the THEN block will...
  21. And not getting paid for it? Very convenient,...

    And not getting paid for it? Very convenient, isn't it?
  22. Think of a pointer as a normal integer...

    Think of a pointer as a normal integer variable... If you do:

    void f(int x) { x = 1; }
    ...
    int a = 3;
    f(a);
    a isn't modified, isn't it?

    If you do:
  23. Replies
    4
    Views
    585

    Another approach is to identify your "private"...

    Another approach is to identify your "private" members with some special naming and never use them outside the functions which deals with the structure directly... Example:


    struct list {
    ...
  24. Replies
    8
    Views
    1,244

    inttypes.h header gives us the proper format...

    inttypes.h header gives us the proper format conversion strings:

    #include <stdio.h>
    #include <stdint.h>
    #include <inttypes.h>

    int main ()
    {
    uint8_t Data_Byte = 0;
    uint8_t LSB_BIT;
  25. Replies
    5
    Views
    667

    But.. you don't need that union or to use a...

    But.. you don't need that union or to use a pointer to use the 12 bits ADC from PIC18x:


    uint32_t value = (ADCRESH << 8) | ADCRESL;
    double flt = (double)value / ((1 << 12) - 1);

    Make sure...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4