Advertisement
Guest User

Untitled

a guest
Oct 5th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // compile with
  2. // $ zig build-obj --release-small -mcpu atmega32u2 -target avr-freestanding-eabi test.zig
  3. // inspect ASM output with
  4. // $ avr-objdump -d -j .progmem.data test.o
  5.  
  6. const std = @import("std");
  7.  
  8. pub fn send(data: []const u8) void {
  9. for (data) |byte| {
  10. _ = asm volatile (
  11. \\hello:
  12. \\ rjmp .+20
  13. \\goodbye:
  14. :
  15. : [byte] "r" (byte)
  16. );
  17. }
  18. }
  19.  
  20. export fn main() void {
  21. var leds = [_]u16{0} ** 32;
  22. send(std.mem.sliceAsBytes(leds[0..]));
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement