Assembly: Code Template

Posted March 5, 2006 by William_Wilson in Computer programming

The following Tech-Recipes tutorial contains a 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 its own scope or uses extern with path names.

-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 it 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: [email protected]
-William. ยง (marvin_gohan)

The Conversation

Follow the reactions below and share your own thoughts.