An assembly language is a language that controls the primitive operations on binary data within a computer.
An assembly language program is made of two types of statements: executable instructions and assembler directives.
Let’s look at an example of an assembly language program that prints a zero-terminated string on simulates a binary counter using an array of 8 LEDs:
delay equ 500 *500ms delay between counts
start equ %11111111 *starts count down from 255
*Display to LCD
org $4000 *Program origin
lea msg,a0 *a0 points to the starting memory location of zero-
*terminated string to display
trap #7 *displays the zero-terminated string pointed by a0
*on the top line of the LCD Display
*Countdown using LED
move.w #start,d1 *d1 <- $FF
loop move.b d1,$30000 *LED array <- [d1]
move.w #delay,d0 *d0 <- $1F4
trap #$d *Delay by the number of milliseconds specified in d0
dbra d1,loop *Decrement d1 and goto to loop if result greater
* than zero
trap #0 *returns control of the CPU back to the Robot’s OS
msg dc.b 'Hello World',$0 *zero-terminated string
end
4.1.2 Program organisation
The assembly language program is written in four columns (or fields):
A word beginning in the left-most column is a programmer-defined label and is used by the assembler as a reference to that line. E.g.: delay, start, loop and msg.
A line beginning with an asterisk in its first column is a comment and is entirely ignored by the assembler.
Consider the line:
loop move.b d1,$30000 *LED array <- [d1]
This is the comment field and is entirely ignored by the assembler.
“move.b d1,$30000” is the actual instruction to be assembled.
“loop” is a label that refers to this line.
The assembler requires at least one space to separate the label and comment field from the actual instructions.
4.1.3 Decimal, Hexadecimal, binary and ASCII representation
The program is assembled producing a listing file. The following listing file contains the original assembly language and the machine code (in hexadecimal) produced by the assembler.
We now describe the five major assembler directives.
At this stage, we have some familiarity with the organisation of a 68000 assembly language program. We saw that programs are composed of assembler directives and executables instructions and we described five of the most important directives: EQU, DC, DS, ORG and END. Executable instructions are composed of an up-code and operands. We will later explain the main mechanisms indicating the address of operands to the assemblers.
REFERENCES
Source: http://www.mee.tcd.ie/~assambc/3d1_l04n.doc
Web site to visit: http://www.mee.tcd.ie
Author of the text: indicated on the source document of the above text
If you are the author of the text above and you not agree to share your knowledge for teaching, research, scholarship (for fair use as indicated in the United States copyrigh low) please send us an e-mail and we will remove your text quickly. Fair use is a limitation and exception to the exclusive right granted by copyright law to the author of a creative work. In United States copyright law, fair use is a doctrine that permits limited use of copyrighted material without acquiring permission from the rights holders. Examples of fair use include commentary, search engines, criticism, news reporting, research, teaching, library archiving and scholarship. It provides for the legal, unlicensed citation or incorporation of copyrighted material in another author's work under a four-factor balancing test. (source: http://en.wikipedia.org/wiki/Fair_use)
The information of medicine and health contained in the site are of a general nature and purpose which is purely informative and for this reason may not replace in any case, the council of a doctor or a qualified entity legally to the profession.
The texts are the property of their respective authors and we thank them for giving us the opportunity to share for free to students, teachers and users of the Web their texts will used only for illustrative educational and scientific purposes only.
All the information in our site are given for nonprofit educational purposes