Skip to content

Instantly share code, notes, and snippets.

@snakeneedy
Created March 7, 2017 11:48
Show Gist options
  • Save snakeneedy/b21be56a36b0fdec64558eab7743bc63 to your computer and use it in GitHub Desktop.
Save snakeneedy/b21be56a36b0fdec64558eab7743bc63 to your computer and use it in GitHub Desktop.
$t0 = 1 + 2 + ... + 25
.text
.globl main
main:
sub $t0, $t0, $t0
addi $t1, $0, 1
For:
add $t0, $t0, $t1
addi $t1, $t1, 1
beq $t1, 26, exit
b For
exit:
addi $15, $0, 15
jr $ra
@snakeneedy
Copy link
Author

要求

  • 實作出 1 + 2 + 3 + ... + 25 並將結果存放在 $t0
    • code 中必須有 iteration (利用 branch) ,不可直接將正確答案放入 $t0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment