Skip to content

Instantly share code, notes, and snippets.

@xatier
Last active December 30, 2015 06:29
Show Gist options
  • Save xatier/7789993 to your computer and use it in GitHub Desktop.
Save xatier/7789993 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main (void) {
int total, a, b, c, i;
int mem[100];
total = 0;
c = 20 // addi $6, $0, 20
mem[0] = 1; // addi $1, $0, 1
mem[1] = 2; // addi $7, $0, 2
a = 1; // addi $4, $0, 1
b = 2; // addi $5, $0, 2
i = 0; // addi $3, $0, 0
total = 0; // addi $2, $0, 0
start:
i++; // addi $3, $0, 1
total += a; // add $2, $2, $4
a = b; // add $4, $0, $5
// nop
total += b; // add $2, $2, $5
total += 3; // addi $2, $0, 3
b = total; // add $5, $0, $2
// nop
mem[i+1] = total; // sw $2, 0($?)
if (i != 20) // slt $9, $3, $6
goto start; // bdq $9, $0, start
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment