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

Using C and reading CPU Register (Carry-Flag) via assembler

Hi smart guys out there,

I am using µVision with TIs eval-kit LM3S9B92. I use µVisions C-Compiler.

I learned that it is not possible to read the CPU-Registers with C and I have to use asembler for that.

I have no idea of asembler and actually I don't work with it in future and I hope I never have to again :-) ...but right now I need to know the status of the carrybit.

So all I am asking is for a piece of code that gets me the status of bit 29 in the register 17 :) and how to implement that in my project.

I hope this doesn't sound sassy ;-) - at least it isn't meant that way.

Thank you so much.

Parents
  • ...but right now I need to know the status of the carrybit.

    That's most probably an incorrect belief.

    Note that even if you find a method for reading the carry flag, there's absolutely no guarantee that by the time that method actually accesses it the carry still contains the same state you were looking for. Compiled C code owns that flag --- it'll do with it whatever it wants, up to and including using it for some other purpose in the meantime.

    In a nutshell, when you think you need the carry flag (or the content of any general-purpose register) from inside a C program, you're still thinking in assembler. And that will not work.

Reply
  • ...but right now I need to know the status of the carrybit.

    That's most probably an incorrect belief.

    Note that even if you find a method for reading the carry flag, there's absolutely no guarantee that by the time that method actually accesses it the carry still contains the same state you were looking for. Compiled C code owns that flag --- it'll do with it whatever it wants, up to and including using it for some other purpose in the meantime.

    In a nutshell, when you think you need the carry flag (or the content of any general-purpose register) from inside a C program, you're still thinking in assembler. And that will not work.

Children