Thread: Reading RAM/ arrays / Number attachment

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    5

    Reading RAM/ arrays / Number attachment

    Hello i have a few questions.

    1. Why are all numbers +48 (i know because of 00110000,picture in attachments) but i want to know why that happens.

    2. Is there a better way to read RAM?
    Code:
    //1.Stundeint stunde1;
    int stunde11;
    char *adresse = (char*) (0xA0000501);
    char a = *adresse;
    char *adresse1 = (char*) (0xA0000502);
    char b = *adresse1;
    a=a-48;
    b=b-48;
    stunde1=10*a+b;
    3. I want to attach two numbers. I did it with that equation c=10*a+b, but is there a way to create a eg. 04. So that one address holds 0 and the other 4.

    4. How do i put Variables into that array?
    eg:
    Code:
    ROM BYTE BIMMELN [26][x] ={
    
                            "stunde1:stunde11",
                            "08:15",
                            "09:05",
                            "09:10",
                            "10:00",
                            "10:05",
                            "10:55",
                            "11:00",
                            "11:50",
                            "11:55",
                            "12:45",
                            "12:50",
                            "13:40",
                            "13:45",
                            "14:35",
                            "14:40",
                            "15:30",
                            "15:35",
                            "16:25",
                            "17:15",
                            "18:00",
                            "18:45",
                            "19:00",
                            "19:45",
                            "20:30",
                            "21:15",
                            };
    Hope that u guys can help me.

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Quote Originally Posted by Marius C. View Post
    1. Why are all numbers +48 (i know because of 00110000,picture in attachments) but i want to know why that happens.
    They are not numbers, per se, but characters, which are relatively small numbers that represent code points in a character mapping scheme. In both the older ASCII system and the newer unicode system, the digits '0' to '9' are assigned the codes 48 to 57. Therefore subtracting 48 from those codes yields the numeric value of the character.

    Quote Originally Posted by Marius C. View Post
    2. Is there a better way to read RAM?
    I don't understand what you're doing there. What machine are you coding for? What compiler are you using?

    Quote Originally Posted by Marius C. View Post
    3. I want to attach two numbers. I did it with that equation c=10*a+b, but is there a way to create a eg. 04. So that one address holds 0 and the other 4.
    I don't understand this question.

    Quote Originally Posted by Marius C. View Post
    4. How do i put Variables into that array?
    I don't understand this question either.
    Last edited by algorism; 03-31-2016 at 11:33 AM.

  3. #3
    Registered User
    Join Date
    Mar 2016
    Posts
    5
    I'm coding with Mplab IDE 8.92 compiler version 1.3. Right now im reading about 50 address of ram and that takes (in my opinion) much space. so i thought maybe i can read for example 0xA0000501-0xA0000505.

    I want to attach numbers. for example 1 and 5 is 15 and not 6. I'm currently doing it with that equation and that works fine until i get a 04, because with my equation i get only 4.

    Sorry if i misspelled the last question. I read RAM, attach two numbers and store them in an array. Now i want these Variables to be changeable. But with the "" the program only takes the characters. without them its not right. So my question was how i
    put my integers into that array.



  4. #4
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Sorry but I still don't understand. I don't do this kind of programming. I'm sure someone else here does and will eventually help you out.

  5. #5
    Registered User
    Join Date
    Mar 2016
    Posts
    5
    ok thank you for explaining me the first one

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    A couple of points.

    1. Mplab is an IDE, not a compiler. In essence, it's a code editor with integrated facilities to drive compilers, debuggers, manual pages etc.
    The documentation says it can support several different compilers.

    So,
    2. Which processor / OS are you programming for?

    Addresses like 0xA0000501 look like some attempt to map video memory in a 32-bit address space.
    VGA/SVGA Video Programming--Accessing the VGA Display Memory

    Ordinarily (in a protected OS like Linux or Windows), you can't arbitrarily invent absolute addresses and go poking around to see what's there. The OS will just kill the program as soon as you try.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Mar 2016
    Posts
    5
    Currently i have the ethernet starter kit from microchip (PIC32MX795F512L) xc32 1.3 compiler version.

    I send the (onboard)ftp server a .txt file with numbers. These numbers i want to read, attach them(eg 04) and put them in that array i posted.
    The read RAM part works fine but i asked myself if that could be easier done.
    The attachment works also fine except when it comes to a=0 b=0-9. With my equation the answer is without the 0 infront.

  8. #8
    Registered User
    Join Date
    Mar 2016
    Posts
    5
    To be specific i just want to add a leading 0 without using the printf function(if that is possible).

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Something like
    Code:
    if ( c < 10 ) {
      *x++ = '0';
      *x++ = c + '0';
    } else {
      *x++ = (c%10) + '0';
      *x++ = (c/10) + '0';
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Speech Recognition - w/ attachment
    By Reece Allen in forum C# Programming
    Replies: 4
    Last Post: 06-19-2011, 01:13 PM
  2. help with message attachment
    By dragunov in forum Networking/Device Communication
    Replies: 4
    Last Post: 09-10-2007, 11:36 PM
  3. Reading files number by number, also getw()?
    By rmullen3 in forum C Programming
    Replies: 4
    Last Post: 01-03-2003, 01:22 PM
  4. Forgot the attachment!
    By SyntaxBubble in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2002, 03:50 PM