C vs ASM

This is a discussion on C vs ASM within the C Programming forums, part of the General Programming Boards category; I'm curious to know if C can do as much as assembler can. Can I access memory and do other ...

  1. #1
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438

    C vs ASM

    I'm curious to know if C can do as much as assembler can. Can I access memory and do other really low level items with C like you can in ASM? I kinda want to learn some low level programming for fun, and I'm trying to decide between ASM and C. Any input is appreciated.

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Its been my understanding that you can do anything in assembly that you can in C. It is also my understanding that it is a lot more work to write in assembly, and usually the only advantage to using it is if you have a part of your code that is uber slow, and could use some tweaking.

    kermit

  3. #3
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    So I can write directly to memory in C, and do other tasks I can't in Java?

  4. #4
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    Well...

    Some things can ONLY be done in ASM - like bootloaders. But, for the most part, C can do anything that you want.

  5. #5
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    I guess I should have answered your question properly.. - You asked if 'C can do as much as assembler,' to which I answered you can do anything in assembly that you can in C - so I was not really answering your question like you wanted - and notice the word order - I was not saying that you can do everything with C that you can with assembly.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    Some things can ONLY be done in ASM - like bootloaders
    Why is that?

    Why isnt there a compiler option to let you pick where it goes in memory? Cant you make a absolute binary with gcc(i have no idea whats its really called, i mean when it requires nothing to run on its own)?

  7. #7
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    Originally posted by mart_man00
    Why is that?
    A bootloader has specific requirements for where bytes go. (For instance, the bootloader needs to end with 7c 00 (or something like that.)) There's also the fact that some things in writing operating systems (like going into protected mode) need specific things done in a specific order, or else it will foul up for no apparent reason. You don't have this level of control with assembly.

    Why isnt there a compiler option to let you pick where it goes in memory? Cant you make a absolute binary with gcc(i have no idea whats its really called, i mean when it requires nothing to run on its own)?
    There is, and you can

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    There is, and you can
    So doesnt that mean its possible?

    Do you really have to go that low level for a bootloader(besides from memory)? I mean isnt its sole purpose to load another program? So you woulnt have to go into protective mode(isnt that what compilcates things?)?

    Im assuming that Lilo is like 2 sperate programs with this.


    Ive been wondering this for a while, thanks.

  9. #9
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >>You don't have this level of control with assembly.
    I'm assuming you mean C, not assembly.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    4

    Re: C vs ASM

    Originally posted by CompiledMonkey
    I'm curious to know if C can do as much as assembler can. Can I access memory and do other really low level items with C like you can in ASM? I kinda want to learn some low level programming for fun, and I'm trying to decide between ASM and C. Any input is appreciated.
    In my best knowledge, you have a lot more control on a lower level over everything in assambler. You can control anything from hardware level to any given variable level.
    The gratest disadvantage is that it is a lot more dificult to write code.
    But the program you have to do will work faster and with less resources needed.

  11. #11
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    Re: Re: C vs ASM

    Originally posted by molie666
    In my best knowledge, you have a lot more control on a lower level over everything in assambler. You can control anything from hardware level to any given variable level.
    The gratest disadvantage is that it is a lot more dificult to write code.
    But the program you have to do will work faster and with less resources needed.
    well then let me see you convert a 10000 line C++/C program to ASM and let me see how effeciently it will run.. obviously you can not convert all that in an optimized manner..

  12. #12
    Registered User
    Join Date
    Aug 2003
    Posts
    4

    Re: Re: Re: C vs ASM

    Originally posted by vasanth
    well then let me see you convert a 10000 line C++/C program to ASM and let me see how effeciently it will run.. obviously you can not convert all that in an optimized manner..
    Just as I said it is a lot more dificult to write code in assembler, but, if done properly, you can build more reliable programs.

  13. #13
    Registered User
    Join Date
    Mar 2002
    Posts
    57
    >>>well then let me see you convert a 10000 line C++/C program to ASM and let me see how effeciently it will run.. obviously you can not convert all that in an optimized manner..


    He never said that. and that was never the question. The question was if C can do "everything" that can be done using assembler. I do not know assembly language, heck I dont even know C so well, but I would think, C cant do everything that assembler does.

    Anoop.

  14. #14
    Registered User
    Join Date
    Aug 2003
    Posts
    4
    Originally posted by anoopks
    >>>well then let me see you convert a 10000 line C++/C program to ASM and let me see how effeciently it will run.. obviously you can not convert all that in an optimized manner..


    He never said that. and that was never the question. The question was if C can do "everything" that can be done using assembler. I do not know assembly language, heck I dont even know C so well, but I would think, C cant do everything that assembler does.

    Anoop.
    Yes it can.
    If you have the apropriate .h files, that is.

  15. #15
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Originally posted by anoopks
    >>>well then let me see you convert a 10000 line C++/C program to ASM and let me see how effeciently it will run.. obviously you can not convert all that in an optimized manner..


    He never said that. and that was never the question. The question was if C can do "everything" that can be done using assembler. I do not know assembly language, heck I dont even know C so well, but I would think, C cant do everything that assembler does.

    Anoop.
    hi anoop.. looks like u r from India.. me tooo

    ok let me put it this way...

    Using Assembler to do big stuff is like using a pen torch cell to power up a building.. instead i would use a generator which is C/C++ May be you can get thousands of cells to power up but not viable...

    There are things like small circuits, etc etc which need to be programmed.. assembler is very usefull hee since there is not much of overhead.. Even it is used to optimize some parts of code in a C/C++ program( you can use inline assembly)..

    Knowing Asm is a good thing since you will be familiar with the structure of the PC archite..... And can make you a better programmer..( atleast thats what i think).

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc asm code syntax
    By Uberapa in forum C Programming
    Replies: 4
    Last Post: 06-15-2007, 01:16 AM
  2. Asm + C++
    By JaWiB in forum C++ Programming
    Replies: 17
    Last Post: 06-26-2003, 03:13 PM
  3. Understanding ASM
    By kuphryn in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 07-12-2002, 07:39 PM
  4. asm mov
    By manu in forum C++ Programming
    Replies: 1
    Last Post: 12-15-2001, 11:59 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM

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