diff options
author | Ayke van Laethem <[email protected]> | 2018-09-16 16:26:04 +0200 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2018-09-16 16:26:04 +0200 |
commit | a02426948b5867b5956a78d181a6842746fdd615 (patch) | |
tree | f43d2093a7ce5da8001f3b82067a8070ba9e4fc4 /targets/avr.S | |
parent | 39e3fe28db0db6ecc898fc56db06f47384d54499 (diff) | |
download | tinygo-a02426948b5867b5956a78d181a6842746fdd615.tar.gz tinygo-a02426948b5867b5956a78d181a6842746fdd615.zip |
avr: implement .data section
This doesn't completely work for some reason as the first character of
.data is corrupted, but otherwise it works.
Diffstat (limited to 'targets/avr.S')
-rw-r--r-- | targets/avr.S | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/targets/avr.S b/targets/avr.S index 838fd7841..b62c1add6 100644 --- a/targets/avr.S +++ b/targets/avr.S @@ -17,6 +17,23 @@ reset: out 0x3d, xl; SPL out 0x3e, xh; SPH + ; Initialize .data +init_data: + ldi xl, lo8(_sdata) + ldi xh, hi8(_sdata) + ldi yl, lo8(_edata) + ldi yh, hi8(_edata) + ldi zl, lo8(_sidata) + ldi zh, hi8(_sidata) +init_data_loop: + cp xl, yl ; if x == y + cpc xh, yh + breq init_data_end ; goto main + lpm r0, Z+ ; r0 = *(z++) + st X+, r0 ; *(x++) = r0 + rjmp init_data_loop ; goto init_data_loop +init_data_end: + ; main will be placed right after here by the linker script so there's no ; need to jump. |