Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. dbg
  2. mov rIO, '2'; Output 2
  3. mov rIO, x0A;
  4. mov rIO, '3';
  5. mov x00, x03; x00 will be the main counter
  6. .00
  7. add x00, x02; Add 2 to the main number
  8. mov x02, $00; Move main number to this
  9. .01
  10. sub x02, x02;
  11. mov x01, $00; Move the main number to x01
  12. mod x01, $02; If the modulo is 0, then the number is not prime.
  13. jmp x06, $01;
  14. jmp x00;
  15. .06
  16. mov x03, x02;
  17. dec x03;
  18. jmp x02, $03; Check if x02 is 1 - if so, the number is prime.
  19. jmp x00;
  20. .02
  21. mov x01, $00; Number to print
  22. mov x04, x05; Stack pointer
  23. .03
  24. inc x04;
  25. mov x02, $01;
  26. mod x02, #10; Find last digit
  27. add x02, x30; Make digit printable
  28. mov $04, $02; Move digit to the stack
  29. div x01, #10; Divide the number by 10 to get next digit
  30. jmp x04, x01; If there are no digits left, go to printing
  31. jmp x03; Else increment the counter and go back to moving numbers into stack
  32. .04
  33. jmp x05, *04; If there is nothing left to print, go back to counting
  34. mov rIO, *04; Print the digit
  35. dec x04; Decrement the stack pointer
  36. jmp x04;
  37. .05
  38. mov rIO, x0A; Output newline
  39. jmp x00;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement