Why assembly?

I've done some work with VB and C++, but have never written any assembly code. Could someone tell me some pros and cons to writting in assembly, how it compares with other languages in difficulty to learn, and what is considered to be a good compiler/interpreter. thanks

Comments

  • : I've done some work with VB and C++, but have never written any assembly code. Could someone tell me some pros and cons to writting in assembly, how it compares with other languages in difficulty to learn, and what is considered to be a good compiler/interpreter. thanks
    :
    PROS: You can do things that VB and C++ don't provide. It's fast.

    CONS: One command in C may take over 200 lines in ASM code. It makes you go crazy(quicker).

    There a several freebies out there but I think the best ones are MASM from MicroSoft and TASM32 from Borland.

    Good luck!

  • [b][red]This message was edited by the Aunas at 2002-6-7 7:38:51[/red][/b][hr]
    [b][red]This message was edited by the Aunas at 2002-6-7 7:37:56[/red][/b][hr]
    : I've done some work with VB and C++, but have never written any assembly code. Could someone tell me some pros and cons to writting in assembly, how it compares with other languages in difficulty to learn, and what is considered to be a good compiler/interpreter. thanks
    :

    C++ is my most favourite language too. But C++ programs is a lot slower than programs written in assembler. Assembler programs are fast, becouse assembler instructions are direct instructions to CPU.
    The best choice, as I think, is write programs with high-level languages by using assembler inlines.

    Pluses:
    Fast programs

    Minuses:
    Difficult to use and understand source (some assembler program's sources are ununderstandable)
    Source is very big, and you must to write long code, forexample to print a char on a screen
    Sometimes it is dangerous (Brrr...). For example you can easilly destoy your partition table or MBR by calling INT 13h with 3 value in ah.





  • : There a several freebies out there but I think the best ones are MASM from MicroSoft and TASM32 from Borland.
    :

    Hi,

    I'd have to disagree. IMHO Nasm (http://nasm.2y.net) is my favourite assembler because it's free, open source, and lets you code without worrying about all the red tape that MASM gives you.

    TASM would be second choice, purely because of it's "ideal" mode.

    Hope this helps,
    (:---Dodgy Del Boy---:)
  • : I've done some work with VB and C++, but have never written any assembly code. Could someone tell me some pros and cons to writting in assembly, how it compares with other languages in difficulty to learn, and what is considered to be a good compiler/interpreter. thanks
    :

    The language itself is "one-to-one" meaning one assembly statement coresponds to 1 CPU command - you are directly commanding the CPU to perform command. High-level languages are "one-to-many" - one statement can correspond to hundreds of CPU instructions.

    Assembly allows direct hardware and memory access - writing device drivers, direct disk access etc. which high level languages often don't allow.

    Assembly must be used to program embedded systems like microchips.

    Also, it's almost impossible to write large software projects - the code becomes too unmaintainable, which is why higher level languages are used.

    In terms of assemblers, well as has been suggested TASM and MASM are probably the most popular, although I don't know which is better.

  • : : I've done some work with VB and C++, but have never written any assembly code. Could someone tell me some pros and cons to writting in assembly, how it compares with other languages in difficulty to learn, and what is considered to be a good compiler/interpreter. thanks
    : :
    :
    : The language itself is "one-to-one" meaning one assembly statement coresponds to 1 CPU command - you are directly commanding the CPU to perform command. High-level languages are "one-to-many" - one statement can correspond to hundreds of CPU instructions.
    :
    : Assembly allows direct hardware and memory access - writing device drivers, direct disk access etc. which high level languages often don't allow.
    :
    : Assembly must be used to program embedded systems like microchips.
    :
    : Also, it's almost impossible to write large software projects - the code becomes too unmaintainable, which is why higher level languages are used.
    :
    : In terms of assemblers, well as has been suggested TASM and MASM are probably the most popular, although I don't know which is better.
    :
    :
    [blue]ASM can be used also as inline means in HLL to achieve the speed-up in places where it needs to be done. Example: you need to write a routine which scans a file for some key - C++ version will be considerably slower then ASM version.[/blue]
  • I do most of my programming in C++ but from time to time I have to embed assembler code in the C++ code. I have taken several courses in assembler and I fell in love with it (I know, you probably think Im sick) but I love it! The one thing that sticks out in my head is I had to compare two numbers by comparing their high order bits and their low order bits. It is very difficult to do in C++ so I did it is assembler in 6 lines and embedded that in the C++ code. I think it takes a certain person to like assembler, it is a different way of thinking. If nothing else it helps you understand how other programming languages perform. It allows you to understand the way data is stored in the registers and gives you direct access to hardware and drivers.
    Aaron


    : I've done some work with VB and C++, but have never written any assembly code. Could someone tell me some pros and cons to writting in assembly, how it compares with other languages in difficulty to learn, and what is considered to be a good compiler/interpreter. thanks
    :

  • By using the compiler option to compile to ASM, you can look at the MC version of your program and learn a lot. And, in turn see just how it all works.
    I have added a lot of routines to my C lib using Assembly. My favorites are string handlers like BASIC's INSTR/LTRIM/RTRIM/MIDSTR/STRING/STRIP(removes selected charactors from string).
    All C programers should at least be aquainted with Assembly.

  • : CONS: One command in C may take over 200 lines in ASM code. It makes you go crazy(quicker).

    What is this command, can you write an example for me?

    Thanks.

    Len
  • : : CONS: One command in C may take over 200 lines in ASM code. It makes you go crazy(quicker).
    :
    : What is this command, can you write an example for me?
    :
    : Thanks.
    :
    : Len
    :

    example command:

    [CODE]
    while ((getchar () != 13) && (EOF(stdin) != 1)) myprintfunction (nonsensefunction1(1,2,3,4,5,6,7), *nonsensevalriable1[nonsensefunction2(1,2,3)].pointer->nonsense++);
    [/CODE]

    i think you got the idea ... however you might not consider this 'one command' in ASM you need much more lines, and it will hardly be faster ... hardly better structured ...

    Enjoy coding the asm version ...
    Send me a postcard when you are finished, OK :-)

    SUSE LINUX 7.3 PRO - The world starts behind windows

  • [CODE]
    : while ((getchar () != 13) && (EOF(stdin) != 1)) myprintfunction (nonsensefunction1(1,2,3,4,5,6,7), *nonsensevalriable1[nonsensefunction2(1,2,3)].pointer->nonsense++);
    [/CODE]
    :
    : Enjoy coding the asm version ...

    Did you do it?
  • [blue]"But C++ programs is a [red]lot[/red] slower than programs written in assembler."

    Simply not true.
    Depends on a programmer - if you C++ crazy and represent every symbol in your program as C++ class called 'CChar' - then YES!

    You have to mix C/C++ and inline ASM in a healthy doses and do it only in a places where you actually need a speed-up: sorting, parsing, searching... etc.[/blue]
  • : Also, it's almost impossible to write large software projects - the code becomes too unmaintainable, which is why higher level languages are used.

    Take a look at the whale virus, 200KB+ source code at http://www.sirkussystem.com/
  • : : Also, it's almost impossible to write large software projects - the code becomes too unmaintainable, which is why higher level languages are used.
    :
    : Take a look at the whale virus, 200KB+ source code at http://www.sirkussystem.com/
    :
    I tried to goto the http://www.sirkussystem.com/ and it came up 'Unavailable'
    However, I have to wonder just how much is code and how much is 'Comment statments'. Surly, one would have to use a lot of comments in a MC program of any size. When I write MC, most of what I write is comments, I'd say about 80% of the file size.
    Writing a large MC program is not too bad if you use includes like you would writing C/C++.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories