DOC PREVIEW
CORNELL ECE 4760 - Study References

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Development Tools User Guide 4-1Section 4AVR Assembler User Guide4.1 IntroductionWelcome to the Atmel AVR Assembler. This manual describes the usage of the Assem-bler. The Assembler covers the whole range of microcontrollers in the AT90S family. The Assembler translates assembly source code into object code. The generated objectcode can be used as input to a simulator or an emulator such as the Atmel AVR In-Cir-cuit Emulator. The Assembler also generates a PROMable code and an optionalEEPROM file which can be programmed directly into the program memory andEEPROM memory of an AVR microcontroller.The Assembler generates fixed code allocations, consequently no linking is necessary.The Assembler runs under Microsoft Windows 3.11, Microsoft Windows95 andMicrosoft Windows NT. In addition, there is an MS-DOS command line version. TheWindows version of the program contains an on-line help function covering most of thisdocument.The instruction set of the AVR family of microcontrollers is only briefly described, refer tothe AVR Data Book (also available on CD-ROM) in order to get more detailed knowl-edge of the instruction set for the different microcontrollers.To get quickly started, the Quick-Start Tutorial is an easy way to get familiar with theAtmel AVR Assembler.Rev. 1022A-A–01/98AVR Assembler User Guide4-2 Development Tools User Guide4.2 Assembler Quick Start TutorialThis tutorial assumes that the AVR Assembler and all program files that come with it areproperly installed on your computer. Please refer to the installation instructions4.2.1 Getting Started Start the AVR Assembler. By selecting “File → Open” from the menu or by clicking on the toolbar, open the file “tutor1.asm”. This loads the assembly file into the Editorwindow. Read the program header and take a look at the program but do not make anychanges yet.4.2.2 Assembling Your First FileOnce you have had a look at the program, select Assemble from the menu. A secondwindow (the Message window) appears, containing a lot of error messages. This win-dow will overlap the editor window, so it is a good idea to clean up your work space onthe screen. Select the Editor window containing the program code, and select “Window→ Tile Horizontal” from the menu. It is useful to have the Editor window larger than theMessage window, so move the top of the Message window down a bit, and follow withthe bottom of the Editor window. Your screen should look like this:AVR Assembler User GuideDevelopment Tools User Guide 4-34.2.3 Finding and Correcting ErrorsFrom the looks of the Message window, it seems that you have attempted to assemble aprogram with lots of bugs. To get any further, the errors must be found and corrected.Point to the first error message in the Message window (the one reported to be on line54) and press the left mouse button. Notice that in the Editor window, a red vertical baris displayed all over line 54. The error message says that only registers R0 to R31 canbe assigned variable names. That is true since the AVR has exactly 32 General Pur-pose working registers numbered R0-R31, and “tutor1.asm” tries to assign a name toregister 32. See the figure below.Double click on the error message in the Message window and observe that the Editorwindow becomes active while the cursor is positioned at the start of the line containingthe error. Correct the mistake by changing “r32” to “r19” in the Editor window. Onedown, five to go. Now click on the next error in the list. The message “Illegal argument type or count”, tellsthat something is wrong with the arguments following the compare (“cp”) instruction.Notice that the register named “BH” is one of the arguments, which happens to be thevariable we just corrected. By clicking along on the remaining errors, it appears that thefirst error generated all the messages. 4.2.4 Reassembling To find out whether all errors have been corrected, double click on any error (to activatethe Editor window) or click inside the Editor window before you assemble once more. Ifyou have done it all right up till now, the Message window will tell that you are crownedwith success.AVR Assembler User Guide4-4 Development Tools User Guide4.3 Assembler source The Assembler works on source files containing instruction mnemonics, labels anddirectives. The instruction mnemonics and the directives often take operands. Code lines should be limited to 120 characters. Every input line can be preceded by a label, which is an alphanumeric string terminatedby a colon. Labels are used as targets for jump and branch instructions and as variablenames in Program memory and RAM.An input line may take one of the four following forms:1. [label:] directive [operands] [Comment] 2. [label:] instruction [operands] [Comment] 3. Comment 4. Empty line A comment has the following form:; [Text]Items placed in braces are optional. The text between the comment-delimiter (;) and theend of line (EOL) is ignored by the Assembler. Labels, instructions and directives aredescribed in more detail later.Examples:label: .EQU var1=100 ; Set var1 to 100 (Directive).EQU var2=200 ; Set var2 to 200test: rjmp test ; Infinite loop (Instruction); Pure comment line; Another comment lineNote: There are no restrictions with respect to column placement of labels, directives, comments or instructions.AVR Assembler User GuideDevelopment Tools User Guide 4-54.4 Instruction mnemonicsThe Assembler accepts mnemonic instructions from the instruction set. A summary ofthe instruction set mnemonics and their parameters is given here. For a detaileddescription of the Instruction set, refer to the AVR Data Book.Note: 1. Not available in base-line microcontrollersMnemonics Operands Description Operation Flags#Clock NoteARITHMETIC AND LOGIC INSTRUCTIONSADD Rd, Rr Add without Carry Rd ← Rd + Rr Z,C,N,V,H 1ADC Rd, Rr Add with Carry Rd ← Rd + Rr + C Z,C,N,V,H 1ADIW Rd, K Add Immediate to Word Rd+1:Rd ← Rd+1:Rd + K Z,C,N,V 2SUB Rd, Rr Subtract without Carry Rd ← Rd - Rr Z,C,N,V,H 1SUBI Rd, K Subtract Immediate Rd ← Rd - K Z,C,N,V,H 1SBC Rd, Rr Subtract with Carry Rd ← Rd - Rr - C Z,C,N,V,H 1SBCI Rd, K Subtract Immediate with Carry Rd ← Rd - K - C Z,C,N,V,H 1SBIW Rd, K Subtract Immediate from Word Rd+1:Rd ← Rd+1:Rd - K Z,C,N,V 2AND Rd, Rr Logical AND Rd ← Rd • Rr Z,N,V 1ANDI Rd, K Logical AND with Immediate Rd ← Rd • K Z,N,V 1OR Rd, Rr Logical OR Rd ← Rd v Rr Z,N,V 1ORI Rd, K Logical OR with Immediate Rd ← Rd v


View Full Document
Download Study References
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study References and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study References 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?