Hack star
Published © CC BY-SA

Arduino Simulator - Arduino in assembly language!! - 2022

Learning Arduino online is very easy with online Arduino simulators. Learn how to blink LED using 100% assembly language with Wokwi

BeginnerFull instructions provided1 hour10,809
Arduino Simulator - Arduino in assembly language!! - 2022

Things used in this project

Story

Read more

Code

Assembly code - To blink an LED

Arduino
; Blink LED on PB5(Arduino Uno pin 13)
; http://forum.arduino.cc/index.php?topic=159572#msg1194604

#define __SFR_OFFSET 0

#include "avr/io.h"

.global main

main:
  sbi   DDRB, 5     ; Set PB5 as output

blink:
  sbi   PINB, 5     ; Toggle PINB
  ldi   r25, hi8(1000)
  ldi   r24, lo8(1000)
  call  delay_ms
  jmp   blink

delay_ms:
  ; Delay about (r25:r24)*ms. Clobbers r30, and r31.
  ; One millisecond is about 16000 cycles at 16MHz.
  ; The inner loop takes 4 cycles, so we repeat it 3000 times
  ldi   r31, hi8(4000)
  ldi   r30, lo8(4000)
1:
  sbiw    r30, 1
  brne    1b
  sbiw    r24, 1
  brne    delay_ms
  ret

Credits

Hack star

Hack star

75 projects • 101 followers
an Arduino enthusiast and an electronic hobbyist

Comments