Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
7Activity
0 of .
Results for:
No results containing your search query
P. 1
Basics of Assembly

Basics of Assembly

Ratings: (0)|Views: 1,422 |Likes:
Published by GNY

More info:

Published by: GNY on Jul 14, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

01/14/2013

pdf

text

original

 
Welcome to my second tut. I know its been a while but im busy :-\.#############################################################Basic Assembly############################### By: z3ro###############################################################################www.darkmindz.org##############Why learn asm?Assembly is seen by many as being too much work to do most tasks. This althoughpartly true assembly is the one of the fastest langs around and is a low levellanguage so it lets you get down and dirty with your machine. Asm also is a greatlearning experience and teaches you how your computer works.Ok lets get started!CODE.model small.stack.dataMessage db "z0mg ASM!!$".codestart:mov dx,OFFSET Messagemov ax,SEG Messagemov ds,axmov ah,9int 21hmov ax,4c00hint 21hEND startOk happy? Fin.tongue.gif alright i guess i can explain it a little bit.First all asm programs start off with a .model call. in this situation we use thesmall memory model which means that the data and code segments are separate butboth are less than 64k. Ill explain more about memory models in another article.The .stack call is required for .exe programs which require a call stack tofunction.We then move into the .data segment. This is where all of your variables arestored.CODEMessage db "z0mg ASM!!$"In this example "message" is your var name. Db stands for declare byte and setsthe size of your var. The "{:content:}quot; symbol terminates the string and alsostores the string length in the var.
 
.codeThis segment stores your code! Who would of thought that? tongue.gifThe first thing you'll notice is the mov command. This copies x into y. It doesn'tmatter what y is so it can be a value register or var etc however you have to makesure x is able to store the amount of data and is same data type.Now were going to take a bit of a detour here to talk about registers.For now were only going to talk about the 16bit registers. Our general purposeregisters are:#note to use their 32bit cousins add an "E" to the front of the name #axbxcxand dxNow all of those above registers are 16bits in size however they each are actually2 registers. ax for example is split into ah and al. However ax al and ah can eachbe used separately for some tasks.Now the next thing you'll notice is the SEG and OFFSET. During the early computeryears they felt no one would ever use more than 1mb so the chip was designed tonot allow anything over 1mb. The problem however was that to access 1mb 20bitswere needed. Since registers were only 16 bits and they felt using 2(32bits) wasimpractical they decided to use SEGMENTS and OFFSETS to access 20bits using only 1register.EX:OFFSET=SEG x 16SEG=Offset / 16( the bottom 4 bits are lost sad.gif )1 register has the offset and 1 has the segment if you put them together you havea 20bit address biggrin.gif .EX2:CODESEGMENT 0010010000010000---- OFFSET ----0100100000100010 20-bit Address00101000100100100010DS stores the segment and SI stores the offset. Note any general register can beused to store an offset except for the segment registers which are CS, DS, ES, SS.^^ I hope you understand all that it took me a while to figure out.The mov ds,ax points or segment and offset to create our 20bit register whichstores our string.Next we move 9 into ah then use int 21. Int cmds are interrupts are like functionsand int 21 is the most common as it calls dos. When we use int 21 it searches ahfor the function and in this case its 9 which is print string.The final part mov ax,4c00h then int21 returns us to DOS. Ill fully explain it inthe next tutorial.Ok now you know how it works so lets compile it. I prefer to use tasm so thats howim going to explain it. Save the file as test.asm # or wtf you want.asmCODEC:\Perl\T\TASM5\BIN>tasm test

Activity (7)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Sonata Soni liked this
Adhi Loserkids liked this
Nana Siexieosep liked this
jase21 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->