View Single Post
Old Sep 3rd, 2004, 10:56 AM   #12
scientica
Newbie
 
scientica's Avatar
 
Join Date: Apr 2004
Location: Sweden
Posts: 10
Rep Power: 0 scientica is on a distinguished road
Send a message via ICQ to scientica
Quote:
Originally posted by Mjordan2nd@Aug 29 2004, 08:09 PM
Well, Ok.

Pros:
Learning assembly language will increase your knowledge of the computer tenfold.
You are in complete control of your machine.
Assembly code is as fast as it gets.
You can get access to unusual programming modes of your processor.
You can use it with some high-level languages

Cons:
Very tedious to write.
It is quite often buggy.
These bugs are hard to find.
not portable
I feel I must comment on this.
Bugs, bugs, bugs... it's like any other language, only more powerfull, eg, you can scatter the plate pile (the stack, a powerful place, there lies the path you follow uppon return )
but with well written (and occasionally documented, eg xor eax,eax needs no explanation) code, uit's quite easy to track down, and if you write your own debug code you get an (IMO) better/easier way to track down bugs --- eg you can write functions that tells you "I'm alive" and using that pin down to the instruction where the error is (well, it's a truth with modification, but it's up to the programmers use of black magic (like doing magic with the stack, chaning return address, writing smc, etc))

As for protable, yes, it's quite right, but as I've been told, with inline asm you can always fix that issue with #ifdef et al, ie one optimized assembly path and one unoptimized C/C++ path -- though it'll enlagre source it'll keep it portable (well, actually this is too truth with modification, as the asm it self still isn't portable )

And tedious, well, I'd say it's highly dependant on the programmer, a sadomasochistical programmer like me get's a kick out of having (more or less) total controll
Seriously, I find asm better than C/C++ in the aspect that there's no type casts to worry about (only the occasionall clarification of the operand size) -- but as I said I think it's a preference thing

And the unusual modes, well, yes, but also no, in a secure OS there are limits (eg some instructions are privileged and can't be exeucted (w/o CPU exceptions, eg, wbinvd and invd ("cacheflushers" - one writesback the other doesn't - could cause system to crash if used impropperly)) in ring3 (think userland), but in ring0 they can (think: usualy kernel and driverspace). But it's quite fun where one can go, iirc in DOS (and many others) you could get to a mode known as UnReal mode, which is a special mode (think real mode(16-bit) + GDT from pmode(protected mode, 32-bit) - giving you more addressable memory).

And the speed, it's true, well writen code is inded the fastest (eg, fit a loop in a L1 cache line (iirc 64 byte for most x86) and prefetch it and you might be lucky enougth to have it executes as fast as the processor can do .

One great way to learn about what makes an computer tick is to write a lillte toy OS, it's something extra ordinary (one learns many fun things, like the why behind A20 beeing disabled, that some hardware is accessed via the keyboard controller ) :blink:
__________________
Regards
Scienitca (registered user #335819 - http://counter.li.org )
--
Together in diversity, we each according to ability, to each according to needs, will help this world (to) become better - who did you help today?
scientica is offline   Reply With Quote