flat assembler
Message board for the users of flat assembler.

Index > Heap > preferences...

Author
Thread Post new topic Reply to topic
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
In the thread on optimizing, in the MAIN section of the forum, Privalov wrote:
"It's also appears to be related somehow to my reason why I prefer order of arguments in Intel syntax (destination first) over the others - when reading the code it makes easier to read (with the usual assembly language indentation, of course) at first look which registers are modified by some piece of code."
This comment led me to reflect a bit on the syntax used by ATT, GAS for example, and the Motorola syntax, for the 68020 and many other cpus. Why is it an advantage to put DESTINATION, before SOURCE, or vice versa? So, thanks Privalov, for this motivational inspiration to do a bit of searching on the internet to learn something about preferences, and in particular, the physiological or ergonomic basis for a particular way of doing things....
http://www.ccbi.cmu.edu/reprints/Newman_Neuropyschologia2003-ToL.pdf
The question of preference regarding source/destination, left/right, front/back, top/bottom, etc, is the topic of investigation in this article, published a couple of years ago. fMRI is a nifty technique, which I endeavored to develop 15 years ago, UNSUCCESSFULLY, perhaps because I employed myself as test subject, squeezing a ball, triggering the RF emission by my EKG, or perhaps because the 1.0 Tesla magnetic field I used was too weak, or more likely, because the RF antenna was not focused on my motor cortex (Brodmann's area 4). Anyway, the folks who published this article have some interesting data regarding the two main types of cognitive processes: executive/planning, and visuo-spatial. What I like most about the article, is their discussion concerning RH and LH spatial centers in the superior parietal cortex. Those who prefer Source, then Destination, or top: origin, bottom: destination, or, vice versa, may find satisfaction in the knowledge that there is a physiological basis for the preference. I confess to believing in conformity with LOT Polish airlines, that it is COUNTER-INTUITIVE, to provide the DESTINATION, before giving the DEPARTURE city. http://www.lot.com/app/index.jsp?area=homepage&type=default&region=CA&lang=en
CHEERIO, tom Smile
Post 06 Apr 2005, 12:31
View user's profile Send private message Reply with quote
YONG



Joined: 16 Mar 2005
Posts: 8000
Location: 22° 15' N | 114° 10' E
YONG
Densely packed ... just like the neurons in your brain ... What a beautiful message!

Wink
Post 05 Nov 2009, 12:14
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Because, tom, it's ASSIGNMENT.

Most languages have something like this:

Code:
x=5
x:=5
x<-5
...    
to assign something.

In C you can even do:
Code:
x+=5    
which means 'add x, 5'...

get it now?

if you want to fight with this ideology, fight with all the languages like this. It is much more LOGICAL that way and it's obvious since it's preferred in most languages...

_________________
Previously known as The_Grey_Beast
Post 05 Nov 2009, 18:47
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
the reasoning for it is obvious. The problem with MASM syntax is use of words (i think they managed to do the usual 3 way to handle a pointer method like in HLLs to make life even more crazy). Gas, technically, is more natural than any programming language, if you think about it, but it could still be better. If you notice, these languages are based on english, where it goes subject object verb. With gas (why some people like it) is that it's verb subject object. Europeans might even like src, dest mneumonic. However, borsuc is on the nose with the HLL thing. Perhaps someone bored enough could make a modification of c where it's more like english.

However, to be honest, since ASM came first, it would also make sense to say that it's not AT&T syntax came from HLLs, but HLLs came from AT&T syntax.

I could see it now... 5+&@a; (five PLUS and assign AT a [5+=a;])

Or, better yet: +-5@a; (add -5 to a)
Post 05 Nov 2009, 20:21
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
With all due respect that would be stupid as seeing WHERE the data goes, i.e what is being manipulated, is much more logical to think in terms of a program, much easier to grasp "what it affects" and what it does. I very much prefer destination first, not only in asm but in all of programming!

I couldn't care less about english. As far as I know, english is not a language built on logic and intuitiveness, like most human languages Razz

_________________
Previously known as The_Grey_Beast
Post 06 Nov 2009, 02:21
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
Naturally it's not NECESSARY to make it like human languages, but the idea of HLLs was to simplify (both to make easy and to avoid "unnecessary complications and repetitive tasks" [see fpu] and, of course, a universal way of programming than having to learn a new CPU every time) programming by making it more "natural." Human languages are logic with heavy indirection and abstraction with things like synonyms and and general terms. For example, an "int" is a general term. It could be a word, a dword, a qword, etc. It only means it's not floating point. Another example is that 4/3 could be interpreted as either floating point (once again, abstract term) or as some size of integer. Just like human languages, context tells the meaning.

And before we go too deep into debate here ('cause really, before anyone goes off the deep end, we must remember that we're arguing about the assignment operator), you'll notice that HLLs in particular are quite similar to human language, only they have a more rigid syntax. For example, in english, a conditional is of the syntax "if [clause], [result clause]." in programming languages it's USUALLY "if [clause] [optional opening parenthesis] [result block] [optional ending parenthesis which must correspond to, and be present in the case of, openening parenthesis]". Most even have a syntax for yet another clause using "else," where it would be another sentence in english. Moreover, like reading language, it goes top down (even vertical languages are top down). Similarly, events are typically chronological (as with spoken language), however (by using functions) events can be taken out of order using references (calling).

Now, for differences (aside from asignement, which one could argue would be an irregular verb [more specifically, "to be"] just like in natural human languages). It has fewer shared words between ALL the speakers of the language (key words). However, it does have words with similar meanings (the "standard" libraries like libc, etc) and dialects (the APIs specific to an OS) and even group slang (cross platform APIs). Though, it tends to define per conversation (program) words (called functions) to explicitly referance clauses, sentances, stories, etc where natural languages would implicitly do that using words like "it," "that," or "there." Moreover, programming languages aren't efficient enough (surprisingly through added complexity which, for once in this universe, actually makes something better) to rely on accenting or speech. It also doesn't explicitly or implicitly express feelings, but let's not forget that even in assembly you can "hint." And lastly, programming languages don't have as many failsafes to prevent misreading.
Post 06 Nov 2009, 02:57
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
DustWolf



Joined: 26 Jan 2006
Posts: 373
Location: Ljubljana, Slovenia
DustWolf
Think FPU!

select x
add 5

Now that's what I call logical. Razz

EDIT: *chokes on kohlrak's putting "GAS" and "natural" in the same sentence* XD
Post 06 Nov 2009, 03:46
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
YONG



Joined: 16 Mar 2005
Posts: 8000
Location: 22° 15' N | 114° 10' E
YONG
Hehe, finally got some replies 4.5 years later ... Wink
Post 06 Nov 2009, 03:58
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
What about the whole code perspective also. Let's not limit this discussion to just the line syntax.

Do you prefer: more-abstracted ---> less-abstracted or less-abstracted ---> more-abstracted?

An example of that I mean: more-abstracted ---> less-abstracted would look like this:
Code:
proc main
    call sub_func_1
endp
proc sub_func_1
    call leaf_func
endp
proc leaf_func
    ;
endp    
That is, the code gets progressively deeper into the details as you read further down.

C encourages less-abstracted ---> more-abstracted style (the opposite of my example above). Indeed C makes it difficult for you if you want to do it the other way around, you'll need header files and other whatnot to do it.

Multi-pass assemblers allow for either method, you can choose whichever you prefer.

Also, do you prefer data first or code first? I think C forces you to define data and constants first (am I right here?). Multi-pass assemblers allow either method.
Post 06 Nov 2009, 04:03
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
On the shirt I wear to play basketball, appears Olde School. Yes, I am old. I think like an old guy. I certainly act like one.

To me, one always starts with data first, then code. Reading code, without understanding the data, is like watching the conclusion to a movie, without knowing anything about the characters or the plot.

4.5 years isn't long.....
Smile
Post 06 Nov 2009, 11:58
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
I think C forces you to define data and constants first (am I right here?).

Well, it forces you to *declare* data and functions before you can use them. Eg. you can just say "hey, there will be a function which takes such and such parameters and returns this", and from that moment on you can call it. Function itself can be defined after it is called, or even in different object. And that is IMO the part you ignored: C encourages you to break down source code into separate modules. In this way, you have (at least one) file where you *define* the code of the module, and a header file where you *declare* the interface of the module. This header is included from other modules, and that programming style makes forward-referencing quite pointless. BTW, FASM strongly discourages this style (by lack of control from command line).

Quote:
Also, do you prefer data first or code first?

I prefer data defined along code that uses them. As for (rare) data that has to be global, I prefer having it in separate file Razz
Post 06 Nov 2009, 12:02
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
vid: Thanks, declare/define, I've never really been sure of the difference.

In that case asm has no notion of declaration. Whereas C forces declarations.
vid wrote:
I prefer data defined along code that uses them.
Yes, but do you put such definitions before or after the code that uses them?
Post 06 Nov 2009, 12:20
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
In that case asm has no notion of declaration. Whereas C forces declarations.

Right. Well, not exactly forces (you can order things so that there are no forward-references), but few people write C code in a way people write FASM code, one huge chunk. Since in C you break code into modules, and modules NEED to have some rather smallish exposed interface (and keep rest private), you are simply bound to have some list of public declarations for every module. This coding style isn't very possible without that. And also, well-defined small interface makes your code nicer in many ways, than one massive chunk of code which can alter anything from anywhere.

One problem in C is that people often mix declarations for public interface with declarations of private stuff (that shouldn't be exposed to other modules), to allow forward-referencing. But it isn't very serious problem, and whoever likes can fix it.

Quote:
Yes, but do you put such definitions before or after the code that uses them?

In the beginning of block that uses them... that's the nature of C language (or even FASM procedure macros, for that matter).
Post 06 Nov 2009, 14:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
I break my asm stuff into "modules", but those being macros instead of redundant function calls. Razz

_________________
Previously known as The_Grey_Beast
Post 06 Nov 2009, 16:40
View user's profile Send private message Reply with quote
DustWolf



Joined: 26 Jan 2006
Posts: 373
Location: Ljubljana, Slovenia
DustWolf
I find there is no way to code in a multi-programmer arrangement (using a CVS), without breaking the code down into many many files, which then come together in main.asm that has includes.

But within the modules it's always constants first, code middle, data later. This arrangement comes from the way things like self-extracting ZIP files are structured (if the data is at the end, you can easily include it in the binary from outside the assembler) and of course the need to keep the dynamic data and the constants seperate, to trigger segfaults in case of bugs.
Post 06 Nov 2009, 20:15
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.