memorey addresses question

This is a discussion on memorey addresses question within the Tech Board forums, part of the Community Boards category; Why is it adjacent memorey addresses differ by 4?...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    115

    memorey addresses question

    Why is it adjacent memorey addresses differ by 4?
    Name:  MemAddressExample.jpg
Views: 88
Size:  92.0 KB

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    The "memory content" column is showing values which are four bytes in length, and your question is, why are the associated addresses differing by four bytes each time?

    Can you put in words, what you think this chart is displaying?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    115
    Quote Originally Posted by brewbuck View Post
    The "memory content" column is showing values which are four bytes in length, and your question is, why are the associated addresses differing by four bytes each time?

    Can you put in words, what you think this chart is displaying?
    What happened to addresses 0xC001, 0xC002, 0xC003 for example? How do you know the memory content is 4 bytes in length? How is that possible that a memory address can be mapped to something other than 1 byte?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by c_weed View Post
    What happened to addresses 0xC001, 0xC002, 0xC003 for example? How do you know the memory content is 4 bytes in length? How is that possible that a memory address can be mapped to something other than 1 byte?
    Gee, I dunno, because the value being stored is 4 bytes long?

    Code:
    printf("%d", sizeof(int));
    What do you get back?

    Unless you are on some seriously old and outdated compiler, it will print 4 ... so in order to store 1 int you need 4 bytes of memory... thus one variable every 4 bytes... just like your image.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    115
    Quote Originally Posted by CommonTater View Post
    Gee, I dunno, because the value being stored is 4 bytes long?

    Code:
    printf("%d", sizeof(int));
    What do you get back?

    Unless you are on some seriously old and outdated compiler, it will print 4 ... so in order to store 1 int you need 4 bytes of memory... thus one variable every 4 bytes... just like your image.
    Oh ya I get it now.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,450
    Whatever is stored in memory is 1s and 0s, so it really doesn't contain any information about what length data stored is.
    In other words, it's showing them grouped by 4 bytes simply because you told it to do so. You can change that to other things (typically to a multiple of a byte).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 08-19-2011, 06:53 PM
  2. MAC addresses
    By Thantos in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-20-2004, 01:26 PM
  3. ip addresses and ports
    By jrahhali in forum Networking/Device Communication
    Replies: 3
    Last Post: 11-18-2003, 05:06 AM
  4. question about 32 bit addresses??
    By newbie02 in forum C++ Programming
    Replies: 3
    Last Post: 09-12-2003, 02:02 PM
  5. DMA, IO Addresses and IRQ
    By jrahhali in forum Tech Board
    Replies: 1
    Last Post: 08-31-2003, 09:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21