ATMEL Studio 7 Does Blink in Assembly Language


See the previous post (here) for detailed information on AS7 installation and simulating of an Arduino program execution. As an exercise to gain familiarity with AS7, lets make an assembly language project using the below Blink code:

• Select “File>New>Project”.

• Assembler.

• AVR Assembler Project.

• Give it a unique name.

• Select the proper device.

Remember to select the Simulator in order to run the program inside the AS7 IDE. See the previous post on how to do this. Here is a screen shot of the assembly code running in AS7:


Here is the code for a very basic assembly language blink program:

.include ""

.org 0x0000
   rjmp start
    ldi r16, 0           ; reset system status
    out SREG, r16        ; init stack pointer
    ldi r16, low(RAMEND)
    out SPL, r16
    ldi r16, high(RAMEND)
    out SPH, r16

    sbi DDRB, DDB5       ;pinMode(13, OUTPUT);
    sbi PORTB, PORTB5    ;turn LED on
    rcall _delay
    cbi PORTB, PORTB5    ;turn LED off
    rcall _delay
    rjmp _loop

    ldi r24, 0x00        ;one second delay iteration
    ldi r23, 0xd4 
    ldi r22, 0x30 
_d1:                     ;delay ~1 second
    subi r24, 1   
    sbci r23, 0   
    sbci r22, 0
    brcc _d1

Now, start learning inline assembly language:

Also available as a book, with greatly expanded coverage!

[click on the image]


About Jim Eli

µC experimenter
This entry was posted in arduino, assembly language and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s