tinygo/targets/avrtiny.S
Ayke van Laethem 2fb866ca86 avr: add attiny1616 support
This is just support for the chip, no boards are currently supported.
However, you can use this target on a custom board.

Notes:

  - This required a new runtime and machine implementation, because the
    hardware is actually very different (and much nicer than older
    AVRs!).
  - I had to update gen-device-avr to support this chip. This also
    affects the generated output of other AVRs, but I checked all chips
    we support and there shouldn't be any backwards incompatible
    changes.
  - I did not implement peripherals like UART, I2C, SPI, etc because I
    don't need them. That is left to do in the future.

You can flash these chips with only a UART and a 1kOhm resistor, which
is really nice (no special hardware needed). Here is the program I've
used for this purpose: https://pypi.org/project/pymcuprog/
2023-05-20 21:18:02 +02:00

44 строки
1,2 КиБ
ArmAsm

; TODO: remove these in LLVM 15
#define __tmp_reg__ r16
#define __zero_reg__ r17
; Startup code
.section .text.__vector_RESET
.global __vector_RESET
__vector_RESET:
clr __zero_reg__ ; this register is expected to be 0 by the C calling convention
; Keep the stack pointer at the default location, which is RAMEND.
; Initialize .data section.
.section .text.__do_copy_data,"ax",@progbits
.global __do_copy_data
__do_copy_data:
ldi xl, lo8(__data_start)
ldi xh, hi8(__data_start)
ldi yl, lo8(__data_end)
ldi yh, hi8(__data_end)
ldi zl, lo8(__data_load_start)
ldi zh, hi8(__data_load_start)
1: ; loop
cp xl, yl ; if x == y
cpc xh, yh
breq 2f ; goto end
ld r16, Z+ ; r0 = *(z++)
st X+, r16 ; *(x++) = r0
rjmp 1b ; goto loop
2: ; end
; Initialize .bss section.
.section .text.__do_clear_bss,"ax",@progbits
.global __do_clear_bss
__do_clear_bss:
ldi xl, lo8(__bss_start)
ldi xh, hi8(__bss_start)
ldi yl, lo8(__bss_end)
1: ; loop
cp xl, yl ; if x == y
breq 2f ; goto end
st X+, __zero_reg__ ; *(x++) = 0
rjmp 1b ; goto loop
2: ; end