Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dbg
- mov rIO, '2'; Output 2
- mov rIO, x0A;
- mov rIO, '3';
- mov x00, x03; x00 will be the main counter
- .00
- add x00, x02; Add 2 to the main number
- mov x02, $00; Move main number to this
- .01
- sub x02, x02;
- mov x01, $00; Move the main number to x01
- mod x01, $02; If the modulo is 0, then the number is not prime.
- jmp x06, $01;
- jmp x00;
- .06
- mov x03, x02;
- dec x03;
- jmp x02, $03; Check if x02 is 1 - if so, the number is prime.
- jmp x00;
- .02
- mov x01, $00; Number to print
- mov x04, x05; Stack pointer
- .03
- inc x04;
- mov x02, $01;
- mod x02, #10; Find last digit
- add x02, x30; Make digit printable
- mov $04, $02; Move digit to the stack
- div x01, #10; Divide the number by 10 to get next digit
- jmp x04, x01; If there are no digits left, go to printing
- jmp x03; Else increment the counter and go back to moving numbers into stack
- .04
- jmp x05, *04; If there is nothing left to print, go back to counting
- mov rIO, *04; Print the digit
- dec x04; Decrement the stack pointer
- jmp x04;
- .05
- mov rIO, x0A; Output newline
- jmp x00;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement