don't click here

C or ASM

Discussion in 'Technical Discussion' started by MarkeyJester, Aug 14, 2009.

  1. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,202
    432
    63
    Japan
    Now before anyone asks why this is not sonic related, yes it is, I'm trying to learn a language so I can program a better SMPS editor as a proper application and improve on it, the megadrive has its limits, one of them being the screen size too small for what I'm needing it for, so there you have it, just before anyone decides to flag that up.

    Anyway, now that you know what I'm going to use it for, I need to know which language would be better to learn, C or ASM, now I've read in places saying that C is great and better than every other language, I've also been told the same about ASM, now having experience with 68K ASM I am header towards the ASM market however am still confused, now I know there are a few programmers here who have used these languages, so I thought I'd ask experience instead of written text dedicated to the specific language,

    can anyone point me in a correct direction here? I would very much appreciate it thank you.
     
  2. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    For a PC application, you're better off using C. Not only is x86 assembler a pain to work with, it's even more irritating to execute system calls. C makes all of that much easier. (Plus you can use inline assembler if you really need to.)

    EDIT: This is assuming you're writing an SMPS editor for PC. If you're writing one for MD, then you might still want to consider using C anyway, since an editor program isn't performance-critical.
     
  3. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,202
    432
    63
    Japan
    well, I had already written an SMPS for the MD but that was ON the MD as a game rom

    (Original link)
    http://forums.sonicretro.org/index.php?showtopic=14986

    now I'm attemption to make something similar but improved on PC, but still for MD's SMPS, but seeing as you've mensioned C having a greater use of what I need, I think my answer is solved,

    Unless anyone else has a different answer, then I'm happy for this topic to be now locked if someone could please
     
  4. Armada

    Armada

    Sometimes I do things Member
    338
    0
    0
    I suggest C, seeing as there is an SMPS playback program already you could use, and it's much more easy to deal with when programming for PC than ASM is (at least on this level). I'd be willing to assist you if you need some help with C as I'm well versed in the syntax.
     
  5. SegaLoco

    SegaLoco

    W)(at did you say? Banned
    Well, it all depends on how intensive you want to get with this. I, as most, recommend C, but if you need it to do amazingly swift things, then making at least some parts in ASM could help, but note, if you make it one on arch, you can't use it on another easily.
     
  6. Mikel

    Mikel

    Member
    Well, if you are making a PC Application, I'd go with C, since Motorola 68K ASM is mainly used on the Mega Drive, the Neo-Geo (Although it also uses Zilog Z80A), the CPS-1 and the CPS-2, I'd use C if you are making your SMPS Music Editor into a Proper application.

    And like Armada said, there is an SMPS Playback Program made by Rob Jinnai, you can find it here:

    http://forums.sonicretro.org/index.php?showtopic=12692

    That can help you with your C programming needs.
     
  7. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    ASM runs faster than C if you do it right. Then again, you're not going to require extreme performances for an application of this kind, so you don't need the degree of optimisation that ASM can give you. And good C compilers can build very optimised applications anyway. Not that so-called "professional developers" (Microsoft just to say a name) care about speed and optimisation nowadays when they release something, they actually have fun at inventing useless new high level languages such as .net and use them for CPU intensive programs which would run like 5000% faster if written in a decent language. But I'm not here to rant.

    So yeah, you should use C, because it's much easier to use compared to ASM, plus it makes it easier to port your code to another system in case you want to release a Mac or Linux build (or to let people port it).
     
  8. SegaLoco

    SegaLoco

    W)(at did you say? Banned
    He is talking about x86 asm, or whatever architecture he might be running. Still, as nineko said, asm is mainly for power applications. As for those high level languages he is talking about, don't ever try to use those, they are pointless, barely portable (thank God for Mono), and are just a pain in the ass to write in. I know, I have tried VB and C#, they are pretty much clones of each other except one is lacking ; to signify the end of a function. If you can though, try to take advantage of C++, classes and namespaces and such are good to learn, even if you wont be using them, because I guarantee you, C may not be around for ever, but C++ will be around for a loooooong time. (What am I saying, C will be around as long as C++ is as long as Microsoft doesn't dick it up and get them to change the standard.)
     
  9. saxman

    saxman

    Oldbie Tech Member
    I would recommend C. You say you have 68k assembly experience, so I'd say you have a fairly good understanding of what it takes to write programs. x86 assembly is a nice language if you're just fooling around or learning about programming for the first time. In your case, I'd say C is the next logical step.
     
  10. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,240
    972
    93
    Long-term happiness
    I'd recommend C not only as it'll be easier for you to code, but it can be ported to other platforms later if need be. ARM netbooks are coming, amongst other uses =P
     
  11. Revival

    Revival

    The AppleTalk Network System Member
    200
    0
    16
    Really? You think? What's so difficult about putting the parameters in registers then triggering interrupt 80h?
    "mov eax,1
    mov ebx,0
    int 80h" (Intel syntax yo)
    is all you need to exit. Value 1 is put in EAX to show it's the exit syscall and value 0 in EBX to give exit code 0 (program ran normally).

    If you want simple, Assembly has it. Each line is one operation. The language is FAR easier to understand. It's just more complex to do high-level operations in. Since you're writing a high level application I would suggest C, however. C is also easier to port. Much easier.

    By the way, the "ASM is more optimised" argument is a bit out. Modern compilers are amazing at optimisation.

    (edited to note: The example given is for Linux, and other kernels that try to emulate Linux (FreeBSD for example).)
     
  12. TmEE

    TmEE

    Master of OPL3-SA2/3 Tech Member
    1,726
    2
    18
    Estonia, Rapla City
    T-04YBSC-A !
    On PC, anything but assembler, Java and the like... x86 ASM is quite pain, and it makes thigns difficult in the realm of windows. In DOS, things are simpler though. And it has been pointed out that you can inline ASM into your C code anyway if you happen to have some need for high performance code.
     
  13. SegaLoco

    SegaLoco

    W)(at did you say? Banned
    Speaking of the world of Windows with asm, can you build a UI with asm? What would it require doing?
     
  14. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    Selling your soul.
     
  15. Revival

    Revival

    The AppleTalk Network System Member
    200
    0
    16
    Certainly, it's possible.

    But I wouldn't recommend it.
     
  16. AamirM

    AamirM

    Tech Member
    The most quickest way would be either to use FASM (my favourite) and/or MASM32. Both have some good docs and already include the libs and necessary includes/macros. They also include some simple example programs.

    But yeah, using asm to make GUI using WinAPI doesn't make much sense.
     
  17. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,240
    972
    93
    Long-term happiness
    God, if you're making a GUI don't use ASM, use C. Making a GUI in ASM is rather like building a house with bricks a quarter of the size of normal ones and that emit radiation until the house is completed - sure it'll work and it'll be just as good when you're done, but it's SO much more work!
     
  18. FraGag

    FraGag

    Tech Member
    I think it's pretty obvious by now that ASM is not an ideal solution here (and pretty much never when dealing with PC applications). However, being familiar with low-level programming will definitely help you learning C quickly.

    Now, if you choose C (or C++), your application will be more portable, as others said, but you'll lose that advantage if you use the Win32 API directly to make a GUI for your application, as you'll be stuck with Windows. However, there are several libraries to help build portable GUIs (amongst other things), for example Qt, wxWidgets or GTK+. Some people here use Mac OS X or Linux, you wouldn't want to let them down, eh? (Wine? what's that? :v: )
     
  19. SegaLoco

    SegaLoco

    W)(at did you say? Banned
    Come on, you are all taking a simple little question that I would never follow up on (those of you who know me know I can't do much with even GTK+ yet) so I doubt I could do a UI in asm, or even a basic application in ASM. It was just a silly little question.
     
  20. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,240
    972
    93
    Long-term happiness
    And miniature radioactive bricks that suddenly stop emitting radiation isn't a semi-silly answer? ;P