You are not logged in.

#1 2009-01-27 05:24:47

pinchyfingers
Member
From: Bristol, PA
Registered: 2008-11-04
Posts: 46
Website

Assembly Programming

I am very interested in learning to program in x86 assembly. I've been reading all sorts of tutorials and searching for some place to start, but I still feel clueless. I have no idea what tools I need: assembler? (GAS?), emulator?, computer I don't mind breaking?

I understand that this is difficult and I probably won't understand it all overnight, but If anyone with more experience is willing to give me some guidance I'd really appreciate it. Just a little direction on where I can start.

Thanks a lot.

Offline

#2 2009-01-27 05:42:56

xor
Member
From: Sweden
Registered: 2003-03-20
Posts: 73

Re: Assembly Programming

Hi,

you may read this nice book "Assembly language step-by-step" hxxp://www.duntemann.com/assembly.htm
Still available I think.

/xor

Offline

#3 2009-01-27 06:11:11

pinchyfingers
Member
From: Bristol, PA
Registered: 2008-11-04
Posts: 46
Website

Re: Assembly Programming

Awesome. It looks like a cool book. I just ordered a copy.

Offline

#4 2009-01-27 07:39:31

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: Assembly Programming

As for tools a couple of good assemblers are:
flat assembler
nasm
yasm

Offline

#5 2009-01-27 09:15:11

deej
Member
Registered: 2008-02-08
Posts: 395

Re: Assembly Programming

Here are a few things which may help you:

Understanding the Stack:

http://www.jorgon.freeserve.co.uk/GoasmHelp/usstack1.htm
http://www.jorgon.freeserve.co.uk/GoasmHelp/usstack2.htm

...windows-centric, but it's the same for Linux. Take time to digest this, it
is absolutely essential that you understand the mechanism thoroughly.
The stack has a knack of appearing to be a simple concept, at first - but
beware, it has a knack of biting-you-in-the-ass !

http://heather.cs.ucdavis.edu/~matloff/50/LinuxAssembly.html
http://docs.cs.up.ac.za/programming/asm/derick_tut/

These two links will help to get your hands dirty wink

Beware of the two different syntax's used: AT&T and Intel. My opinion is
that the AT&T syntax is horrible; use Intel syntax.

The first of the above two links also introduces you to 'gdb' - the gnu-debugger.
Again, it is absolutely essential that you get the hang of this - it will pay you
well to suffer the trials of learning it, believe me. There are gui front-ends to
gdb -

http://sources.redhat.com/insight/index.php

- for instance,
which make the learning far easier.

You'll note that al lthe above links concern 32-bit assembly. Information
regarding 64-bit assembly is a bit thin-on-the-ground, but here's one
from AMD:

http://www.x86-64.org/documentation/assembly.html

Is it worth jumping straight into 64-bit assembly ? I'd say yes, but the
dearth of examples available will make it difficult, if not impossible. Just bear
it in mind; the mechanics used on 64-bit are the same as those used on 32-bit.

Hope this help...

Deej

Offline

#6 2009-01-27 11:43:35

Oxyd
Member
From: Czech Republic
Registered: 2008-01-17
Posts: 167

Re: Assembly Programming

pinchyfingers wrote:

computer I don't mind breaking?

Unless you plan on learning assembly on DOS or simillar real-mode OS, the chances of breaking your computer by your assembly mistakes are no bigger than the chances of doing so by messing up in any other language.

Also, you could perhaps try and get hold of some non-x86-based CPU -- some microcontroller would be great -- 8051 comes to my mind first.  x86 is grossly complicated as it's the result of evolution since the 80s.  And I found it quite a lot fun to program microcontrollers. smile  Once you get your mind around programming in machine-level instructions, the switch to x86 shouldn't be any harder than just reading about x86 instruction set, its stack, the way you interact with the OS and stuff like that -- this stuff shouldn't look so complicated once you know what you're doing with the individual instructions.

Offline

#7 2009-01-27 17:24:47

tsv
Member
From: UK
Registered: 2008-12-03
Posts: 71
Website

Re: Assembly Programming

There's a free (in all senses) book here, which is nice if you don't have any other programming experience, but may be a little simplistic if you do.

Good luck, assembly language programming can be an enlightening experience!

(Edited because I suddenly seemed to lose the ability to speak in English)

Last edited by tsv (2009-01-27 17:25:30)

Offline

#8 2009-01-27 19:34:44

tlawson
Member
From: MN, USA
Registered: 2009-01-24
Posts: 24

Re: Assembly Programming

Oxyd wrote:

Also, you could perhaps try and get hold of some non-x86-based CPU -- some microcontroller would be great -- 8051 comes to my mind first.  x86 is grossly complicated as it's the result of evolution since the 80s.

I'd just like to second this.  Another possibility is PDP/11 assembly language.  By contrast, it's quite simple, especially since the method it uses for storing instructions makes it very human-readable (assuming that you print it in octal).

Offline

#9 2009-01-28 04:14:37

pinchyfingers
Member
From: Bristol, PA
Registered: 2008-11-04
Posts: 46
Website

Re: Assembly Programming

Thanks a lot for all of the replies. I really like the idea of programming microcontrollers. Would programming an emulator be the same kind of experience or am I definitely better of with the real hardware? I'm all about getting the real thing, but until I do it'd be nice to have an emulator to work on.

I will go over all of the suggested reading. Thanks for the links.

I'm tired of being such a lightweight programmer, especially now that I am planning on going to school for computer science. I'm sure a lot of people can relate to my situation: I taught myself BASIC as a kid, but I didn't have the internet or many books, so I figured out a lot by trial and error and didn't understand much. I'm very familiar with Python, but I haven't finished any significant projects, I know enough C that I passed CS101 and enough Scheme to work through SICP. I really want to know what those electrons are doing whizzing around inside the computer, so I am committed to understanding assembly and completing a halfway interesting program.

Offline

#10 2009-01-28 10:28:21

jacko
Member
Registered: 2007-11-23
Posts: 840

Re: Assembly Programming

I really want to know what those electrons are doing whizzing around inside the computer, so I am committed to understanding assembly and completing a halfway interesting program.

in a sense, turning on and off switches/gates. In particular AND XOR etc... the concept of computers is fundamentally easy. I also recommend microcontrollers. I believe I read some of the books at a site who makes the 'Propeller' microcontroller.

You can google it, the forums are nice over there. I decided not to be lazy and found you the link. They have some very exciting projects. I been hesitant though as I don't know assembly that well either.

would help to add link http://www.parallax.com/tabid/407/Default.aspx

Last edited by jacko (2009-01-28 10:30:30)

Offline

#11 2009-01-28 11:23:04

tsv
Member
From: UK
Registered: 2008-12-03
Posts: 71
Website

Re: Assembly Programming

Also, I'm a little biased in that it was written by one of my lecturers, but the book "Computer Systems Architecture: A Networking Approach" by Rob Williams, is superb. Not directly about assembly, but it would make a nice companion book, really telling you what the computer is doing underneath. It's not afraid to go into detail, but remains accessible.

Wow, that sounded like sales spiel, but yeah, it helped me.

Do try to set yourself one big project in another language (you talked about not having done any). Find some piece of software you feel like you need, preferably, maybe work with friends. The experience of working on a large project is invaluable.

Offline

#12 2009-01-29 00:05:36

pinchyfingers
Member
From: Bristol, PA
Registered: 2008-11-04
Posts: 46
Website

Re: Assembly Programming

Programming From the Ground Up is a very cool book. I'ma few chapters into it and really enjoying it.

jacko: I came acrossed an article about programming the Propellor in assembly, maybe I'll look into getting one.

I really appreciate all of the help, so I'll keep posting as I make progress. After doing some reading and neing walked through two minimal programs, I already feel much more confident and knowledgable. Thanks for the encouragement.

Offline

Board footer

Powered by FluxBB