This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

transfer the value of one variable to another using bitwise (<<)

Good morning everyone Forum
I have done a lot of programming and proficient using C but this Kile compiler is new to me and very different. it is confusing me.
I have a question and need your help.
I wonder how can I rotate the left (<<) the value of variable 'A', so to rotate, bitwise be transferred to another variable 'B'.

Parents
  • It is totally irrelevant if the compiler produces x86 assembler, ARM assembler Z80 assembler or code for a virtual machine.

    The C language will still be the same. So the C code to rotate the contents of a variable and assign to another variable will look the same.

    A statement:

    a = b+1;
    


    means the same in Keil or in M$ Visual C++ (assuming you compile as C and don't compile as C++ with some fancy operator overloading).

    Same if you play with:

    a = b << 1;
    

    So the C code that performs a rotate will look the same in Keil or in Watcom or gcc or any other compiler. The exception is that different processors have different limits for size of the integer variables. So for some architectures you may implement a 64-bit rotate with just a standard "int" variable. And for some architectures you need to implement a big-number library or similar, where you need an array of smaller integer data types. But that is a completely different issue.

    Next thing is that some compilers have intrinsics or additional CRTL functions for performing left and right rotate. The normal way to check that is to read the documentation for the compiler - which I have to assume you have done.

Reply
  • It is totally irrelevant if the compiler produces x86 assembler, ARM assembler Z80 assembler or code for a virtual machine.

    The C language will still be the same. So the C code to rotate the contents of a variable and assign to another variable will look the same.

    A statement:

    a = b+1;
    


    means the same in Keil or in M$ Visual C++ (assuming you compile as C and don't compile as C++ with some fancy operator overloading).

    Same if you play with:

    a = b << 1;
    

    So the C code that performs a rotate will look the same in Keil or in Watcom or gcc or any other compiler. The exception is that different processors have different limits for size of the integer variables. So for some architectures you may implement a 64-bit rotate with just a standard "int" variable. And for some architectures you need to implement a big-number library or similar, where you need an array of smaller integer data types. But that is a completely different issue.

    Next thing is that some compilers have intrinsics or additional CRTL functions for performing left and right rotate. The normal way to check that is to read the documentation for the compiler - which I have to assume you have done.

Children
No data