Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. ;
  2. ; AssemblerApplication1.asm
  3. ;
  4. ; Created: 29/03/2017 7:03:02 PM
  5. ; Author : Comp2121
  6. ;
  7. .include "m2560def.inc"
  8.  
  9. start:
  10. .dseg
  11. array: .byte 4
  12. .cseg
  13. string: .db "comp 24121.",0
  14.  
  15. ; Assign the parts of the string to the correct data memory locations
  16. ldi ZL, low(string<<1)
  17. ldi ZH, high(string<<1)
  18. ldi YL, low(array)
  19. ldi YH, high(array)
  20.  
  21. ldi r18, 20 ;Settign the Max String size to 20
  22.  
  23. loop1: ;Loading the string into program memory
  24. lpm r16, Z+
  25. ST Y+, r16
  26. dec r18
  27. brne loop1
  28.  
  29. ldi YL, low(array) ;Reinitialising the values in the Y Register
  30. ldi YH, high(array)
  31.  
  32. loop2: ;Taking stuff out of program memory and storing it into the stack.
  33. ld r16, Y ;Load r16 with the first value of the string from PM
  34. push r16 ;Push the value at r16 into the stack
  35. ST Y+, r16 ;Interates to the next value at Y
  36. brne loop2
  37.  
  38. .def a = r17
  39. ldi a ,1 ; Initialize a
  40.  
  41. loop3: ;This loop will pop the vlaue into data memory.
  42. pop a
  43. inc a ; Increment a
  44. brne loop3
  45.  
  46. end:
  47. halt:
  48. rjmp halt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement