Thread: Difference between ROM and RAM..

  1. #16
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    It's nothing to worry about, because you can always run them again.
    Sure, if you don't mind rewriting that 10 page paper from scratch. (Just emphasizing a point)
    I just knew someone was going to say that.

    2. Running and compiling?
    As Thantos said, when you compile a program, you basically turn the human-readable source code (in C) that you wrote into a machine-readable executable (in machine code) that the computer can run.

    When you run a program, you tell the CPU to start at the beginning of the program and execute the instructions contained therein. When you start Word, you're running a program.

    [edit] "It has more"? More what? Don't leave us hanging! [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    Quote Originally Posted by shwetha_siddu View Post
    But i am getting confuse with :-
    1. what is difference between data and code?
    2. Running and compiling?
    3. What is Role of ROM? i heard that some instance we will transfer data from EEPROM to RAM to ROM what for this?
    1. I don't know. Is there a difference between data and code?

    2. Running a program executes a bunch of commands. Compiling takes stuff we can read (C, for instance) and turns it into commands the computer can read (1's and 0's) and maybe execute later.

    3. This would happen when you're making hardware, I guess; if you have some spare silicon running around, and want to make a chip and put some ROM on it, you would need to get it on there somehow. My rough estimate is that at least 9999 C programs out of 10000 would never get here.

  3. #18
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Aha! I have an analogy all ready now:

    When you write code, you're drawing a plan for a mould on paper. When you create this mould out of plastic, you're compiling the program. When you use this mould to create lots of little moulded objects out of plasticine, which you can then flatten out and use again, you're running the program . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #19
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by shwetha_siddu View Post
    But i am getting confuse with :-
    1. what is difference between data and code?
    2. Running and compiling?
    3. What is Role of ROM? i heard that some instance we will transfer data from EEPROM to RAM to ROM what for this?

    1. Code is something that the processor can (and should) execute as instructions - it's the add, sub, mov, jmp instructions that make a program work. Data is anything the program needs that ISN'T code [although some people will separate data into subcategories, and I'm sure your tutor will start asking you what the heap and stack is at some point in the future, but I won't forgo the question by answering it here].

    2. Running or executing is when the processor "runs" the program, that is, the processor is performing whatever task it has been told to do in the code. Compiling is the phase where the compiler (a program written for this purpose) is translating the human-readable code, say
    Code:
    int main()
    {
       printf("Hello, World!\n");
       return 0;
    }
    into machine-readable instructions (code and data). The compiled code is called "executable", and in windows has (usually) the extension .exe.

    3. ROM in a PC is not used for anything other than the initial startup (where it loads the first bit of program code from the hard disk, which then loads the rest of the operating environment) and last steps of shutdown.

    If you have a mobile phone or other embedded device, where there is no hard-disk, then the executable code + data for that device is normally stored in some form of ROM - it can be a traditional ROM that is programmed at the time of manufacturing - these are the cheapest ones, or it can be a EPROM (old technology now) or a EEPROM, such as Flash-ROM's. These are erasable and can be reprogrammed. EEPROM can be reprogrammed in situ in the machine, whilst EPROMs may need for example UV-light to be erased.

    Some embedded systems use ROM for "Execute in place", meaning that the processor executes directly from the ROM itself. Other embedded systems, for performance reasons, move the code from the ROM to the RAM during the first part of the startup (obviously, the first execution happens from ROM).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do this
    By BEN10 in forum C Programming
    Replies: 32
    Last Post: 05-28-2009, 02:22 AM
  2. Problem with the linker file
    By ssharish2005 in forum Tech Board
    Replies: 2
    Last Post: 04-24-2007, 05:46 AM
  3. pointer in rom
    By ramdal in forum C Programming
    Replies: 4
    Last Post: 12-19-2005, 09:33 AM
  4. less use of ram
    By ramdal in forum C Programming
    Replies: 4
    Last Post: 12-19-2005, 08:25 AM