Talk:X86 assembly

Here is the original text of this page. --Whiteknight (talk)(projects) 00:16, 9 May 2006 (UTC)

Assembly for beginners
This book takes the opposite approach to teaching assembly by assuming the reader doesn't know anything about programming. It tries to make it as easy as possible to learn x86 assembly. To be useful to as many people as possible, this tutorial will assume that you're running Windows (2000 or higher.)

x86 means:
x86 is a family of 32-bit processors which includes the 386, 486, Pentium (586), Pentium Pro (686), Pentium 2, 3, 4, as well as all AMD processors such as the Duron and Athlon XP. This tutorial assumes that you have a 586 or higher processor.

Binary and hex
When programming assembly, binary and hexadecimal numbers are often used in place of their base 10 counterparts. There are many other pages on the web which cover this subject in great detail.

Hands on experiment
Go to start>run and type cmd.exe

This will send you into the windows command prompt, from here type debug and press enter then type r and press enter.

For now let's just explain what the lines a-dx=0000 mean, these are general purpose registers, and note that the 0000 is hexadicimal, not decimal or binary.

(place holder)

type a then enter

type mov ax,100 then enter twice

type t

you will notice that AX=0000 has now changed to AX=0100, not a whole lot of interesting stuff going on there. the mov instruction moves the second value into the first thing you give it. try this

a

mov bx,ax (enter twice)

t

note that bx now has the same value as ax, the value of ax was moved or copied into bx.

the commands add and sub work about the same and you can imagine what they do. You might be wondering what happens when you add 1 to FFFF, go ahead and try it just goes to zero, 2+FFFF=1, etc. same for subtracting.

mov ax,FFFF

add ax,1

-t

AX=0000

Also the registers can be split by changing the "x" in ax,bx,etc... to l or h, you can enter a two digit hexadecimal number, h is two high digits, l is two low digits. h would go on the left, l on the right.

mov ah,FF

add ah,2

t

AX=0100

note that only the first two decimals were changed.

To go any further
Well I don't really know how to do much more of this and you may have notice that the windows command line doesn't work so well and doesn't always give you what you think the answer should be. since all tutorials are outdated and windows is said to be horible for assembly programming someone needs to contribute a a better tutorial with an instruction on how to set up an emulation of a good operating system for assembly.