Log in

View Full Version : Assembler programming


book
March 9th, 2006, 20:06
Hi. I know a bit about assembler now, but I still don't know how you actually start writing executables in it - I mean, is there a popular IDE, a development environment, something...........? What tools can I use?

JMI
March 9th, 2006, 22:27
It would appear that you have not actually spent much time THINKING about this subject or doing any basic research on your own issue. For example how about taking an obvious phrase, such as:

writing executables in asm (and/or) assembly language programming

putting them in your favorite search engine and reading some of the links you will find. This is something you are supposed to do here before asking a question and this is WHY it is written under your signature!

Here's another hint: you might want to check out "masm" with your favorite search engine. It is one of the development environments for programming in asm. There are several other well discussed ones which you should come across using the two search criteria I already gave you.

Among the resources your will eventually come across is a primer titled:

The Art of Assembly Language Programming

which you can also google and which will describe some of the basics.

You have alot of work ahead of you. The sooner you start, the faster your will make some progress.

Regards,

naides
March 9th, 2006, 23:15
Nice to see you around book

book
March 10th, 2006, 00:11
Hi Nadies (do i Know you? )

@JMI - I resent that! I'm not a complete idiot, uh. I know about the Art of Assembley book, obviously, and I know a bit of assembler(haven't ever applied it though). I have looked quite a few things, and eventually gave up. They all seemed either:
1. Outdated.
2. Freeware rubbish
3. Overly complicated

Are there commercial programs? ides that are relatively new? anything particularly powerful, like it would give you complete control over p.e. header & segments? What do the pros use?

LLXX
March 10th, 2006, 00:42
An assembler, of course. TASM 2.5 is rather nice. As you've mentioned, many aslr's are overly complicated, but what I do is wrap my code in standard headers and footers and then give that file to the aslr.

The AoA book is *not*, contrary to what it claims to be, about real Asm. If you've worked with real Asm for a long time, you will know what I mean.

"What do the pros use?" Aslr's that they have themselves written

It is also a very good exercise in Asm to *write* an aslr in Asm.

JMI
March 10th, 2006, 01:55
book:

It bothers me not in the slightest that you resent my doing my job. If you don't want to be reminded about searching, simply say what you have actually done to help yourself. My crystal ball was a little cloudy and I could not determine you had done anything to help yourself before you Posted.

No one suggested you were "a complete idiot" except you! If you can't tolerate a simple reminder of the Rules when your Post does not indicate you followed them, perhaps you should consider getting out of the kitchen. Since your Post indicated no effort and no knowledge, I gave you a reminder and a direction to start.

Whether you like it or not, or approve or not, that is my job and I shall continue to do it as I see it.

Regards,

oby1
March 10th, 2006, 02:31
This guy is thinking that:
- AoA is outdated
-Iczlion tutorials are outdated
-MASM 9.2 is outdated
-Gosam is aoudated
-FASM 32 bits and 64 bits is oudated
- surely TASM 5.3 are oudated
-coultless tutorials om MASM32 and Win32ASm and FASM bord are all outdated esp the ones about OOP design paterns , simplicty, speed andfull controll

The IDEs like RadASM with code folding and instant forward and back in code tree is outdate and probably freeware rubish besides it was updated yesterday and this clearly makes it oudated since is not from today...

Same goes for WinASM, ASM studio and other IDEs

Besides i am sure that SolarOS full GUI 32bit ASM os under GPL is freeware rubish Also Menuet32 and Menuet64 bits are freeware rubish DexOS also

I guess he has found some Tasm 1.0 IDE for DOS 2.0 and some samples using int 10 and mov bx, es mov dx,es and now he is checking the advanced programming in 320x240 CGA/VGA on S3 trion 3D chipset because...

DirectX and Direct3d tutorials of Scronty and Hostile Encounter DirectX Win32 full ASM game is clearely outdated ....

The man clearely knows what he is saying and as every newbie out there he always knows better because he has read some tutorials on dc++ ... directly from the masters of course...

Sorry that this had to be my frst post here... but there are many "outdated" hints inside...

book
March 10th, 2006, 04:16
@JMI - God, this sort of stuff ruins forums....im not offended....can we get on with our lives..........

@oby1 - Your an idiot.
My point was - All I could find were a bunch of pokey, out-dated looking websites for assemblers that looked as if they started off as someones personal project(not to hold that against them). Hard to use(gave up on radasm), old fashioned, and about 10 years old. I assumed I must be poking around the edges and missing the good stuff - There must be some popular commercial title somewhere right? Obviously not.

I'm sure your a nice guy in real life.

Admiral
March 10th, 2006, 07:50
Quote:
[Originally Posted by book]... God, this sort of stuff ruins forums ... Your an idiot ...


book, please try not to take our members' impatience as a personal attack. Although the posts may be tinged with sarcasm, you've actually been given a lot of useful information already.

A fact of the matter is that most assembly languages are pretty old and are bound to working on existing hardware that is used all over the world. A consequence of this is that standards have to be adhered to and so ASM is by-and-large very static. A tutorial that is ten years old will contain 90% useful information. The remaining ten percent pertains to the details of modern CPU architecture and will, no matter who writes it, appear 'overly complicated' to anybody who isn't familiar with the basics.
My point is that you'd be hard-pushed to find an ASM tutorial or reference guide that is out of date.

As for an assembler, you've been pointed to MASM. This is the number one choice for Win32 programmers. If you specify a platform, perhaps we can give more inspired suggestions. All you're left with now is to find an IDE that suits you. I personally like WinASM Studio. Try it out. If you don't like it, take a trip down to Iczelion's site and check out his links section.

Finally, the best way to learn is to go into the deep end. I'd be the first to admit that I'm guilty of wasting hours and hours trying to find the 'best' tools for a task I've been set when I actually should be finding something adequate and getting my head down. Doing things the fast way will invariably lead you to the best tools as you find imperfections in your current arsenal and as you mingle with the societies. You'll also appreicate an upgrade far more if you've spent the last few months using something less 'perfect'.

As an aside, I want to know who was responsible for popularising the term 'assembler' to mean 'assembly'. If I ever do find out, and if he/she is still alive I think I'll make it my mission to personally do them some damage .

Regards
Admiral

0xf001
March 10th, 2006, 09:00
book,

I recommend to try to think in a way that not the outer form, ie the look of "things" is important - it's important what's inside

you will find that probably the better the content is - the more "uncommercially" ie websites look. the ones with the most fancy animations and big advertisments are usually worst

so keep on reading when you on an iczellions site, maaaan

regards, 0xf001

book
March 10th, 2006, 09:29
Thanks for the replies. And thanks for bearing with me, I generally attract a lot of irritated people by not being very clear it seems. I guess I will try and ignore age/appearance of this stuff more often, its just hard coming from a background of java/c++ not to look for up-to-date tools. And actually, I have come across a LOT of out of date content, so yeah, its a bit irritating.

I guess you answered my question. But to be honest it would have been sort of .......reassuring .......... to find out about a large scale, new program by people like borland/microsoft etc.

Fake51
March 10th, 2006, 11:07
Hi

Just wanted to add my 2 cents to the flame war (so seldom I get the chance). JK.

Anyway, here's the point: machine code is as low as you can go. Asm is just a representation of machine code. There's no way for anyone who doesn't design hardware to actually improve upon assembly. Hence, you can only make so many IDEs before it becomes trivial - given a thousand different text editors, how would you go about making a new and better one that would knock all the others off the shelf?
But that's not the real reason no big software company will do a major asm product. The real reason is, that asm isn't used by most programmers. Hence, the market for producing IDEs for asm is quite small. Add to that fact, that there are already quite a few IDEs available freely.

But actually, the fact that asm hasn't changed a whole heap (the basics, anyway) is not a bad thing, quite the contrary. Being away from my normal computer, I do small asm stuff using notepad, masm, and the build.bat modified to run easier. Actually, that's not a whole lot more minimalistic than what I otherwise do: UltraEdit and masm32. Plus, from time to time some resource prog/hacker. And ollydbg for debugging.
I guess the central question is: why do you go for asm? For me it's the simplicity, the minimalism. If I wanted big and shiny, I'd go for something a lot different.

Fake

Ps. Justification for writing this: notes on how to go minimalistic. Apart from notepad and masm32, all you really need to do win32asm is the platform sdk (browse it online, don't even have to download, although that is nicer) and ... well, examples like those found in the masm32 package.

sgdt
March 10th, 2006, 21:22
1 vote here for RadASM and MASM. And where would we be without Olly?

If the same number of people who write in C++ on a daily basis also wrote in ASM, we'd have tons of pretty web sites and correctly spelled tutorials and IDE's that link up with Microsofts dedicated MASM web sites. We'd have the latest DX and D3D APIs released in .INC form, and they would be supported, and CLR and IL would be religated back to nightmare status.

But then there's reality. Most people who think of themself as a programmer get all panic'y when they see the likes of MOVDQA. They have no desire to polute their universe with the machanics of the way things work. Hell, a great deal of them don't know how to deal with pointers, and couldn't tell a tag line from a page alias table. And yes, they take themselfs seriously.

So, if you want a well written and correctly spelled tutorial, or a fancy web site complete with a FLASH UI, or a wicked IDE that's always up to date, I think you best get busy.

Most of the people who DO use ASM don't really have the time, so I think it's up to you.

I look forward to seeing what you come up with.

LLXX
March 10th, 2006, 23:25
Quote:
[Originally Posted by book]Thanks for the replies. And thanks for bearing with me, I generally attract a lot of irritated people by not being very clear it seems. I guess I will try and ignore age/appearance of this stuff more often, its just hard coming from a background of java/c++ not to look for up-to-date tools. And actually, I have come across a LOT of out of date content, so yeah, its a bit irritating.

I guess you answered my question. But to be honest it would have been sort of .......reassuring .......... to find out about a large scale, new program by people like borland/microsoft etc.
Actually, with Asm I've found that the older the material is, the better. This is because the Asm community has experienced a decline over the last decade, so the newest material that you find will not be as insightful or as of much benefit as something e.g. 10 years older. Knowledge has been lost throughout time. For example, I have some Asm literature with source code from the early 1980s, and reading through the source code is like reading an engaging novel. The coders back then knew all the special tricks which made Asm enjoyable. Now, the source code mostly seems boring and unimaginative. It's as if the programmers are getting more and more stupid.

If you come from a background of Java/C++ or any other HLL, you will find Asm *very* different from what you're used to. As I've told countless others before, forget everything you ever knew about programming if you want to truly make the most out of the Asm language. The ways of thinking which are involved are so different that attempting to think of it in a high-level sort of manner will impede your understanding and thus your code will be no better than that emitted by a compiler. It is to write better and more efficient code that we learn Asm for.

Quote:
[Originally Posted by book]There must be some popular commercial title somewhere right?
Finally, one of the principles of Asm that you must keep in mind is that it's anti-commercialistic. It's against the commercial trend of progressing toward less and less efficient, higher and higher level languages. To quote one of the Asm Introduction lectures I have given,
Quote:
[It is]...an expression of freedom, against strict "structured" programming. It is to show the rest of them: "This is how software should be written. This is the true power of the machine. This is how small and fast software should be."
By choosing Asm, you are showing your defiance of "currently accepted" programming methods and your desire to write better software.

I think I've said enough. As you can probably see by now, I'm one of the few Asm coders left that still believe in the old ideals

Good luck... and may the power of Asm be with you someday

Fake51
March 11th, 2006, 05:49
Quote:
[Originally Posted by LLXX]
Finally, one of the principles of Asm that you must keep in mind is that it's anti-commercialistic. It's against the commercial trend of progressing toward less and less efficient, higher and higher level languages. To quote one of the Asm Introduction lectures I have given,
By choosing Asm, you are showing your defiance of "currently accepted" programming methods and your desire to write better software.

I think I've said enough. As you can probably see by now, I'm one of the few Asm coders left that still believe in the old ideals

Good luck... and may the power of Asm be with you someday


Different folks, different strokes, I guess. However, just one point: asm is NOT and ideal, it's NOT a political or economical belief, it's a programming language. Whatever you choose to do with it is your own business, as with any other language. Choosing asm does NOT mean showing your support for anti-commercialistic ideas - it merely shows you're choosing a programming language.
That said, choosing asm is definately one way of displaying attitudes towards the the world of computing today. Not too long ago, a friend of mine highly recommended programming in a .net environment to me. Development was so much faster, he said. And then admitted: but ofcourse everybody who wants to run your stuff needs the .net files. Going asm is one way to show that you really don't care for that kind of dependency.

Fake

0xf001
March 11th, 2006, 07:48
hi,

sorry its polarizing too much, i could not help my self to post again hehe ...

Quote:
However, just one point: asm is NOT and ideal


as with everything - it depends what you want to do, no language is ideal. some are better suited and some not so suited for a specifc case. always. you won't want to have your highly optimized gfx drivers coded in VB probably and you won't want to code a desktop environment in asm _probably_ LOL

cheers, 0xf001

Fake51
March 11th, 2006, 08:12
Hi

Good point to make, although it quite misses what I was commenting on LLXX was writing about asm being anti-commercialistic as if asm was invented by a peaceful ngo for the betterment of our lives. Asm is not an ideal in the sense that it's not an utopian set of beliefs or anything like it. There may exist a community of asm programmers who share some anti-commercialistic attitudes - but this does not reflect on asm as such.
But ofcourse, here you point actually applies in a double sense Asm is probably better suited for something like anti-commercialistic communities than .net is
Anyway, I was just reacting to the whole glorification and sanctifying of assembly - it's just a tool, it was invented to make coding a lot easier. End of story. You want heroes and saints? Look to all the people who spend time and energy writing code and publishing it, giving it away for free. But they are heroes and saints irregardless of what programming language they use.

Fake

nikolatesla20
March 11th, 2006, 09:00
I agree with Fake51. This is merely a tool. However since it seems so outdated, as the one searching has admitted, it can seem somewhat "romantic" and also "powerful" to program a system in pure ASM. Most these days rarely have the knowlege to do such a thing so really in a way it has become a lost "art". BUT one must remember that it is not "art". It is only a means to an end. But it does give one more "power" in the fact that they have the lowest level (next to the hardware) knowlege - and knowlege is power. Once you know ASM, most software protections begin to bend to your will and not the other way around

I will agree also with LLXX in the fact that older publications no doubt are better - back when coders had not choice but to use ASM. But it is also good to learn modern principles in ASM, such as how OOP works on the low level, because really it's just another construct of man! Once you know it you can write more effective ASM code but still think in high-level terms. Other interesting topics include how COM works at the ASM level, and then on to the PE format and binary layouts (since having learned ASM, you learned the compiler side of things, and now you must learn PE format and file formats, to learn the LINKER side of things!). Combine knowlege from those two and there is very little you CANNOT do !

-nt20

disavowed
March 12th, 2006, 02:45
Quote:
[Originally Posted by nikolatesla20]Other interesting topics include how COM works at the ASM level

I'd rather shoot myself in the face than deal with COM at the ASM level

oby1
March 14th, 2006, 14:15
COM is very easy in ASM:

and extract from my RTS game: Hostile Encounter calling DirectX COM interfaces:

Code:

Direct_Draw_Surface_Lock1 PROC
USES esi
ARG @@a_surface:dword
LOCAL @@tmp_result:dword
;------------------------------
; setup surface descriptor
;------------------------------
Call Zero_Memory_Byte, offset ddsd_all, SIZE DDSURFACEDESC2
mov esi,offset ddsd_all
mov [esi.ddsd2_dwSize], SIZE DDSURFACEDESC2

;-------------------------------------------
; params to IDirectSurface:Lock()
;--------------------------------------------
push 0
push DDLOCK_WAIT
push offset ddsd_all ;surface descriptor to get pointer in
push 0 ;full rectangle
push [@@a_surface] ; surface to lock

mov eax,[eax] ; find vtable address
call [eax + DDS_Lock] ; call the Lock method

.IF eax!=DD_OK
ODS1_fmt <"Ddraw:LockSurface Failed:%x">,eax
jmp Game_Finish
.ELSE
;ODS1 <"Ddraw:LockSurface:OK">
.ENDIF

;----------------------------------------
; return the pointer and pitch in eax,ebx
;----------------------------------------
mov esi,offset ddsd_all
mov eax,[esi.ddsd2_lpSurface]
mov ebx,[esi.ddsd2_lPitch]
ret
ENDP


Kind of old code as now I use is more like:

COM_Call [a_object],a_method, param1, param2,...

And if you programm in modern ASM it does not mean that you can not design and think in an OOP like fashion.

As you can see COM is simply reduced to:
Code:

push method_parameters
push object instance
call [object_instance_vtable+Method]


Hardly something to be considered very complicated.


Nevertheless using a simple text editor and RADASM (lately)...
I and one friend have been able to create a full RTS game of the magnitude of the Starcraft in less than 6 months in a team of only 2 full programmers working normaly (8hours per day). There is a functional demo available on the net... i guess you know.

The same project took the original comerciall highlevel company 3 years and 30 programmers and who knows how many tools and IDEs and management.

I have later created an Operating Sytem with GUI and reparent window objects, true translucency multiple desktops, controls and dynamic auto-aranging content in a little over 6 months of work (yeah only 3 months full and then 1 day per month once in a while fro the last years).

So my experience is that speed of development in ASM is 10x bigger than any modern HLL programming language.

The ASM problems are actually:
-------------------------------
-non portable code
-the need to be able to remove the programmers as you wish and pay them as low as possible
-experienced ASM programmers are hard to find today while yo can find a huge ammount of HLL programmers per day.


Non "art" like programmes in VC++/VB/Delphi/NET/Java whatever can be replaced very easy and payed wery low income.

You do not have to depend on algorithms, inteligence and "art" --> it is much more reasurring for the investors to be considereing "the programmer" a simple "machine" that uses and IDE and OOP tools to achieve the task of making them rich (the investors) as fast as possible and no matter the cost to the users.

LLXX
March 15th, 2006, 20:09
Quote:
[Originally Posted by oby1]So my experience is that speed of development in ASM is 10x bigger than any modern HLL programming language.
I think in your case it was just a question of intelligence and skill, which experienced Asm coders certainly have more of in comparison to HLL programmers. However, if you said that the Asm programs are (more than) 10x smaller than their HLL equivalents, that would certainly be true

Quote:
[Originally Posted by oby1]You do not have to depend on algorithms, inteligence and "art" --> it is much more reasurring for the investors to be considereing "the programmer" a simple "machine" that uses and IDE and OOP tools to achieve the task of making them rich (the investors) as fast as possible and no matter the cost to the users.
It certainly seems that way today. I'm a recreational/competitive Asm programmer (my occupation has nothing to do with programming), so I take my time and ensure that the code I write is the best it can be. It's only commercialism which has caused the recent flood of countless EHLLs like .NET/Java/etc. and the corresponding decline in the intelligence of the "programmers" (I hesitate to even use the term to describe these "writers of code".)

oby1
March 15th, 2006, 22:10
Quote:

I think in your case it was just a question of intelligence and skill, which experienced Asm coders certainly have more of in comparison to HLL programmers.


Since beeing an experienced full ASM game or OS kernel programmer today is rare I kind of agree with your statement.

But there are a lot of very skilled HLL programmers out there also (mainly in C/C++ area). However most of them are bound to ignore some parts of how things really work at a low level and this is not giving them an avantage compared to an equal experienced low level ASM proggrammer. I have once too offten heard them say that "on today super comuters" an multiplication might be faster or equal to an addition of an integer variable

Funny is that I am very experienced in both areas: low level and HLL.

Quote:

if you said that the Asm programs are (more than) 10x smaller than their HLL equivalents, that would certainly be true


Not exactly... HE RTS is 800 files/modules over 75 folders and more than 300.000 lines of code after streamlineing. Because of macro usage sometimes every line expands on more ASM lines. Not to mention we also did have to develop additional tools like: Map Editor and inhouse Sprite format convertor/encoder and they are not exactly small either.

But funny fact is that the binary release has more files: 1857 in 157 folders.
(because of sprites)

I would like to finish this by two important quotes that the mankind never understood.
One is by Einstein that once said: A solution to a problem must be as simple as possible to get the job done, but not simpler than that.

Instead of understanding that you must seek the most simple solution people choose to add layer on top of layer to the "solution". And honestly there is not limit to the complexity of one solution. That is why Einstein and God did provide us this HINT: never add anything to them most simple solution!

The second was pointed to me by a friend and former co worker on HE (Eugen) ...
Antione de Saint Exupery once said: A design is completed when you can not substract nothing from it and not when you can not add nothing to it.

A phrase that each software designer should read untill fully understood...
It is the same principle as Einstein's but expressed in a more humman clear way.

The speed of an experienced ASM designer comes exactly from this seek of the most simple but still fully functional solution and a wise decission to stop loosing time with useless levels of complexity on top of that.

Silver
March 16th, 2006, 04:56
Quote:
and extract from my RTS game: Hostile Encounter calling DirectX COM interfaces:


DirectX is a lot easier than other SDK's with respect to COM. DX wraps all the COM stuff in friendly classes and helper functions. If you were to code (for example) an app that interfaces with Office you'd find it much, much harder.

IMO you can't call DX coding "COM coding". You can learn to code DX without any knowledge of COM.

ViceVirtue
March 28th, 2006, 02:51
How would you (plural, all/any of you) rate GCC as an assembler? Should it be done, should I use GCC to compile assembly?

LLXX
March 28th, 2006, 06:22
GCC is a C compiler, not an assembler.

ViceVirtue
March 28th, 2006, 06:34
Yes but it can also assemble (by default, it assembles files ending with .s)
It creates assembly files with the -S option (AFAIK) from C files (ie it goes most of the way of compiling it..)

0xf001
March 28th, 2006, 07:56
hi,

well the assembler used by gcc is as, which aparently supports at&t syntax, rather than intel syntax which seems to be more popular on x86 platforms, so maybe check what syntax you want to use before using it. nasm ie supports intel syntax if you want to try that. Of course its good to understand both variants, but to start with better stick with one i think

regards, 0xf001

blabberer
March 28th, 2006, 10:42
Quote:

gcc is as, which aparently supports at&t syntax,


well gcc also supports intel syntax
well there are a few tutorials by stingduk few simple programs using gas and intel syntax and gcc inlined
that uses intel syntax

actually masm style invokes too (i didnt understand why or how that macro is working but it still works

may be you can check them out if you like
http://www.reversing.be/article.php?story=20051222184434392
http://www.reversing.be/article.php?story=2005122814133523
http://www.reversing.be/article.php?story=20051230165311578
http://www.reversing.be/article.php?story=20051210184532785
http://www.reversing.be/article.php?story=20051203194931893

0xf001
March 28th, 2006, 10:58
hehe,

well while gcc supports it, as does not i thought, cause there was nothing in the man page.
until i figured .intel_syntax noprefix
however i mainly use nasm hehe
i undestand the question for the assembler to use to assemble ".asm" files, or do you want to create them?

regards, 0xf001