; ***************************************************** ; * Jump labels within a macro: the answer is "yes" * ; * 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 which includes a label ; within that macro (mjmp) and a jump to a label ; outside that macro. Both jumps are translated ; correctly. ; .MACRO TestMacro inc mpr ; INC the register mpr brne mjmp ; If no overflow skip the next rjmp ovf ; Jump if overflow occurs mjmp: .ENDMACRO ; .LISTMAC ; ; Start of main program ; ldi mpr,0xFF ; Set PortB (LEDs) to be output out DDRB,mpr ; to Data Direction Register ; ldi mpr,0xFE ; Set the register to 254 testmacro ; Insert the macro here (one INC) testmacro ; Insert it once again here (another INC) ; As there should have been an overflow during the last INC ; the following code should not be reached. If executed, ; it would result in all LEDs on. ; outp: out PORTB,mpr loop: rjmp loop ; and end the program in a loop ; ; The overflow should occur and this code will be executed ; ovf: ldi mpr,0xFF ; Blank all LEDs out PORTB,mpr ; at Port B rjmp loop ; Jump to indefinite loop ; ; After execution all the LEDs PB.0 to PB.7 should be off.