Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a few quick questions about asm.

Status
Not open for further replies.

darknecromancer

Programmer
Nov 6, 2003
10
0
0
US
hay, whats ups guys! i'm new to this forum :). But i know some VB, some scripting, and alittle most about JS but i am interested in leaning and programming in asm. I was browsing the net and found several help files and a compiler, but i was unable to locate a... hm... i guess you could call it library. So i was thinking, maybe Asm is like scripting, your computer already has all the required 'stuff' to program in it, and not like VB where you need librarys. So my first quiestion is: does Asm need a library and i'm just not finding one? or is it like js or scripting where you can just go into notepad, please no comments on my choice of scripting programs :p, and make a program?

And also, i know this is kinda off topic, but i was told by my programming teacher that Asm is kinda like hex coding and that asm would help me understand hex. Does anyone know of any 'good' hex tutorials? i mean i could just search google but i dont know how reliable they are and how detailed they are, so i thought i'd ask you if you know of any good hex tutorials.

Thx :)
Mike
 
Hi Mike,

I'm not good in explaining something, but I'll try. So someone (anyone) please correct me if I'm wrong :)

does Asm need a library

You could roll everything on your own (if you want and if you can). But most of the time, we don't want to do it. And for a much bigger program we often can't do it ourself (depends on your skill). So I think the real question here is "Do WE need the libraries?" and the answer is (usually) Yes! Asm doesn't need a library but it can use libraries

and i'm just not finding one?

For Asm Real-DOS programming, it is not much you can find. But for windows you can use (mostly) C++ library, and there is a lot more you can find on the net.

Sorry, don't know any good hex tutorial. And I'm afraid can't explain this good enough (as I already mentioned). Hope someone will jump in.

Regards

-- AirCon --
 
alright, thanks for the info, please keep the info flowing :). I just reloaded my red hat linux on my computer, after uninstalling it from lack of use, and the loading process was funny. There were ads, information about red hat. Like there was on that had a hot dog, a soda, and a frig that say "hay! there if a great time to go grab a snag! :)" or something along those lines. Just thought i'd tell yeah :)

Be good
Mike
 
Hi there Mike

If you have any particular questions on hex, just shoot. I'll try my best to help you out.

I have no idea of ASM but I do know that hex plays a significant part in all assembly languages. For example, in SPARC you can actually "hand-code" instructions using hex rather than using sythetics or machine instructions. This is an interesting though tedious process and helps you understand how helpful a compiler can be!

Don't know of any online tutorial, but it's not difficult if you put in some time.

nopscti

 
o hay, sorry i meant asm. to be short for assembly : \. Yeah i dont know of any single question i have yet, but i'll just tell you what my plays are.

My CD-Row is packing to go south for the winter, and i have no $ right know to replave the drive. So i was talkin to my Programming Teacher and he said inorder to make a no cd ... 'crack' for a program u need to edit the .exe, more specificly the parts where it calls for files on the CD and just redirect it to the file on your Hard Drive, so i though ok, sounds easy enough. But i open up an .exe, just remembered .exe in windows : \ not linux, and i get like 20 pages of code. So i sort through it and in the first 1/3 of the .exe its just.... jiberous, just like "iabiew73u3iw8t3ib oiwnrow83o" and then the 2/3 is just "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" and the 3/3 halk is just CD error msgs. Like "No cd was found, please make sure you have the cd in the drive"
ok....wheres the calling of files 8 \, i figure its in teh jib but i thought hex was hex. :\
 
Hex is just Hex, a representation of a load of numbers.

The numbers may be instruction codes or they may be data.

It's the context that gives them meaning.

The hex of a Z80 program means nothing to an 8086.

And for that matter, the hex of a 286, 386, 486, pentium etc. means very little to an 8086.

If you want to find out what the hex in an EXE file means, you have to disassemble it.

You can do this by hand (or eye) but it's a long and tedious process.

Debug.exe will give an indication of the complexities of disassembly.

rgds
Zeit.
 
First you don't need a hex editing tutorial to learn and programming in asm. You, however, only need to know a few number systems: (decimal, binary, hexadecimal, and octal) in order to work in asm.

Asm uses mnemonics to give the microprocessor instructions. These mnemonic instructions are converted into opcodes (binary representations predetermined by Intel). Learning asm is not at all difficult, it only requires a different view of programming.

It is definitely true that asm will make you a better programmer than simply HLL programming. Libraries are used in ASM and they are available for your use in packages such as MASM32 ( Such packages allow you to code Windows programs and Console programs. 16-bit programs were a thing of the past (however, you can still make them using 16-bit linkers), and 32-bit is the current standard. That, however, will soon change with the accceptance of the 64-bit processors.

You should visit the win32asm community, and masm32 forums to learn more about it.


There are several assemblers available for use: MASM, FASM, HLA, RosASM, GoASM. MASM is the standard to start with. You can choose any other later. I'm writing a book on 32-bit x86 ASM in collaboration with several other ASM programmers. You might wanna have a look at it at:
Regards,
Art
 
Nobody in their right mind should write asm unless there is a good reason. That is precisely why so many people went to so much trouble to develop higher level languages.

Asm leaves everything up to you - you decide stack frame structures on the way in and out of procedures, you decide which registers get used for what. It doesn't protect you from disasters. Yes, I appreciate many modern assemblers will handle some of these issues for you (such as automatic stack frames) - but if you want your assembler to behave like a high-level language, why not go the whole hog and write the thing in C or similar?

Asm is also the least portable language of all: because your interractions with the big wide world and your user will have to happen via hardware or via whatever provision the operating system might make (and that might not be much!), everything you write is utterly fixed to that hardware and operating system.

The only places where anyone should consider writing asm are
(1) hobbyists who just enjoy it. Maybe you're one. If so, fine.

(2) places where every byte of memory counts. Asm code can usually be made shorter than high level stuff. But if every byte counts, you probably aren't thinking 64-bit processors or IBM-compatible PCs.

(3) places where speed is of the essence. Good asm runs faster than anything else. But beware: bad asm runs just as slowly as bad C, in fact often slower, because in C, even if you're a bad programmer, the person who wrote the compiler isn't. Their optimisations may be better than yours! Very few people will need to do this; an average implementation of a good algorithm usually beats a hand-tuned version of a dodgy algorithm, so time spent researching the approach is usually more effective than time spent putting it into asm. Frankly cleaning up your PC might have more effect than bursting into assembler.

(4) where you need to interact with hardware in a way that is difficult even for C in its most hardware-friendly implementations. Not many people will ever fall in this category.
 
(5) OS programmers. :)


The mind is like a parachute - it works better when open...
 
(5) and (6) = (4).
Large apologies to embedded people, who are numerous. I tend to take my washing machine for granted. Moderate apologies to operating system people - you are a lot less numerous than the rest of us, and if you don't recognise your application as being (3) and (4) then I don't want to use your operating system!
 
Don't worry, lionelhill, no offence was taken!

I write embedded stuff in C where possible.

Amazingly enough, there is a C compiler for the pic 12c508 which only has 512 bytes of EPROM.

I was reduced to assembler (free download from Microchip) in that case because I couldn't justify the cost of purchase of a compiler and the client certainly wouldn't buy it for one project.

rgds
Zeit.
 
Wow! Shades of writing things for the Acorn Atom, back in the days before I expanded it to its full glory of 12K.
In assembler I'm mostly hobbyist (so I don't want to put anyone off, despite my generally grotty moan-posting above!)
Professionally I'm still stuck with Pascal, because it's the only thing for which I have a proper licence with no restrictions about use of compiled products. That's what comes of being a mere technical user. One day someone will treat me to something more up-to-date.

Darknecromancer, one thing I have found good about assembler is when it's available embedded in a higher language. A higher language makes an excelent test-bed for embedded bits of assembler, and it can be really useful to be able to hand-code bits and pieces where speed is of the essence (for instance if you get into do-it-yourself graphics). The only caveats are (1) it's very un-portable and politically incorrect, and (2) a thorough knowledge of your compiler (how it creates function calls etc., what registers it uses for what purposes) is as important as a thorough knowledge of assembler. But aquiring that knowledge will help you write better high-level stuff too. You'll know the consequences of what you write. It's worth it, if you've got the time. Have fun!

 
Lionelhill,

a thorough knowledge of your compiler (how it creates function calls etc., what registers it uses for what purposes) is as important as a thorough knowledge of assembler. But aquiring that knowledge will help you write better high-level stuff too

Totally agree!
Well, I also use asm for hobby (1), some from (2) and (3). And I used to use Pascal too, but now I use a much higher languange :-D

-- AirCon --
 
Folks,

Assembler is definitely a pain to write and debug. This is nothing new!

Would like to call your attention to a plastic 8 1/2" by 11" card which MicroLogic sells with all the instructions explained for the Intel 8086/8088 chips. I found it to be exceptionally valuable when writing an entire program in the early 80's in one of the early MASM with NO include files or help.

Contact me direct if you want to know how to reach them or if they are out of stock, I have several at my office.

Yes, I'm one of those heretical programmers who likes to write assembler -- started in 1962! I have written a 32-bit integer to ASCII converter for the following chips: 8088, 80386, 80486 and Pentium. And, exceptionally optimized code for all chips differed! Certain instructions, across chip versions, have not received the same levels of optimization. Thus you modify the code avoiding the less efficient instructions.

bsh3
 
The little yellow handbook that comes with tasm is jolly handy, too. I have yet to see an op-code list in any textbook that contains all opcodes AND gets them right AND includes all information you need (like what they correspond to in binary, estimated cycle count on different processors, how many bytes they take up, what they do, what flags they change, and syntax of use, preferably with example).
 
This sort of stuff is becoming more and more difficult to find.

bsh3, was your version of MASM v1.00 like mine is?

I've got version 6.10 somewhere, but I still use version 1.00 with batch files since I don't have to think much to use it.

Bit slow on a 12MHz 286 though....

rgds
Zeit.
 
Zeit,

Believe it was Masm v. 2.0. Have owned all versions of MASM through something like 6.13d. Do remember that there were NO include files containing macros for opening files, performing I/O, etc.

Caution to those learning MASM, changed significantly between versions 5.1 and 6.0. Version 6.0 and later are easier to use.

The plastic card I mentioned is for 8086/88 and while I've been using it for 18 years, I've never found an error in its flags or hex decomposition. The instruction set for the 386 and higher chips would not fit on a single 8 1/2" by 11" card, printed front and back.

bsh3
 
.............. wow............ alot of replies, some more informative to my question then others but all helpfull :) thx. I couldn't get logged on for some reason, probubly because of my Linux somehow, but i learned that...... maybe i dont need Asm juusstt yet, i didn't even have a dire need to learn it in the first place, just my schools IT person said it helps to know Asm to understand Hex. I was trying to learn to use Hex and make no cd things, but due to the lack of popularity and information, getting badmouthed when asking it in other forums :(, i just gave up, came to the conclusion that i'll just have to go buy a new CD ROM drive every 6 months as my lame game screws it up. But thx for allll the info guys. But i know where to come for info on Asm if i ever need help :).

~Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top