View and vote on the article here: Assembly part 1
Assembly part 1| Category | | | Summary | | | Body | <div align="center]<strong>Assembly Part I </strong></div>
This is a tutorial for people, like me, who want to learn Assembly. I am not very good at it since im still learning it myself, but I will do my best. The first things you should know, used for our first program, are some basics about Assembly
Registers:
there are 4 main register types(for general purpose): ax, bx, cx, and dx
ax is usually used for memory usage (adding subtracting etc)
bx is usually used for pointers
cx is usually used in loops
dx is usually used for storing data
each register can be broken down into 2 parts, since each register is a 4 digit hexidecimal number, like 2a5gh (the h at the end denotes hexidecimal)
so we get things like ah and al
ah (h for high) and al(h for low) correspond with the high and low parts of the ax register
so if ax were to be 3c56h
ah would be 3ch and al would be 56h
using registers like this can be used to save some space in memory
(note: this also works for bx, cx, and dx registers)
there are more registers but we will get into them later
we will get into calls, flags, identifiers, and more registers in a later lesson also
our first program will demonstrate the simple Hello World program
;hello world program
;note, you can use the semi-colon to start a comment
.model small ;this tells the assembler that not
;alot of memory is needed for the program
.stack ;we will also get into this later, just
;put it there for now
.data ;here we will store our data
message db "Hello World!!","$"
.code
main proc ;begining of the process main
mov ax,seg message ;this moves the string to a register
mov ds,ax ;this moves the string to a data segment
mov ax,09h ;this calls the print to screen function
lea dx,ax ;LEA load effective address
;this loads the data in ds (used with
;register ds) with the fucntion at address
;in ax (which is 09h), essentially printing
;the string to screen
int 21h ;this inturupts the program which allows the
;string to be printed to screen
mov ah;4ch ;notice the ah, and the 4c, so ax is 4c00h
;this is the dos routine to exit to dos
int 21h ;this again allowing the program to exit
main endp ;end of the process main
end main ;end of the program and also tells the
;assembler where to start the program
Written by Apocolipse (March 13)
|
|
This article was imported from the CyberArmy University site. (original author: Apocolipse)
There are no replies to this post yet.
|