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

Locating ACC with C

Dear all,

How to locate the bit I want in ACC register?
I supposed to use ACC_7 with regx51.h but it encounters error.

Thanks.

Bill

PS. I am searching for AT89C51.h. Please notice me in case you find it. Thanks.

Parents
  • See the include files in your installation directory, typically C:\keil\c51\inc.

    There are many reg*.h files, one corresponding to each supported 8051 variant.

    reg51.h has the "base" definitions common to any 8051, including the ACC, so it should suffice.

    And I'll repeat the earlier comment that you probably don't need to access the accumulator directly if you're writing C. Most likely, that's either a detail you can leave to the compiler, or you should be writing your custom routine in assembler and linking it to the rest of your C code. Changing the accumulator directly makes a lot of assumptions about how the compiler generates object code that may not remain true in the presence of optimization, source changes, or updated compiler versions.

Reply
  • See the include files in your installation directory, typically C:\keil\c51\inc.

    There are many reg*.h files, one corresponding to each supported 8051 variant.

    reg51.h has the "base" definitions common to any 8051, including the ACC, so it should suffice.

    And I'll repeat the earlier comment that you probably don't need to access the accumulator directly if you're writing C. Most likely, that's either a detail you can leave to the compiler, or you should be writing your custom routine in assembler and linking it to the rest of your C code. Changing the accumulator directly makes a lot of assumptions about how the compiler generates object code that may not remain true in the presence of optimization, source changes, or updated compiler versions.

Children
  • "you probably don't need to access the accumulator directly if you're writing C"

    I'd put it stronger: you almost certainly should not access the accumulator directly if you're writing C!

    "Changing the accumulator directly makes a lot of assumptions about how the compiler generates object code that may not remain true..."

    In fact, they may not even be true in the first place!