Menu

#181 SDCC memory addressing

None
closed
nobody
None
5
2023-01-03
2022-11-29
No

SDCC compiles like this

*(uint16_t *)&FUU=0xf1b2;

FUU - memory address +0 = 0xb2
FUU - memory address +1 = 0xf1

and i need this

FUU - memory address -0 = 0xb2
FUU - memory address -1 = 0xf1

the values must be written to the register

___sfr __at(0x10) FOO_B15_8
___sfr __at(0x11) DOO_B7_0

MOD EDIT: Use actual text instead of an externally hosted picture showing text

Related

Feature Requests: #862

Discussion

  • Benedikt Freisen

    Okay. Let's ignore the fact that this request does not contain a single actual question and act as if the part titled “and I need this” were a question.

    The short answer is: “No. You don't.”
    The long answer is a tad bit more complicated:

    Firstly, dereferencing a pointer in C will only ever access memory at and above the position it points to, but never memory below that address. If you expect something else, your code is broken.
    Additionally, when writing a 16-bit word to memory, the byte order depends on the target architecture's endianess. You can convert the byte order with an appropriate macro, though.
    Since you did not disclose which architecture you are trying to compile your code for, nor what you are actually trying to do, I'm afraid I cannot help you much further.

    P.S.:
    Posting the same cryptic request lacking virtually all essential information in four different places on the same web page does not improve your chances to get a helpful answer. They are all read by the same handful of people, anyway.

     
    • ivan23654623

      ivan23654623 - 2022-11-30

      ok arigato

       
  • Benedikt Freisen

    • status: open --> closed
     

Log in to post a comment.

Auth0 Logo