News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Traditionist Coding style

Started by MusicalMike, July 24, 2005, 07:24:40 PM

Previous topic - Next topic

Mark Jones

Jeez, is nothing simple and sacred anymore? :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

Mark,

The world is a malicious plot to kneecap you into cowering complaince where I am a "a Rafferty's Rules" man myself.  :bg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MusicalMike

Jeese, I didn't figure on my thread becomming so popular. In any event, a lot of people seem to be interested in the square bracket issue now. I happen to know the answer to that. Assemblers like fasm, gas, etc use a very different style from MASM and TASM (TASM is the next closest thing to MASM). Square brackets are traditionally used for addressing memory via the complex memory addressing modes, since this is built into the CPU MASM also supports this feature. Assemblers also allow you to use the subscript notation such as this; myLabel[0].

PBrennick

I would not say that masm does not support indirect addressing.  It just does it in another way.  Using OFFSET or ADDR is a form of indirect addressing in the sense that it tells the assembler it is NOT an indirect address because the variable contains the data.  A variable can be a pointer to another variable that contains the data.  This is indirect addressing.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Randall Hyde

Quote from: MusicalMike on July 29, 2005, 01:18:51 AM
Jeese, I didn't figure on my thread becomming so popular. In any event, a lot of people seem to be interested in the square bracket issue now. I happen to know the answer to that. Assemblers like fasm, gas, etc use a very different style from MASM and TASM (TASM is the next closest thing to MASM). Square brackets are traditionally used for addressing memory via the complex memory addressing modes, since this is built into the CPU MASM also supports this feature. Assemblers also allow you to use the subscript notation such as this; myLabel[0].

At the CPU level, indirect addressing is specified by various bit patterns in the opcode. Brackets have nothing to do with it. Syntactically, you could use parenthesis (as Gas does), an asterisk (as C/C++ does), a caret (as Pascal does) or any other syntactical form.

In standard (original) Intel syntax, identifiers in the symbol table carry sufficient information to let the assembler know if they are a memory location or something else, so the assembler can determine whether an identifier references memory just from the identifier. However, this takes a more sophisticated data structure in the symbol table and more complex code in the assembler itself. It is no wonder that hobby level assemblers eschew the Intel syntax and go with the use of brackets to signify memory access -- it's much easier to code.

In the early days of computer, assembly language syntax was kept as simple as possible because assemblers had to be small. Early computers didn't have much memory and you couldn't afford all the extra code and data to support a sophisticated syntax. Several "old-timers" got used to that simplistic syntax and grumbled when Intel syntax came along, but Intel's syntax is better for many well-understood software engineering reasons.

As to the "hobby-level" assemblers, that's a choice they made and they're going to have to live with it. Some prefer that syntax, but it has it's own drawbacks.
Cheers,
Randy Hyde

MusicalMike

(off topic) Wait, are you THE Randall Hyde the creator of the High Level Assembler?

PBrennick

[Grumble]

Is that an indirect grumble?  I sure am a grumbler, though.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Randall Hyde

Quote from: MusicalMike on July 29, 2005, 04:40:38 PM
(off topic) Wait, are you THE Randall Hyde the creator of the High Level Assembler?

One and the same.
Cheers,
Randy Hyde

Mark Jones

Wuh-oh, this thread is really goin' askew now. :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

tenkey

Quote from: Eóin on July 28, 2005, 11:56:33 PM
Well tenkey, FASM uses bracketing around memory references. The logic is that the variable name is really just an equate for its address value (be it absolute or relative) in memory and you would use brackets if you were entering the address so you use them with the name.
I should have stated that the Zilog assembler was the only non-x86 assembler that I've ever seen that uses bracketing (actually round brackets) in the same way as FASM/NASM/etc. I implied it in the sentence that followed.

Because we're talking about different syntaxes that describe exactly the same machine, I just view it all as window dressing. I have my preferences, but I have no problems with whatever style you choose. Heck, if I was interested enough, I'd create an assembly language that looked like the mainframe assembler I used to use.

The question has been about "traditional" coding style, which uses minimal syntax. As Randy mentions, this was true of the really old (and thus to my mind, the "traditional") assemblers.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

Xor Stance

#25
Pbrennick,

quote from AOA:

There are eight forms of this addressing mode on the 80x86, best demonstrated by the following instructions:

      mov( [eax], al );

      mov( [ebx], al );

      mov( [ecx], al );

      mov( [edx], al );

      mov( [edi], al );

      mov( [esi], al );

      mov( [ebp], al );


I know I haven't learn asm that much but its because I read asm only 1 minute and then play or do something else.
But now I have mature a little bit, and the bore is getting drown away fool genes let me stay.

That sucks that masm doesn't let you support a normal syntax from Intel, damn ms. But LEA direct addressing mode, I didn't know much about OFFSET and ADDR but I know there functions.

MusicalMike,

all was derive from machine language 0101 to 0101 asm, asm with macros, etc... You can try Goasm the tuts is where you learn quickly and fast. HLA has its own book AOA, the best for description among overall, Nasm has its own doc it can be handy and Masm32 only has iczelion. programmersheaven.com Asm > a tutorial for 16-bits Adams or Cat like that the best
for getting started at DOS old days and then in Webster again you have to find the formal doc from ms imo good. Before you get lost... I forgot the Intel manuals don't get lost like Linux devs that they don't know that they're doing in Intel.

Just a note in Go, the tutorial was maded to learn efficiently and fast you might find it difficult but that's how binary and hexadecimal numbers are useful. But much of the theory you must find it in HLA and the rest, asm is for people that earned a medallion for learning it like another language.