; *****************************************************
; * Demonstrates the use of macros with the ATMEL *
; * assembler, just a test program for use with the *
; * ATMEL STK200 board, (C) 2000 Gerhard Schmidt *
; * Report bugs to http://www.avr-asm-tutorial.net *
; *****************************************************
;
.NOLIST
.INCLUDE "8515def.inc"
.LIST
;
; Used registers
;
.DEF mpr=R16 ; a multi purpose register
;
; The following is the macro, a piece of code that
; will be inserted into your program whenever you
; need it there. Whenever you need the same sequences
; all over again and you don't want to call a subroutine
; you should write a macro and insert this sequence by
; calling that macro.
;
.MACRO TestMacro
inc mpr
inc mpr
inc mpr
.ENDMACRO
;
;
; Start of main program
;
ldi mpr,0xFF ; Set PortB (LEDs) to be output
out DDRB,mpr ; to Data Direction Register
clr mpr ; Clear the register
testmacro ; Insert the macro here (three INCs)
testmacro ; Insert it once again here (another 3)
com mpr ; Invert the result to display it
out PORTB,mpr ; and write it to the LEDs
loop:
rjmp loop ; and end the program in a loop
;
; Assembling this code should result in a 11 word long
; binary, because the two TestMacro-macros blow up to
; six INCs during the assembly process.
;
; After execution the LEDs PB.1 and PB.2 should be on,
; all others should be off to display the result (6 dec
; = 0000.0110 binary)!
;