Advertisement

ASSEMBLY! Grrrrrrr....the pain!!!!

Started by June 17, 2002 09:31 PM
11 comments, last by masterconjurer 22 years, 6 months ago
How come that whenever I find a "working" assembly program, I download it, it works, but it won''t compile/run the file??? I even read the help files to make sure all the paths are set up! Maybe I should just dig deep into a good programming language and then code my own assembly program since I can''t seem to find one that will work properly! Can someone please help me out here? I''m desperate to find a working Assembly program that I can learn the lanugage! Thanks in advancc! Master Conjurer
quote: Original post by masterconjurer
How come that whenever I find a "working" assembly program, I download it, it works, but it won't compile/run the file??? I even read the help files to make sure all the paths are set up! Maybe I should just dig deep into a good programming language and then code my own assembly program since I can't seem to find one that will work properly! Can someone please help me out here? I'm desperate to find a working Assembly program that I can learn the lanugage! Thanks in advancc!


Master Conjurer


If you're a beginner as you probably are since you're posting in the Beginners forum, why in heck are you trying to learn assembly??? I did my share of ASM coding and I have to say this, since most ASM compilers use different syntax styles, you might not be using the ASM compiler that is required for your source file. Is the source file using the motorolla standard fo the X86 standard??? ( To know the difference, if you see alot of %%something or %soemthing in the source, it's most probably a motorolla asm compiler that you need )... Anyhow, if you can post the code of the file you're trying to compile, I might be able to help you out a bit more. If you don't want to post it in the forum, send to me via e-mail.

"DaHjajmajQa'jajHeghmeH!"

Cyberdrek
danielc@iquebec.com
Founder
Laval Linux

/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

[edited by - cyberdrek on June 17, 2002 10:58:10 PM]
[Cyberdrek | ]
Advertisement
I believe i got the code from a tutorial over at ProgrammersHeaven.com. I'm not sure which one it was because my friend printed it for me at school. It's just a simple little code that displays a smiley face on the screen. But when I go to COMPILE, it compiles, but when I click RUN, it gives me some strange error! This is in BLASM BTW.

[edited by - masterconjurer on June 17, 2002 11:54:49 PM]
thats because most old code was designed for use woth 16bit compilers (ie dos only). they wont compile with any windows compiler (since they are all 32bit). most old dos code was designed to be compiled using tasm, nasm, or masm 16bit.

dont start with asm unless you know c/c++ VERY well, know a lot about cpus/memory/os interaction, know how to use a compiler/assembler through command line, and finnally can understand errors that the compiler/asmebler spits out at you.

learn asm correctly, search for asm tutorials meant for windows, or code simple functions for use within a c/c++ app. dealing with 16bit code is not a good idea when all modern desktop OSes are 32bit and dont work like the old dos code you are trying to learn from.

also, if you cant access a website and get the code yourself (you do have net access it seems), you shoudl also recondier trying to learn asm.

asm is not super difficult, but learning it before you now how to code is not a good idea. its much more difficult to learn unless you can understand some of the code just because you can read and guess at some of the simple nemonics. also helps to use a c/c++ compiler that allows inline asm so you can just code small sections and not deal woth some of the uglier side of asm coding.

better yet, go buy a book if you can afford it, or search for one online. since all asm books come with the compiler you need as well as step by step you through the code you are better off and will actually learn something. heck, drawing a smily face to the screen is WAY too adavnced as the first thing to learn. start with a hello world app (tougher then you would think), then go from there.
Okay, assuming still want to give asm a try.

You might want to download MASM32. That is a version of MASM that will be set up completely for you so assembling with it is a piece of cake. It comes with lots of examples and is compatible with several tutorials on the net.

MASM32: http://www.movsd.com/masm.htm
Take a look at this site also:
http://spiff.tripnet.se/~iczelion/

You will also need documentation. Search the net to find the manuals to MASM. Also you will need the Intel IA-32 architecture reference manuals (Vol 1 - 3). These can be downloaded from
http://developer.intel.com

But be warned - if you don't know the principles of assember before you start you will never make it. Books that are good to give you a foundation are (read all of them in the order given):

John Waldron: Intrudction to Risc Assembly language programming (this teaches the basics of generic assembler - not Intel x86)
Patterson & hennesey: Computer Organization and Design (teaches how a processor works so you can understand the docs)
Silbershatz and Galvin: Operating System Concepts (teaches how an operating system works so you can understand the docs)

One final thing. There are many assemblers out there and *they are not compatible* so if a piece of source was written for one assembler then it must be compiled on that one. For instance MASM and TASM are very different (the two most popular assemblers).

But as previously mentionend by the other posters - if you don't know how to program at least C and you know it by heart you should not attempt assembler.

[edited by - felonius on June 18, 2002 4:14:17 AM]
Jacob Marner, M.Sc.Console Programmer, Deadline Games
quote: Original post by masterconjurer
I believe i got the code from a tutorial over at ProgrammersHeaven.com. I'm not sure which one it was because my friend printed it for me at school. It's just a simple little code that displays a smiley face on the screen. But when I go to COMPILE, it compiles, but when I click RUN, it gives me some strange error! This is in BLASM BTW.

[edited by - masterconjurer on June 17, 2002 11:54:49 PM]


As I alreay told you earlier in this same thread, ASM isn't compatible. Most compilers except x86 ASM and TASM which tend to use the same style, use different coding styles. Now, sice you didn't post the code, I can't tell you why it doesn't run properly when you compile it yourself as I don't have a clue what the problem might be. Since you state that it's just a simple program that prints a smiley to the screen, that should be done in about 10 lines max, maybe 20 if he's not using interrupts but then again, it might only take 3 lines. Just paste the code here... If you're using code that was designed for DOS with windows assembly language, none of the old code will work correctly. Get a good old DOS compiler and compile the code with it. ASM is hard to grasp since it didn't usually come with an IDE, or simple interface, you had to send the compile commands manually using DOS and then link the obj files manually also making sure to give the right command line parameters... I would recommend you learn how to proram before getting yourself into ASM, if you code asm badly( even if you think your code is good and it compiles, it still might not run or it might crash your system. You can even do permanent damage to systems... ), I remember coding a small app for school and in the process of coding it, I had a call to an interrupt, I had entered the wrong one by mistake and the program actually formated my HD. The day that happened, I had been coding ASM for about +/- 5 years and concidered myself an avanced ASM coder and still, a small dumb error and instead of doing what it should've done, my program formatted my HD. For another of my classes, I had coded a small virus( it was an anti-virus class ) to test our anti-virus, the virus would format random cluster upon each of it's pass. It's not too visible until you realise that some of your data is disappearing right in front of your eyes. Turn's out that the anti-virus detected it and eliminated it correcly but still, the point is, in ASM, you have total control over the machine( back in the DOS erra ) and it can be a dangerous tool.

"DaHjajmajQa'jajHeghmeH!"

Cyberdrek
danielc@iquebec.com
Founder
Laval Linux

/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

[edited by - cyberdrek on June 18, 2002 9:07:27 AM]
[Cyberdrek | ]
Advertisement
when you get the right books and tutorials you´ll see it is very easy to code some demos in assembler...
cyberdeck, much of what you speak of is not possible in linux, win2k, winxp, winnt, unix, etc. asm does give you complete control, it gives you better optimizing opurtunities. while some stuff cant be done in a higher level langauge, much of the dangerous stuff is prevented now since you require "root" access thus permission from the OS. no matter what your code is still running in user space and as such is limited to what the OS allows. dos allowed you to do anything. win9x allows most things, but some interupts dont work. win2k,linux,winxp,etc are VERY restrictive and wont allow things like direct access to the drive unless you are root. even then, you are still going through the OS.

remember, most assemblers dont come with pretty functions like in c/c++. you get nothing except the simple instructions of the cpu and some interrupt functions (some of which you cant even call while in protected mode). things like drawing lines must be done yourself. even things like a=b+4*x+1-q is multiple lines of code. just doing sin() or sqrt() requires you to actually write the function yoruself (though some newer cpus have a sin()/sqrt() instruction)

i highly suggest getting a c/c++ compiler that handles inline asm, and only write small functions or use it for optimization. it will be much easier then writing everything in asm.
quote: Original post by a person
remember, most assemblers dont come with pretty functions like in c/c++. you get nothing except the simple instructions of the cpu and some interrupt functions (some of which you cant even call while in protected mode). things like drawing lines must be done yourself. even things like a=b+4*x+1-q is multiple lines of code. just doing sin() or sqrt() requires you to actually write the function yoruself (though some newer cpus have a sin()/sqrt() instruction)

i highly suggest getting a c/c++ compiler that handles inline asm, and only write small functions or use it for optimization. it will be much easier then writing everything in asm.


The thing about getting a C/C++ compiler is a good idea and using inline asm is also often good. But there is nothing that prevent you from writing .asm files and then linking them with your C/C++ .obj files or even the C/C++ standard libraries. This allows you (for instance) to call the C functions sin() and sqrt() so you *dont* have to write them yourself.

I posted a thread the other day about using .asm files within Visual Studio. It works like a bliss. That way you can combine inline assembler, C, C++ and .asm files in the same project.
Jacob Marner, M.Sc.Console Programmer, Deadline Games
quote: Original post by a person
cyberdeck, much of what you speak of is not possible in linux, win2k, winxp, winnt, unix, etc. asm does give you complete control, it gives you better optimizing opurtunities. while some stuff cant be done in a higher level langauge, much of the dangerous stuff is prevented now since you require "root" access thus permission from the OS. no matter what your code is still running in user space and as such is limited to what the OS allows. dos allowed you to do anything. win9x allows most things, but some interupts dont work. win2k,linux,winxp,etc are VERY restrictive and wont allow things like direct access to the drive unless you are root. even then, you are still going through the OS.

remember, most assemblers dont come with pretty functions like in c/c++. you get nothing except the simple instructions of the cpu and some interrupt functions (some of which you cant even call while in protected mode). things like drawing lines must be done yourself. even things like a=b+4*x+1-q is multiple lines of code. just doing sin() or sqrt() requires you to actually write the function yoruself (though some newer cpus have a sin()/sqrt() instruction)

i highly suggest getting a c/c++ compiler that handles inline asm, and only write small functions or use it for optimization. it will be much easier then writing everything in asm.


Did you read my post correctly? I said I was talking about DOS ASM compilers since that's when I was started using ASM. OH, and BTW, it is possible since I did it. I still have those projects lying around. If you use an old DOS 6.22 boot disk to start your system, all the restrictions that the Windows implies are gone. And if his code is for DOS and he uses a windows compiler, there's a good chance that it won't work. That's why I told him to get a good DOS ASM compiler and use it. BTW, it might help if you read my post correctly before answering. I also stated that I had done these projects back in the old DOS days, again proof that you didn't read my post. Get a clue before posting... I'm not new to ASM...

"DaHjajmajQa'jajHeghmeH!"

Cyberdrek
danielc@iquebec.com
Founder
Laval Linux

/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

[edited by - cyberdrek on June 19, 2002 8:32:57 AM]
[Cyberdrek | ]

This topic is closed to new replies.

Advertisement