Created
June 16, 2017 08:14
-
-
Save DaisukeMiyamoto/8f346fc446fc4667fb1842c67a3e5703 to your computer and use it in GitHub Desktop.
fizz buzz in assembler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .include "io.s" | |
| .text | |
| .global _start | |
| _start: | |
| mov x22, #1 // i = 1 | |
| mov x24, #30 // loop max | |
| mov x23, #1 // 3 counter | |
| mov x25, #3 // 3 | |
| mov x26, #1 // 5 counter | |
| mov x27, #5 // 5 | |
| mov x28, #1 // 15 counter | |
| mov x29, #15 // 15 | |
| Loop: | |
| sub x2, x28, x29 | |
| cbz x2, is15 | |
| sub x2, x27, x26 | |
| cbz x2, is5 | |
| sub x2, x25, x23 | |
| cbz x2, is3 | |
| mov x1, x22 | |
| bl print1d | |
| final: | |
| sub x11, x22, x24 | |
| cbz x11, Exit | |
| add x22, x22, #1 | |
| add x23, x23, #1 | |
| add x26, x26, #1 | |
| add x28, x28, #1 | |
| b Loop | |
| Exit: | |
| exit | |
| is15: | |
| mov x28, #0 | |
| mov x26, #0 | |
| mov x23, #0 | |
| mov x1, #-2 | |
| bl print1d | |
| b final | |
| is5: | |
| mov x26, #0 | |
| mov x1, #-1 | |
| bl print1d | |
| b final | |
| is3: | |
| mov x23, #0 | |
| mov x1, #0 | |
| bl print1d | |
| b final | |
| .data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment