i know than i gonna be 'Hunted like a dog'for make this questions but ... i have to :

write a program in MASM it's better (faster an smallest) than do it in other languages?

what is better (fast and small), make an IF...THEN HLL instruction or use a cmp...jxx?

What is better , use Windows APIS to perform (i.e. write, read , move, etc, some file, or other tasks) or
invent again the Wheel and use interruption and all the old fashioned routines to accces to the I/O devices?

how can i reduces the amount of memory ram used by my program?

.....

i hope u understand this quetions that come to my mind
after read some chapters of THE ART OF THE ASSeMBLY LANGUAGE


:grin: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :grin:
Posted on 2003-02-18 06:40:48 by DrBios
write a program in MASM it's better (faster an smallest) than do it in other languages?

in asm your code should definitely turnout smaller since there'll be less overhead. in most case it will be faster but if you write sloppy code expect sloppy results!

what is better (fast and small), make an IF...THEN HLL instruction or use a cmp...jxx?

in masm .if....elseif....else....endif chain resolves to the same thing if you use cmp..je/ne...jmp...cmp..je/ne...jmp... chain.
I think the confusion occurs because people see if..then constructs as some sort of HLL invention. I use them all the, they make the code more readable. You'll often see in the fasm forum guys screaming bloddy murder at the mention of such constructs(if while repeat invoke etc but that's why I love masm and any assembler hoping to attract my useage can't be stuck in the dark ages!:tongue:

What is better , use Windows APIS to perform (i.e. write, read , move, etc, some file, or other tasks) or
invent again the Wheel and use interruption and all the old fashioned routines to accces to the I/O devices?

in 32bit windows io instructions and other which change the operation of the cpu are privaledged instructions available only to ring 0 applications(drivers etc). Normal applications will generate an exception. If you're writing for an OS it makes sense to use it's api...when we wrote for dos we used int 21 to call DOS api functions...now we write for windows/linux etc...we use the apis provided(at least when it comes to interfacing with hardware(file io/mem allocation and OS specifics etc).

how can i reduces the amount of memory ram used by my program?

minimize program size, minimize variables, use temp files for storage(not really!). is it nesseccary?
Posted on 2003-02-18 07:36:17 by MArtial_Code
I'll might be considered as an "old school & old beliefs" guy but I think that it's not the language that makes the programmer but the way to adapt. There is no "one" language IMHO, there are cases where one is more appropriate than another. The good programmer is the one that is able to use C/C++ in some circumstances (e.g. C is nice for system programming), might use C++ to build a compiler, might use VB to code a library organiser (if that lazy ;) ) and ASM to optimize some graphical functions or any other routine that has to be small, fast and without too much overhead.

Now I guess that if we are here is that we love Asm or we love to learm Asm (me far from knowing it, still learning, quite a Newbie) and we try to show that everything can be done in Asm, like the founders proved that we could code Win32.

To be sincere, I'm fed up of people shouting "I'm a programmer! I can code in ..." and they shout the name of a HHHHHHHHigh (very high level ;) )Level Language without having any methodology. I work in a company as Software Engineer, I'm doing mostly RAD development while my studies were focused on plain C/C++. When I'm home I like to try stuff in ASM. Takes away that bitter taste left in my mouth during the day ;) I meet plenty of people not working in the IT teams as "Business Oriented" that think and say that they can do the same we do in VB. I think we're forgetting the concept I put in the beginning of the long boring post. Learn how to code without being bound to a language, that makes possible to choose the language.

Ka.
Posted on 2003-02-19 07:05:11 by KaSt
The art of coding/programming is also to find the best algorithm.

Regards,

Vortex
Posted on 2003-02-19 07:35:44 by Vortex
Do you think HLLs were invented for use by non-engineers? In the past only electronic engineers could program because everything was hardcoded and/or at the hardware level. In order to make the whole idea palatable to people not interested in electronics they had to come up with something that worked for those not interested in the hardware, only the concept of the what the program would perform. This way, those more interested in finance could also be programmers and write those type of programs. Then you wouldn't have to make electronic engineers understand finance.
Posted on 2003-02-19 11:14:31 by drhowarddrfine
drhowarddrfinedrhoward, guess what I said maybe wasn't that clear. I didn't say HLLs were invented for "non egineers" or that you can spot a "non engineer" because he/she codes in a HLL.

I just said that a true coder knows what language is more appropriate to a situation and his/her skills make he/she can easily switch from one language to the other. Coding, my personal belief, is an art. An art which can be trained by anyone, sure, but musicians can switch more easily from one instrument to the other than me from my "Happy Birthday" on a piano to a flute or something else.

Everybody can code, the only thing I said is that a method has to be learned. Then, doesn't matter what language you choose to use. This makes your code easier to read, easier to understand, easier maintenance...

Don't tell me about "Finance people" coding. I work in a "Financial Institute" and had more than a couple of times to debug "user's code" ;)

This is more a joke than something else but you can spot code which hasn't been done by IT people as there are IT people coding like pigs (which is worst).

For Vortex, there you talk about the "high art of coding". Let's keep it simple for the moment ;)

Ka.
Posted on 2003-02-19 13:56:19 by KaSt
My question wasn't of you. I was thinking out loud. I've had these thoughts about HLLs and this was part of the reasoning. I'm not saying anything about what you said.
Posted on 2003-02-19 14:30:14 by drhowarddrfine
Oh, a few languages were intended for the use of 'non-engineering' personnel, perhaps the most notable is 'COBOL.' It was intended that boss would take a couple of COBOL courses and write all needed programs, then fire the programmers :grin:. And of course the boss never really learned how to program in it properly, so instead of firing the programmer, he tossed the COBOL manual at him and went back to do whatever bosses do :tongue:. he he he...


But anyway... most HLL's nowadays all pretty much look alike, it's hard to find a new HLL that isn't structured in a way highly remnisicient of C. Even modern dialects of old languages like ForTran and BASIC are now structured (although I think you can still write unstructured BASIC if you really, really want to).

And really, the number of programming languages you can write in isn't what's important in programming, it's how well you write in them. Things like structured programming, objects, etc. don't need to be supported by the language so that you can use them - the only support needed in the language is a way of extending it flexibly, such as through the all-powerful Assembly MACRO. Also, structured programming and object oriented programming must sometimes be broken so as to squeeze the most performance out of a piece of code. If you try looking at some of the optimized code in the Algo section, you may sometimes get lost in code that has been broken down from the structure it used to have and restructured in some other manner that is less obvious. Heck, sometimes the algorithm itself has been battered out of its original shape.


I just said that a true coder knows what language is more appropriate to a situation and his/her skills make he/she can easily switch from one language to the other. Coding, my personal belief, is an art. An art which can be trained by anyone, sure, but musicians can switch more easily from one instrument to the other than me from my "Happy Birthday" on a piano to a flute or something else.


He he he... I can play a tune on both a piano and a guitar, just needed a couple minutes to figure out how to position the fingers properly on the guitar (my primary instrument was the piano). Or rather, I USED to be able to do that, haven't played guitar in a long time...
Posted on 2003-02-20 00:12:42 by AmkG
My point wasn't how many languages you know but how easily you can switch from one to the other even if you don't know them. Means easily learning, adapting and for sure optimising...

Sorry, English isn't my mother tongue


Ka.
Posted on 2003-02-20 10:54:27 by KaSt
First of all I agree with Drhoward, man back then those machines, if you didnt know electronics you couldnt program, HLL's couldnt help ya because their compilers were garbage. man I wish those days were still here, but I am too young to have experienced those days but they looked like a lot of fun.

Ya like someone said before I can pick up many languages after learning assembly I picked up C and VB *VERY* quickly, so its a good idea to learn how to adapt into many languages so that you are as versatile as possible.
Posted on 2003-02-21 19:29:24 by x86asm
i just love ASM because in general you need to understand how computers work to use it well and that's what you learn by coding in it. that's something other languages can barely claim to do, however you put it. then you might even understand the basis of the hardware, and it no longer stays a software-only learning tool.
Posted on 2003-03-18 21:02:18 by Kobra
There is an element of truth in most of what has been said in this thread, pick the right tool for the job depending on your criterion of the right tool.

Learn to "program" and the language does not matter that much. If you really want small, fast and powerful, flexible code, learn and write ASM as it can do the lot but you must learn how its done and this takes a while.

Never do something harder than you need to do to get the result you are after, the pseudo high level constructions that MASM supports save you time and make a lot of code far easier to write in a reliable manner.

We all know how to write manual comparisons and often in a critical algorithm it works better but in complex logic, the pseudo high level constructions get the job done in a far more reliable manner than a tangled mess of CMP/Jxx.

It really depends on whether you want reliable code that works well or if you prefer to do things the hard way and miss out on the reliability for no purpose. Assembler is in fact a high level language, you can write opcodes directly in HEX but few of us are robust enough to do it. :alright:

Family names for different mnemonics, multiple names for the same mnemonic and a convevient notation is what an assembler is about, crippling an assembler just makes coding slower and less reliable.

Exstensions to an assembler, macros, libraries etc ... just make it a lot more powerful and reliable so if you want the full grunt of an assembler, use what it has available on a needs basis, not an ideological form of constipation.

Regards,

hutch@movsd.com
Posted on 2003-03-19 02:28:41 by hutch--

in masm .if....elseif....else....endif chain resolves to the same thing if you use cmp..je/ne...jmp...cmp..je/ne...jmp... chain.
I think the confusion occurs because people see if..then constructs as some sort of HLL invention.


I prefer to use jmps because of the following (a matter of style, not of assembler choice):
1. I find it more readable.
2. It permit me to self-document the code (meaningful labels are a good thing).
3. To branch only on special cases (avoiding to flush the cache, an artisanal pre-emptive branch prediction :) )
4. Some small optimizations rearraning blocks of code.

Regarding the subject, I still code in C/C++ and I am learning Ruby. Using the proper language for the proper task; but I get full satisfaction when I code in fasm or tasm,nasm,masm,spasm,goasm: asm is asm, no matter what dialect you speak ;).

Regards,
Posted on 2003-03-19 04:46:22 by pelaillo



I prefer to use jmps because of the following (a matter of style, not of assembler choice):
1. I find it more readable.
2. It permit me to self-document the code (meaningful labels are a good thing).
3. To branch only on special cases (avoiding to flush the cache, an artisanal pre-emptive branch prediction :) )
4. Some small optimizations rearraning blocks of code.

Regarding the subject, I still code in C/C++ and I am learning Ruby. Using the proper language for the proper task; but I get full satisfaction when I code in fasm or tasm,nasm,masm,spasm,goasm: asm is asm, no matter what dialect you speak ;).

Regards,


I agree with all that, especially #2...
Posted on 2003-03-26 21:23:40 by AmkG
I hear what you're saying about CMP/Jxx's versus .IF/.ELSEIF/.ENDIF's. I personally just converted a lot of older ASM code using CMP's to .IF's, because .IF's are my personal preference. I guess it's just the way my mind works. :)

One factor definitely in favor of CMP's is increased portability to other assemblers.

Another would be the experience of debugging your disassembled code: you're already used to seeing the CMP's and jumps, whereas an .IF/.ELSEIF programmer like me would have to make the additional mental translation. I've done it, and it's not terrible, but it *was* a little nicer to see the CMPs and jumps the way I programmed them.

Still, in the long run, I do find (for me) that MASM structured programming constructs bring more to the table than they take away. I am always very concerned with my program's reliability and correctness. Using full MASM helps me not only there, but it also helps me code a little faster.

:alright:
Posted on 2003-03-31 08:53:47 by MANT
some thing I see being left out is the role of comments
I see all this talk about readable code yes you should
use names that kind of explane what is going on but
readablety by humans is far form what a program was
ment to be the exlantions about what the program is
doing should be in the comments not the code itself
about being able to maintenance the code should be
broken in to vaery small chuncks that don't depend on
how each other works to work another thing I see that
has ben for the most part forgotten is the idea of
antibugging like checking the range input data and the
range of output data and putting error checking code in
the programes as a programmer you know better than
anyone else what a given chunck of code should do
and have at least a good idea of what can go wrong
when I started learnning assembly programming I had
no debugging tools at all and had to program defencevly
or else debugging was hopeless
Posted on 2003-04-24 21:05:26 by rob.rice
Comments, yeah, good idea. Here's another one: punctuation! :grin: ;)
Posted on 2003-04-24 22:28:57 by MANT
MANT Comments, yeah, good idea. Here's another one: punctuation!

ouchh

OK your right on that one
BUT am I right on my other points ????????
Posted on 2003-04-25 14:30:24 by rob.rice