Assembly: Code Template
The general template for designing an Assembly code program
TITLE
COMMENT |
|
.MODEL SMALL
.STACK 100H
.DATA
.CODE
.486
INCLUDE io.mac
main PROC
.STARTUP
done:
.EXIT
main ENDP
END main
-after title commonly listed is the name of the current file possibly including the path
-placed between the | | are comments describing the program
-model type SMALL describes code which only points within it's own scope, or uses extern with path name s.
-under .DATA goes your pre-defined terms, such as global variables and strings to be output
-under .CODE goes the actual code of your program
-.486 describes the type of program, if you wish to include ONLY 8086 type you may also choose .386
-the include here allows for read and write of IO properties from the keyboard (standard IO)
-main is only a standard name , it can be any name .STARTUP is a label to denote the beginning of the program code
-done: is a label showing a method beginning. Assembly works top down ignoring labels, but is a relative term to be used in jmp statements.
-.EXIT exits the program
-end PROC denotes the end of a process or program
Questions/Comments: william_a_wilson@hotmail.com
-William. (marvin_gohan)
Also see ...
H3How to implement the in assembly, the effect of the if statement, which is available to other languages./H3PBeing that Assembly is a low level language, as opposed to the high level most programmers are used to (eg: Java, C, C++, Perl, etc), it doesn't have all the same features that these l
H3How to use mov/H3Pmov is a useful tool in assembly language, it can move constants, or dynamics such as offsets. br / br /span style="font weight: bold"mov/span takes 2 parameters, the first is the reciever and the second is the operand. br / br /span style="font weight: bold"E
H3How to use jmp/H3Pjmp used as a jump statement jumps from one place to another: br / br /span style="font weight: bold"Example:/span br /div class="code" br /.MODEL SMALL br /.STACK 100H br /.DATA br /result_msg DB 'true inside if statement',0 br /test
H3How to use the conditional jmp, jumps (je, jg, jl, jne, etc)/H3Pa conditional jump, is just that, it jumps on a condition, if the condition is false, then if continues with the next line. br /eg: br / br /cmp 0,1 br /je one_equals_0 br /mov AX,0 br / br /if je ret
H3The size and reason for defining different sized parameters/H3Pdiv class="code" br /&91;b&93;DB&58;&91;/b&93; Define Byte ;allocates 1 byte br /&91;b&93;DW&58;&91;/b&93; Define Word ;allocates 2 bytes br /&91;b&93;DD&
